Tell Claude Code which endpoint is slow. Get back a measured, verified fix.
Profyle traces the requests of your FastAPI, Flask, Django or Tornado app and gives
Claude Code what it needs to find the bottleneck, fix your code and prove the fix by
replaying the same request.
Quick start
1. Install, once per project
$ pip install profyle
$ profyle init
profyle init connects Claude Code to Profyle in this project. Commit the two files it
adds (.mcp.json and .claude/skills/) and your teammates only need pip install profyle.
2. Ask Claude Code
GET /orders is slow, can you fix it?
You don't have to start anything first: Claude starts your app with tracing if needed.
3. Get a measured, verified fix
GET /orders now takes about 17 ms warm, down from about 120 ms.
Root cause: an N+1 query. list_orders (main.py:22) called get_customer
(main.py:17) once per order: 50 calls, 107 ms, 90% of the request.
Change: get_customers fetches all the names with one WHERE id IN (...) query.
| Before | After |
|---|
| Median request time | 119.9 ms | 16.9 ms |
| Lookup calls | 50 | 1 |
Behavior check: status 200 and an identical response body before and after.
A real Claude Code session on a project with no Profyle code and the server stopped.
What Claude did between steps 2 and 3
- Checked the setup with
doctor: nothing traced yet.
- Found the dev server command in the README and, with your OK, started it with
profyle run uvicorn main:app --reload, which traces without code changes.
- Called the endpoint and replayed it 3 times for a warm baseline (the first request
of a server includes warm-up).
- Read the trace digest:
list_orders → get_customer ×50, 90% of the request.
- Fixed the code, waited for the reload, replayed the same request and compared the
traces: 7× faster, same status, same response body.
[!WARNING]
Profyle is a development tool. Tracing slows requests down and traces contain
source code and request data, so do not enable it in production. See
SECURITY.md.
Without Claude Code
Start your dev server through profyle run, and every request tells you where its time
went:
$ profyle run uvicorn main:app --reload
profyle ▸ GET /orders 123.8 ms · #2 · repeated: list_orders → get_customer ×50 (87.1%)
Then dig into any trace:
$ profyle start # browse the traces in a web UI, with Perfetto
$ profyle analyze 2 # the bottleneck digest of trace #2
$ profyle replay 2 # send the same request again and compare
Good to know
- Requirements: Python 3.10+.
- Which environment Claude uses:
profyle init starts the MCP server with uv run or
poetry run in projects that use them, and with profyle from your PATH otherwise.
In that case open Claude Code with your project's environment activated, or edit the
command in .mcp.json.
- Many projects? Install the Claude Code plugin once instead of running
profyle init
in each: claude plugin marketplace add vpcarlos/profyle && claude plugin install profyle@profyle (set PROFYLE_COMMAND=/path/to/.venv/bin/profyle if profyle is not
on your PATH).
- Remove it:
profyle uninstall, then pip uninstall profyle (see
Uninstall).
Add tracing to your app
Without code changes: profyle run
Put profyle run in front of the command that starts your dev server: