Skip to content

Command line

← Index

Redline has two kinds of commands:

  • the redline program, installed with redline-core. It works on files and a running app from the outside: load tests, scenarios, configuration checks.
  • framework commands (manage.py redline_*, flask redline ...) that run inside your app and so know its settings, models and templates.

redline

redline load SCENARIO [options]       run a load test against a running app
redline export --store DB [ID --html OUT]   OTLP preview/send, or one HTML summary
redline digest --store DB --webhook URL    post newly seen issues to a chat webhook
redline init                          write a starter redline.toml and update .gitignore
redline load init ...                 write a scenario file
redline check record|compare|run|init|show|ratchet|comment|verify|findings|compare-live   refactor check: prove a refactor is safe
redline instrumentation --store DB    what redline cannot see (inactive integrations, truncated traces, drops)
redline mcp --store DB                serve read-only tools to an AI agent over MCP (stdio)
redline fix-prompt ISSUE --store DB   write a brief an AI agent can act on to fix one finding
redline agent-skill [--write DIR]     print or write the redline skill / AGENTS.md section
redline diagnose ISSUE --store DB     preview (opt-in: send) a redacted finding to an AI provider
redline config                        print the effective configuration
redline doctor                        check the setup
redline hash-password                 make a password hash for access = "basic"

Exit codes: 0 success, 1 a check or threshold failed, 2 a usage, configuration or scenario error, 130 interrupted with Ctrl-C. redline check adds 3, the app could not be reached.

redline init

