Skip to main content
contextrot logo

contextrot

Your coding agent gets worse as its context fills.
contextrot proves it on your own sessions — and tells you exactly what to change.

PyPI version PyPI Downloads Python versions CI License: MIT

Quick start

uvx contextrot

or, with plain pip (Python 3.9+ — including the stock python3 on macOS):

pip3 install contextrot
contextrot

contextrot: command not found after pip install? Your Python scripts directory isn't on PATH (common with the stock macOS python3). Either use uvx contextrot above, or run it PATH-free with python3 -m contextrot.

That's it. No config, no API keys, no uploads. contextrot reads the session transcripts your agent CLI already keeps on disk and answers a question no other tool answers:

At what context fill does my agent start failing, what's causing it, and what is it costing me?

contextrot terminal report: verdict, rot curve by context fill with confidence intervals, context composition, and prescriptions

Every report leads with a plain verdict — one of four honest answers:

Verdict Meaning
Context rot detected your failure rate climbs significantly as context fills
! Edge rot flat until near the window limit, then it climbs — compact before you get there
No measurable rot your failure rate stays flat; your setup is working
? Not enough data keep using your agent and re-run

A tool that can say "you're fine" is a tool you can trust when it says you're not.

Why a benchmark can't tell you this

Research (Chroma's context-rot report, several 2026 papers) shows LLM output quality degrades as input context grows — even far below the window limit. But that research runs synthetic tasks in lab conditions. Your degradation point depends on your projects, your MCP setup, your model, your prompting style.

contextrot measures it where it actually matters: in your own sessions.

How it works

Agent CLIs like Claude Code log every session to local JSONL transcripts. Each step carries token accounting and behavioral evidence. contextrot extracts five independent failure signals per step and correlates them with context fill at that moment:

Signal What it catches
Edit failures the agent tried to edit code and missed — the clearest "lost track of file state" event
Retry loops the same tool call repeated after an error: paying twice for one action
Re-reads re-reading files it already read — content scrolled out of effective attention
Self-corrections "I apologize, let me fix that"
Tool errors any failed tool call

Statistics are kept honest: Wilson 95% confidence intervals, per-signal breakdowns, visible n-counts, and a degradation threshold that only gets declared when a bucket's confidence floor clears the baseline — one noisy bucket can't scare you. Full method: docs/methodology.md.

Use more than one model? The report also compares them head-to-head — an independent rot curve and verdict per model family (Opus vs Sonnet vs Haiku), on a shared scale, so you can see which model degrades first for your workload.

Work across several repos? contextrot projects does the same head-to-head by project — an independent rot curve and verdict per working directory, ranked by size, so the specific repo whose CLAUDE.md or MCP setup is dragging you down stops hiding inside your all-projects average.

Use more than one coding agent? contextrot agents compares them too — Claude Code vs Codex CLI vs Gemini CLI vs Cline, each with its own curve and verdict on a shared scale, measured on your workload rather than a benchmark's.

Commands

contextrot                      # full report, last 30 days
contextrot --days 90            # more history = tighter statistics
contextrot -p myproject         # one project only
contextrot --html report.html   # shareable single-file report (still 100% local)
                                #   includes a 1200×630 share card — save as PNG,
                                #   post it; and a per-model comparison when you
                                #   use more than one model
contextrot --json               # every number, recomputable
contextrot projects             # rank your projects — which repo rots first
contextrot agents               # rank your coding agents — which CLI rots first
contextrot install statusline   # live context-health segment in Claude Code's
                                #   statusline, colored by YOUR measured curve
                                #   (dry-run by default; --apply to write)
contextrot install hook         # one-time in-session warning when you cross
                                #   your measured degradation threshold
contextrot mcp                  # MCP stdio server — let any MCP-capable agent
                                #   query your rot report mid-session
                                #   (claude mcp add contextrot -- contextrot mcp)
contextrot trends               # week-over-week: is your hygiene improving?
                                #   (the before/after check for `fix`)
contextrot fix                  # dry-run: prescriptions + unused MCP servers +
                                #   CLAUDE.md size. Add --apply to disable unused
                                #   *global* MCP servers (backs up first, reversible)
contextrot badge                # local SVG verdict badge for your README —
                                #   no badge service sees your data
contextrot sessions             # list what was parsed

Live statusline (Claude Code)

The report tells you where you degrade; the statusline tells you while it's happening. After contextrot install statusline --apply, Claude Code's status bar shows your current context fill colored against your own measured curve — not a generic "yellow at 70%":

ctx 72% ███████░░░ · ▲ past your knee (~70%) · fail here 4.8% (1.5× fresh)

Every plain contextrot run recalibrates it from your latest data. Other statusline tools show cost and a hardcoded threshold; this one knows where you start failing. Dry-run by default, backed up, reversible with contextrot uninstall statusline.

Prefer an active nudge over a passive bar? contextrot install hook registers a PostToolUse hook that warns once — the moment a session crosses your measured threshold — then stays quiet until the next crossing. If your curve has no knee, it says nothing at all: no generic scare thresholds.

How is this different from…

Tool Question it answers What it can't tell you
ccusage "How much did I spend?" anything about output quality — use both, they're complementary
Claude Code /context "What's in my window right now?" no outcomes, no history, no correlation
Langfuse / Phoenix / MLflow "How is the app I built behaving?" require instrumentation; contextrot analyzes the agent you use, zero setup
Chroma's research "Do models degrade on benchmarks?" nothing about your workload — contextrot is the personal-data counterpart

FAQ

The report says $2,000+ but I'm on a $20/month subscription. Is it broken? No — that figure is the token value of your usage priced at API list rates, labeled as such in the report. It exists because tokens are the resource that fills your context window and burns your rate limits, and dollars are the only unit everyone reads instantly. Two honest readings: it's what your usage would cost pay-per-token (enjoy your subscription), and the "burned in degraded steps" share is the fraction of that resource going to rework. It is not, and never claims to be, your bill.

Why is the token flow so large? Agents re-send the entire conversation to the model on every step. A 100-step session at 100k context ≈ 10M tokens flowing through — mostly cache reads. That's normal; it's also exactly why context bloat matters.

Correlation isn't causation, right? Right, and the report says so on its face. Deep-context steps are also later-in-task steps. contextrot is an observational diagnostic with conservative statistics, not a lab experiment — see methodology.

What about my privacy? contextrot makes zero network calls. Local files in, terminal/local HTML out. Grep the codebase for an HTTP client — there isn't one.

Supported agents

Agent Status
Claude Code ✅ today
OpenCode ✅ today — community-contributed
Codex CLI ✅ today
Gemini CLI ✅ today
Qwen Code ✅ today — same recording format as Gemini CLI
Cline (VS Code) ✅ today
Roo Code (VS Code) ✅ today
Kilo Code (VS Code) ✅ today
Kiro CLI ❌ blocked upstream — its transcripts record no token counts, so context fill can't be computed
OpenTelemetry GenAI spans planned

An adapter is one small file with a fixture and a test — it's the paved first-contribution path.

Roadmap

  • contextrot fix (0.6.0) — dry-run prescriptions + unused-MCP-server detection, reversible --apply
  • ✅ Adapter wave (0.6.1–0.7.0) — Codex CLI, Gemini CLI, Qwen Code, Cline, Roo Code, Kilo Code + per-agent comparison
  • ✅ Live surfaces (0.8.0–0.10.0) — calibrated Claude Code statusline, knee-crossing warning hook, MCP server for any agent
  • contextrot trends (0.11.0) — week-over-week before/after measurement for fix
  • OpenTelemetry GenAI span ingestion
  • Opt-in, anonymized aggregate stats → the State of Context Rot report: real-workload degradation curves across the community (off by default, aggregate-only, documented schema)

Contributing

See CONTRIBUTING.md. Most valuable first PR: an adapter for the agent CLI you use — there are spec'd, ready-to-pick-up adapter issues waiting.

Ran the tool? Share your rot curve — flat curves count too.

Contributors

Stats

Downloads per month Downloads per week Downloads per day Views

Live dashboards: pypistats · clickpy (ClickHouse)

If contextrot told you something useful about your setup, a ⭐ helps other agent users find it.

Star History Chart

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contextrot-1.0.0.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

contextrot-1.0.0-py3-none-any.whl (83.8 kB view details)

Uploaded Python 3

File details

Details for the file contextrot-1.0.0.tar.gz.

File metadata

  • Download URL: contextrot-1.0.0.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for contextrot-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ecd57941dd5e97a255967aad948297434bbe3255730360473c9a9f5ee9dfe18e
MD5 710a62bb2256136864eb0e19e791a0f6
BLAKE2b-256 a4fb93d13263d789919bfd419b6ccc7490470e5a84c12b52f8103658883f012a

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextrot-1.0.0.tar.gz:

Publisher: release.yml on Priyanshu-byte-coder/contextrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file contextrot-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: contextrot-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 83.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for contextrot-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2cd52633d36e7306df41fa35cf9d5dd79e3ee388617af471c875225919b92189
MD5 193cb27101d0626a31da048008ab7c98
BLAKE2b-256 11e54f48b23d053b268536684e53ddd5ae820a1d8da3b87830e953319d311b00

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextrot-1.0.0-py3-none-any.whl:

Publisher: release.yml on Priyanshu-byte-coder/contextrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page