Working with AI agents¶
Redline is built so a coding agent can find a performance problem, fix it and prove the fix, using recorded data instead of guesses. Everything here is read-only unless stated; the few tools that send load or delete data stay off until the operator turns them on.
Machine-readable docs¶
| File | What it is |
|---|---|
/llms.txt |
Index of every page with a one-line summary (llmstxt.org format) |
/llms-full.txt |
All pages in one file, for loading into a context window |
/reference/settings.schema.json |
Every setting with its type and default (JSON Schema) |
/reference/cli.json |
Every command and flag |
They are generated by scripts/build_llms.py; CI fails when they are stale.
Give your agent the instructions¶
redline agent-skill --write ~/.claude/skills # a Claude skill: .../redline/SKILL.md
redline agent-skill --format agents --write . # AGENTS.redline.md to merge into AGENTS.md
The text covers how to find problems, fix them and verify, and the rules below.
MCP server¶
It speaks the Model Context Protocol over stdio (line-delimited JSON-RPC) and opens the store read-only. Example client entry:
{ "mcpServers": { "redline": { "command": "redline", "args": ["mcp", "--store", ".redline/redline.db"] } } }
Every tool takes a JSON-schema-checked argument object. Results are bounded in size, and credentials in URLs, tokens, header and cookie values and identity values are never returned (only their names).
Findings and traces
| Tool | Returns |
|---|---|
list_issues |
Findings ranked by sampled impact, each with why, callsite and suggestion |
explain_issue |
One finding in full |
fix_prompt |
A Markdown brief for fixing one finding, with constraints and how to verify |
diagnose_preview |
Exactly what redline diagnose --send would transmit; never sends |
list_traces |
Recorded requests, filterable by route, method, status, duration, queries, issues |
get_trace |
A bounded request summary: timings, issues, slowest spans (no bodies or logs) |
compare_traces |
Two requests side by side: time by kind, SQL that appeared or vanished |
list_endpoints |
Per-route latency percentiles, error rate and query counts |
search_sql |
Normalised SQL statements with counts and timings |
index_advice |
Index suggestions from the recorded workload (offline) |
cache_summary, external_summary, job_summary |
Cache hit rates, outbound call latency, background task outcomes |
history, compare_periods, list_releases |
Latency history, before/after comparison of two periods, release markers |
llm_summary |
Sampled LLM-call tokens and counts per route and model |
instrumentation_report |
What redline cannot see: inactive integrations, truncated traces, drops |
Load runs
| Tool | Returns |
|---|---|
list_load_runs |
Recent runs with status, knee step, max OK rps and verdict |
get_load_run |
One run: steps with latency percentiles and errors, the scenario (header, cookie and identity values removed) and its summary |
load_run_summary |
The analysis: knee, flows, recovery, drift, identities (names and counts), limiting_resource, resources |
load_run_bottlenecks |
Per step, the queries and routes that slowed most, with callsites |
load_run_metrics |
CPU, memory, GC, threads and connection-pool numbers per step and the likely limiting resource (GET api/runs/ID/metrics) |
validate_scenario |
Parses a scenario (object or .json/.toml file in the working directory) and returns errors or a summary; never runs it |
generate_scenario_from_openapi |
A scenario from an OpenAPI document; writes get weight 0; header values are not returned |
generate_scenario_from_traces |
A scenario weighted by the traffic recorded in the store |
generate_scenario_from_stages |
A staged (spike, soak, recovery) scenario from 10:30s,200:20s,10:60s or a stage list |
Database, SQL and checks
| Tool | Returns |
|---|---|
database_capabilities |
What the plan login may do (GET api/database/capabilities). The MCP server holds no database connection, so it answers supported: false unless a connection is registered in its process |
analyze_sql_plan |
Analyses a pasted SQL Server XML plan (operator tree, findings, suggested indexes); nothing is executed and the plan is not echoed back |
lint_sql, scan_sql_source, scan_sql_project |
Offline SQL lints for a statement, Python source text, or a directory inside the working directory |
analyze_source, analyze_project |
Static performance review of Python source or a directory |
doctor |
The setup checks of redline doctor for the working directory (database and production add the permission probe and the production checklist) |
check_report |
Summary of a saved redline check compare --json report |
check_findings |
Findings new in a saved report, each with a fix brief |
verify_fix |
gone / still_present / inconclusive from a saved compare report |
State-changing tools (off by default)
| Tool | Needs | What it does |
|---|---|---|
start_load_run |
--allow-load --load-target URL |
Starts a background load run against the operator's fixed target; one run at a time; scenarios that read local files or import code (data, identities_file, metric_sources) are refused |
stop_load_run |
--allow-load |
Asks a running load run to stop gracefully |
delete_load_run |
--allow-delete-runs |
Deletes a finished run and its steps |
Without the flags these tools are neither listed nor callable. The target is fixed by the
operator: a base_url in an agent's scenario is ignored, so an agent cannot aim load at
another host. The server itself still opens the store read-only; a started run is a separate
redline load process that writes its own results.
Bad input produces an error result the model can read; the server keeps running. With --audit, each call is appended as a JSONL record containing the tool
name, argument names and timing, never argument values. The file is created with mode 0600.
The fix loop¶
redline fix-prompt ISSUE_ID --store .redline/redline.db > brief.md # evidence + constraints
redline check record check.toml # baseline, before editing
# ...the agent edits the code...
redline check compare check.toml --json report.json
redline check verify report.json --kind n_plus_one # exit 0 only when gone
verify answers gone, still_present or inconclusive. A finding is only gone when it
was in the baseline, is absent now, responses are equal, and the run had enough samples with
complete server metrics. If it says inconclusive, collect more samples; do not declare
success. See Refactor check.
Reviewing agent-written code in CI¶
- run: redline check compare check.toml --json report.json --fail-on slower,changed,broken,budget
- run: redline check findings report.json --new-only --json > findings.json # exit 1 if any
findings lists issues that are new relative to the baseline and includes a fix brief for
each, which an agent step can consume. Pair it with the pytest markers
(@pytest.mark.redline(max_queries=…, no_n_plus_one=True)) and the redline check ratchet
query-count ratchet so a change cannot quietly add queries.
AI-assisted diagnosis¶
redline diagnose ISSUE_ID --store .redline/redline.db # preview only, nothing is sent
redline diagnose ISSUE_ID --store .redline/redline.db --send # opted in: really sends
Off by default. The default run prints the exact request (destination, model and body) and
exits. Sending needs three things together: --send, ai_diagnosis = true in the settings,
and the key in the REDLINE_AI_API_KEY environment variable. The destination host is fixed
for the provider (api.anthropic.com); it cannot be redirected. The body is an allowlist of
finding fields (kind, title, evidence, SQL shape with literals replaced, file, line,
function and one line of source) passed through the redactor. Request and response bodies,
logs and LLM prompt text are never part of it. Errors report the HTTP status only, never the
key or the provider's response body. Agents must not enable this themselves.
Rules for agents¶
- Never capture, log or paste prompt or completion text, tokens, passwords or request bodies.
- Do not delete traces or run EXPLAIN ANALYZE against a production store.
- Do not weaken a test, threshold or budget to make a finding disappear.
- Do not push, tag or publish without the owner's approval.
- Do not enable
ai_diagnosisor setREDLINE_AI_API_KEY; only the owner opts in.
Safe deployment recipe¶
Run the app with read_only = true and explain_analyze = false, point redline mcp at a
copy or read-only mount of the store, and keep --audit on. Without --allow-load and
--allow-delete-runs the MCP process cannot write to the store or send traffic at all.