Detects the framework (manage.py, then dependencies in pyproject.toml / requirements*.txt, then installed packages) and writes a starter redline.toml (preset, storage_path, sampling and ignore_paths, plus the adapter's install line as a comment). It also adds the store directory (/.redline/) to .gitignore, once.

redline init                    # write redline.toml, update .gitignore
redline init --dry-run          # print what would be written
redline init --pyproject        # append a [tool.redline] table to pyproject.toml instead
redline init --framework flask  # skip detection

It never overwrites: an existing redline.toml is left alone unless --force, and a pyproject.toml that already has [tool.redline] is never edited. --dir DIR selects the project.

redline export

redline export --store DB previews sanitized OTLP spans and issue logs as JSON; --send --endpoint URL posts them to an explicit collector (see security). It reads the store read-only.

redline export ID --html OUT --store DB writes one self-contained HTML file for a recording or a load run, to attach to a ticket or send to a colleague without giving them access to the UI. It has inline CSS only (no scripts, fonts or other external assets, and a Content-Security-Policy that forbids them), every value is HTML-escaped and passed through the project's redaction first. A recording shows its issues, a span waterfall, SQL grouped by statement and captured logs; a run shows its steps, errors and scenario paths. Request and response bodies, headers and SQL parameters are never included, and SQL is the normalized statement unless you add --include-sql (still redacted). Exit 1 when the id is unknown.

redline digest

Posts the issues that appeared recently to a Slack-compatible incoming webhook, once each.

redline digest --store .redline/redline.db --webhook "$SLACK_WEBHOOK" --since 24h
redline digest --store .redline/redline.db --dry-run        # print the payload

It reads the store read-only and picks the issues first seen within --since (default 24h; 30m, 7d... as in the load tester) that earlier digests have not reported, at or above --min-severity. The payload is {"text": "..."}: a headline, then up to 20 lines [severity] kind: title on route (xN), worst first, then ...and N more; --ui-url adds a link to the Issues page and --title renames the first line. Text is passed through the project's redaction and Slack control characters are escaped.

Issues are identified by their stable id (the fingerprint that deduplicates them across requests). The ids that were sent are kept in --state FILE (default digest-state.json next to the store) only after the webhook answered 2xx, so a failed run is retried by the next one, and an issue is never posted twice. Entries older than 30 days are dropped from the file. Redirects are not followed and the URL must be http(s) without credentials. Exit codes: 0 sent or nothing new, 1 store unreadable or delivery failed, 2 usage error. Run it from cron or a scheduled CI job on the development or staging environment.

redline load

Drives an app at a controlled request rate and records the run. --fail-p95-ms and --fail-error-rate make it a CI gate. It is documented in full on the Load testing page, including the options table.

redline load scenario.toml --steps 10:100:10 --step-duration 20s
redline load scenario.toml --rps 50 --duration 60s --fail-p95-ms 400

redline load init

Writes a scenario from an OpenAPI document or from the traffic Redline has captured.

redline load init --from-openapi http://localhost:8000/openapi.json -o scenario.toml
redline load init --from-traces --top 15 --window 7d -o scenario.toml

See Generating scenarios.

redline check

The refactor check: replay a suite of read-only requests against the old code, then the new code, and compare the responses and the timings. Needs redline-core[load] (httpx). Python 3.10 needs tomli for TOML suites (JSON suites always work).

redline check record  SUITE [options]   run a suite and write a baseline
redline check compare SUITE [options]   run it again and compare with a baseline
redline check run     SUITE [options]   record if there is no baseline file yet, else compare
redline check init --from-traces [...]  write a suite from recorded read-only traffic
redline check show    REPORT.json       print a saved report again
redline check ratchet SUITE            fail on new query-count regressions; --update tightens
redline check comment REPORT            post a report as the sticky PR comment (GitHub Actions)
redline check verify  REPORT --kind K   is a finding gone, still_present or inconclusive? (exit 0 only when gone)
redline check findings REPORT [--new-only]  list findings, with an agent brief each (exit 1 when any are new)
redline check compare-live SUITE --old URL --new URL  alternate requests between two running versions

SUITE is a .toml or .json suite file.

Option On Meaning
--base-url URL record, compare, run Override the suite's base_url
--store PATH record, compare, run The app's Redline store, for server-side metrics. Default: the configured storage_path when that file exists
--no-store record, compare, run Client-side metrics only
--label TEXT record, compare, run A label for this run (for example before)
-q, --quiet record, compare, run No progress line
--out FILE record, run Baseline file to write. Default <suite>.baseline.json next to the suite
--baseline FILE compare, run Baseline JSON. Default <suite>.baseline.json
--baseline-id ID compare, run A baseline stored in --store instead of a file. Not together with --baseline
--json OUT compare, run Write the full report as JSON
--markdown OUT compare, run Write a Markdown PR comment
--junit OUT compare, run Write JUnit XML, one test case per request
--fail-on LIST compare, run, show Verdicts that make the exit code 1: any of slower, changed, broken, missing, noisy, faster, or none. Default slower,changed,broken,missing
--slower-pct X, --slower-ms Y compare, run Override thresholds.slower_pct and thresholds.slower_ms for this run
--ruff [PATH] compare, run, show Include Ruff JSON from PATH; with no path run ruff check --select F --output-format json. Findings appear in the Markdown and JUnit outputs and make the exit code 1
--no-color compare, run, show No ANSI colours

redline check init takes --from-traces (required), --store PATH, --route PATTERN (repeatable fnmatch pattern on the route), --limit N (default 20), --base-url URL, -o/--out OUT (default check.toml; .json writes JSON; - writes to stdout) and --force. It writes base_url only when --base-url is given or the traces show a single host; otherwise it leaves a commented # base_url = "http://127.0.0.1:8000" line to fill in. It writes one request per read-only route Redline has seen, using the most recent concrete path; header values are never copied, and an Authorization or Cookie header gets a ${env:REDLINE_CHECK_AUTHORIZATION} or ${env:REDLINE_CHECK_COOKIE} placeholder.

redline check show takes the report JSON and prints it again; --markdown OUT and --junit OUT write those files from it. It exits 0 unless --fail-on is given; with --fail-on it exits 1 when a request matches it, as compare does. --ruff attaches a Ruff result to the report (or re-runs ruff check --select F); any finding, or a failure to read the result, makes compare/run exit 1. Redline is not a linter: it only carries Ruff's JSON into the same report.

redline check init --from-traces --route '/orders*' -o checks/orders.toml
redline check record checks/orders.toml --label before
redline check compare checks/orders.toml --markdown report.md --junit report.xml

Exit codes: 0 nothing matched --fail-on, 1 something did, 2 a usage, suite or baseline error, 3 the app could not be reached at all, 130 interrupted (Ctrl-C or SIGTERM; a record then writes no baseline). More in Outputs and exit codes.

redline instrumentation, mcp, fix-prompt, agent-skill, diagnose

Tools for working with AI agents. All read a store and none changes it.

Command Purpose Exit codes
redline instrumentation --store DB [--window S] [--json] What redline cannot see: integrations installed but not instrumented, truncated traces, traces without a profile, dropped and failed writes 0, 2 bad window
redline mcp --store DB [--audit FILE] MCP server over stdio with read-only tools (list_issues, explain_issue, get_trace, instrumentation_report, verify_fix, llm_summary) 0, 2 store not found
redline fix-prompt ISSUE --store DB [--window W] [--out FILE] Markdown brief with evidence, constraints and the verify steps for one finding 0, 2 unknown issue or store
redline agent-skill [--format skill\|agents] [--write DIR] [--force] The Claude skill or AGENTS.md section that teaches an agent to use redline 0, 2 file exists
redline diagnose ISSUE --store DB [--send] Preview the exact request to an AI provider; --send also needs ai_diagnosis = true and REDLINE_AI_API_KEY 0, 1 provider error, 2 not opted in

redline check verify REPORT --kind KIND [--fingerprint FP] [--min-samples N] [--json] reads a saved compare report; redline check findings REPORT [--new-only] [--json] lists findings with a brief each; redline check compare-live SUITE --old URL --new URL [--rounds N] [--json OUT] sends each request to both servers and flips the order every round. See Refactor check.

redline config

Prints the effective configuration: every setting's final value, grouped (capture, sampling, detectors, storage, access, features, other), which layer it came from (default, preset, file, or env REDLINE_X) and any warnings. Secrets are shown as ***. Use it first when a setting seems to be ignored.

REDLINE_PRESET=production redline config
redline config --json                       # the same data as GET api/config
redline config --project-root ./backend     # where to look for redline.toml

It reads the file and environment layers only. Settings you give in code (REDLINE = {...}, install(settings=...)) are not visible to a separate command; the running app's complete view is the UI's Settings page and GET api/config. An invalid configuration (for example access = "token" without a token, or a misspelled REDLINE_* variable) prints the error and exits with 2.

See Configuration.

redline doctor

The storage check creates and removes its own temporary probe in the nearest existing parent directory. It does not write to or initialize the configured database. This checks actual filesystem behavior rather than permission bits alone, which can be misleading under root or on special/read-only mounts.

Checks that the setup is sound. Each line is OK, WARN or FAIL; the command exits 1 if any check fails or the configuration does not load, and 0 otherwise (warnings do not fail it). It takes --json and --project-root DIR like redline config, plus:

  • --workers N: the number of worker processes the deployment runs. Without it the count is read from WEB_CONCURRENCY, --workers/-w in GUNICORN_CMD_ARGS and UVICORN_WORKERS.
  • --strict: any warning makes the command exit 1, and the filesystem and workers checks about a SQLite store are reported as FAIL. Use it in deployment pipelines.
  • --production: also check the recording-only production policy (see Production doctor gate).

With storage_url set, the storage check verifies the PostgreSQL driver is installed and the database answers (password masked in the output); the SQLite file checks are skipped.

Check Looks at
storage a temporary file can actually be created/written in the nearest existing parent; an existing store can be opened for writing without truncation
storage WAL a throwaway SQLite database beside the store really accepts PRAGMA journal_mode=WAL; failure is a hard error because a writable store refuses non-WAL
filesystem on Linux, the mount type from /proc/self/mountinfo; nfs, cifs, 9p, virtiofs, fuse and similar mounts warn that WAL may not be reliable (fail with --strict)
workers more than one worker process sharing a SQLite file warns, recommending storage_url (fail with --strict)
ui bundle the prebuilt UI is present in redline-core
access open fails (warns when REDLINE_ALLOW_OPEN=1 is set); access not set in the file or environment warns (FastAPI, Flask and Litestar answer 404 outside debug mode unless the app sets it in code); trust_unix_socket warns; local outside the dev preset warns, because behind a proxy nobody can reach Redline
token shorter than 24 characters (warn), an unreadable token_file (fail), a token_file readable by other users (warn)
basic an invalid hash (fail), fewer than 100 000 PBKDF2 iterations (warn)
sessions token or basic without secret_key: logins are per worker process (warn)
proxies token/basic with trusted_proxies empty (warn: behind a proxy every client shares one login rate-limit bucket, and X-Forwarded-Proto is not believed for the Secure cookie), or another non-local policy outside dev
capture the production preset capturing request or response bodies or locals (warn)
retention history_retention_days off, or max_rows and max_age_days both off (warn)
load load_from_ui on but httpx missing (warn)

It sees the file and environment layers only, like redline config. Run it in your deploy pipeline and after changing access settings.

redline hash-password

Prompts for a password twice (a mismatch exits 2) and prints a PBKDF2-SHA256 hash to put in basic_users. The password is never echoed or stored. When stdin is not a terminal it reads one line from stdin instead, so it can be scripted. --iterations N sets the cost (default 600 000, minimum 1 000). See Access control.

redline hash-password
echo 'correct horse' | redline hash-password --iterations 800000

Django

Command Does
manage.py redline_clear [--noinput] Delete every recorded trace (asks to confirm unless --noinput). History is kept
manage.py redline_prune [--max-age-days N] [--max-rows N] Apply retention now. 0 disables that rule for this run
manage.py redline_scan [PATHS] [--json] [--fail] [--dialect django\|jinja] [--no-drf] Static N+1 scan of templates and DRF serializers
manage.py redline_scenario [-o FILE] [--base-url URL] [--force] Generate a load-test scenario from your URLconf (stdout without -o)

Flask

Command Does
flask redline clear [--yes] Delete every recorded trace (asks to confirm unless --yes, -y or --noinput)
flask redline prune [--max-age-days N] [--max-rows N] Apply retention now
flask redline scan [--json] [--fail] Static N+1 scan of the Jinja templates of the app and its blueprints
flask redline scenario [-o FILE] [--base-url URL] [--force] Generate a load-test scenario from the url_map (stdout without -o; default base URL http://127.0.0.1:5000)

FastAPI and Litestar

These adapters have no command group of their own. Use the redline program, and the store directly for housekeeping:

from fastapi_redline import install

redline = install(app, engine=engine)
redline.store.prune(max_age_s=86_400, max_rows=1_000)

Scenarios come from the app's OpenAPI document:

redline load init --from-openapi http://localhost:8000/openapi.json

Production doctor gate

redline doctor --production --strict --json adds the recording-only production policy to the ordinary storage/access probes. It validates rather than changes settings. Warnings retain their warn status in JSON but produce nonzero exit status under --strict; configuration failures also produce valid JSON. See Production deployment.