Save tokens with Claude Code, Codex, and other agents.
An open-source CLI that compacts command output to reduce token usage and routes subagents within your model policy. Support and available models vary by harness and session.
Product status: beta. See the beta exit criteria and known limitations.
- 67%fewer command-output bytes in a benchmark of 110 fixtures with CCR enabled. Bytes, not billed tokens.
- Your policyDownshift routes in deterministic code without an extra LLM call. Your orchestrator may still use an LLM.
- InspectExplore routing and compaction information. Observability varies by harness.
Less output. Thoughtful routing. More visibility.
Compactor
Keep the useful output
Supported commands can be compacted while preserving the exit status. The direct wrapper refuses commands outside its allowlist; run those directly. See supported commands.
$ go test ./...ok internal/agentsok internal/routing↓ compactPASS · packages successfulSynthetic example; output and reduction vary by command. Subagent model routing
Apply your model policy
Downshift applies subagent model choices through deterministic code. Available models and supported hooks depend on the harness and session.
Agent delegates a task↓Policy + available models↓Model choice for the subagentConceptual flow; the orchestrator chooses whether to delegate. Observability
See what happened
Inspect routing, compaction savings, main-session mechanical work, and relative quota estimates per harness.

Illustration, not a product screenshot.
What's new in v0.29.7
Failed go test runs are shorter, and the full report is downshift report. Head to head on 50 commands: 98.7% cut and every failure line kept, against 6.6% for rtk.
- A failed go test keeps every failure line and drops the passed-test count: go test -v with one failure goes from 161 to 131 bytes, under tokf's 137.
- The full report is downshift report in a terminal; /ds-agents report and the pane's Full report button are gone, and Details keeps each agent's models, tools and tokens.
- From v0.29.6: a repo-wide find folds by directory, a plain diff a b is compacted, and a big log over curl folds repeated lines.
Who it is for
Downshift helps when verbose outputs cause context rot or when your agent delegates work while protecting your main prompt cache and frontier quota.
Your agent delegates
Keep frontier models for architecture and tricky debugging while routine searches and checks run on lighter tiers within your policy. Claude Code is complete, Codex is functional, OpenCode is beta, and Cursor is experimental.
You pay per token
Compact noisy builds,
WebFetch/MCP, and large reads before context bloat compounds every turn, recover raw traces for 24 h viadownshift retrieve <id>, and spot un-delegated main-session mechanical work indownshift report.You are on a plan (Pro, Max, Team)
There is no per-token bill.
downshift stats,report, and the session pane show lower-tier tokens, relative quota-unit estimates (assuming equal tokens, per harness), and 30-dayponytailadoption while plan-limit impact is still being measured.
Not for: picking your main model, deciding whether to delegate, or printing billing invoices.
Where a coding agent spends more than it needs to.
Downshift addresses both with a single Go binary and no daemon.
Subagents inherit oversized models and effort
A mechanical file search or test run often inherits the same frontier model and high reasoning effort meant for architectural design.
Fix
A local hook scores the task and rightsizes model tier and reasoning effort only when confident. In doubt, your model stays and your main session's prompt cache stays intact.
Status
Completed on Claude Code
Noisy command output causes context rot
Thousands of repetitive passing test lines or clean status dumps don't just waste tokens — they dilute the context window, degrading the agent's recall of earlier system rules and constraints.
Fix
downshift compactshortens clean noise (67.1% corpus cut with CCR; plusWebFetch/mcp__*> 4 KB andRead> 64 KB post-run on Claude Code), keeping failures, exit codes, and 24 h raw recovery viadownshift retrieve <id>.Status
Implemented, on by default
Completed: seen working end to end. Implemented: code, tests and at least one real observation. Reports show tokens and coverage, not dollars.
- 1
Model choices for subagents
Completed on Claude CodeRewrites only the subagent's model, never your main session.
QualifierOne small KiroCrew experiment measured about 53% fewer tokens per completed task with routing and compactor combined (2026-10-21; six control tasks). This is directional.
- 2
Compactor
On by defaultWraps
git,go testand the other test and build tools listed in the docs; keeps the exit code.QualifierSupported shell forms and automatic wrapping vary by harness. Recognized Git commands include
git status,git log,git diffandgit show; output handling depends on the command.
Several harnesses, honest levels
Setup can configure supported harness integrations; available capabilities vary.
QualifierCodex is functional, OpenCode is beta, and Cursor is experimental.
Guardrails Implemented
Set model floors for tasks that need a more conservative policy.
QualifierYour project defines the policy; sensitive tasks do not have a universal automatic floor.
See and compare Implemented
Switched, held or only observed, with the reason, plus compaction savings per harness.
QualifierChild token usage is available on supported harnesses; the report flags a routing verdict at 20 completed tasks.
See Downshift in action.
See three Claude Code programming scenarios: subagent routing, file operations, and compacted test output.
The routing scenario shows simple and complex tasks evaluated against the session policy. Scenarios rotate automatically every ten seconds.
Rewritten
Stays on frontier
Original model kept
- Task
- rename the userId variable to accountId
- Tier
- small
- mid
- frontier
- Model move
- opus → haiku
- Price gap
- ~75%, price gap of one model swap (est., list price), not a session saving
- Outcome
- Rewritten
- Why
- trivial task, no risk, confident
Guardrail
not rewritten: held by a guardrail
In this historical example, the classifier held the original model. Current routing decisions may differ.
These historical examples do not predict current routing decisions.
Less output in your context.
Passing tests and clean builds can reach your agent as a shorter summary. The exit status is preserved; displayed details depend on the command.
Compactor is on by default. It runs routine commands through downshift compact, which keeps the exit code and shortens recognized output according to the command family. It wraps every git subcommand and the listed test and build tools (go, pytest, vitest, jest, tsc, cargo, playwright, cypress, phpunit, gradle, maven, flutter, dart, next build). Recognized Git commands include git status, git log, git diff and git show; results depend on the command and its output. Desktop reads count too: agent-desktop snapshot and find print an accessibility tree as JSON, which Compactor re-encodes one line per element with every field kept. A repeat read of the same window comes back as only the lines that changed.
Shell integration varies by harness. Your agent can also run downshift compact -- <command> directly. This is not the /compact command: it never summarises your conversation.
Across the benchmark corpus, output was 53.0% smaller without CCR and 67.1% smaller with Command Context Recovery (CCR, enabled by default). Clean outputs and lossless test runners had 60.3% fewer bytes, with best cases reaching 90%–95% fewer bytes (cargo test 93%, flutter test 92%, npm install 89%, pytest 87%, cypress 83%, playwright 82%, turbo 80%, tsc 78%, next build 77%, vitest 74%). Bytes, not tokens, and not your command mix.
Command Context Recovery (CCR) is on by default: the raw command output is saved locally (files 0600) for 24 hours, when eligible, so you or your agent can inspect stored output with downshift retrieve <id>. Some secret-like lines are withheld from the store, but arbitrary secret formats may remain. Turn Compactor off with "exec": false in the config or DOWNSHIFT_EXEC=0.
Before and after, real runs
| Run | Before | After | Cut |
|---|---|---|---|
| Full suite | 4,466 | 2,331 | −47.8% |
| Package 1 | 752 | 317 | −57.8% |
| Package 2 | 619 | 238 | −61.5% |
| Package 3 | 471 | 174 | −63.1% |
| Package 4 | 278 | 142 | −48.9% |
Single runs, 2026-10-21, bytes.
How a spawn gets its model.
Eight steps, all code in the repository. Your agent spawns a subagent; a local hook scores the task; guardrails check it; the hook rewrites the model or leaves it alone; telemetry records counts and timings.
Harness
The agent spawns a subagent
Agent / TaskThe main agent delegates through its spawn tool: Agent or Task, spawn_agent, invoke_subagent. Downshift sees nothing until the harness fires its pre-tool hook.
Downshift
The hook starts
runHookAdapterrunHookAdapter reads the payload from stdin, capped at 1 MiB with a 2 s read timeout, sets a 1.5 s budget, and turns any panic into an unchanged spawn.
Downshift
The adapter reads the payload
internal/adaptersThe harness adapter reads available task, model and session information. It declares what the harness can do and holds no policy.
Downshift
The task is classified
internal/classifyWeighted signals in English and Portuguese give TRIVIAL, SIMPLE, MEDIUM or COMPLEX, which maps to a tier: small, mid or frontier. A prompt with no signal defaults to mid and abstains.
Downshift
The semantic step can only raise
internal/fuseAn in-process word-hash step may lift a hesitant class. It never lowers a tier, never boosts a prompt with no signal and never creates COMPLEX on its own.
Downshift
Floors and guardrails check
selfcheck.go R1-R9Guardrails R1 to R9 and the project floor in .downshift/policy.json run next. The session model list and the quota gate decide what can be written. Any hit means: keep the model.
Downshift
Rewrite or hold
updatedInputWhen supported and eligible, the hook can return a model change and reasoning effort where the harness accepts it. Otherwise the spawn continues as requested.
Harness, then Downshift
The subagent runs and is recorded
events.jsonlThe harness runs the child on the written model, or ignores the rewrite, which Downshift cannot control. Downshift then appends counts, hashes, timings and, on Claude Code, token counts to events.jsonl. No prompt text.
Boundaries and limits
- No extra model call by Downshift routing code.
- Routing telemetry does not store prompt text; CCR may store eligible command output locally.
- No rewrite when unsure.
- No universal automatic floor for sensitive tasks: configure an appropriate policy.
- No blocked spawn because of an error: a bad payload, panic or timeout leaves the spawn unchanged.
Eight layers, each with its status.
Status is what the repository shows today, not what is planned. Implemented does not mean validated on every harness.
Right model, less noise
ClassificationScores the task text into TRIVIAL, SIMPLE, MEDIUM or COMPLEX, with no LLM call.Implemented
- internal/classify: weighted signals in English and Portuguese
- language guard
- internal/fuse: hash semantic boost, raise-only
On blind test sets, tier accuracy is 40 to 53%, and most misses are abstentions that keep your model.
Model catalog and sessionKnows which models exist in your session, their tier and whether one is explicit-only.Implemented
- internal/catalog: tiers, aliases, explicit_only
- session models from hook lists, session-models.json, discovery, or inferred from the current model on Claude Code
Routing hook per harnessRouting integrations use harness-specific capabilities and formats; application varies by harness.Implemented
- one shared runner, runHookAdapter
- adapters: claudecode, cursor, codex, opencode, antigravity, kirocrew
Claude Code is completed, Codex is functional, OpenCode is beta, and Cursor, Antigravity and KiroCrew are experimental.
Shell output compaction (downshift compact)git and the listed test and build tools. Keeps the exit code and compacts only what is unambiguously clean.On by default
- shell exec wrapper; automatic rewrite varies by harness
- CCR (Command Context Recovery) on by default: raw output kept 24 hours, read back with downshift retrieve <id>
- "exec": false or DOWNSHIFT_EXEC=0 turns it off
- downshift context compress, for pipes
Stay in control
GuardrailsHolds any change the evidence does not support and keeps the model you asked for.Implemented
- R1 to R9 (R3 retired) in selfcheck.go
- Model floors configurable in the project policy
- project tier floor in .downshift/policy.json, which only raises
- quota and credit gate
The quota gate is implemented but not validated on every harness.
Rules it always follows
- Local classification. Downshift scores tasks locally using signals and a model catalog, without an extra LLM call for routing. Routing telemetry does not store prompt text.
- Fail-open. Any error or missing capability leaves the spawn untouched. Downshift only changes the model and effort fields.
- Doubt keeps your model. Unsure? The spawn keeps the model it asked for. A cheaper choice without enough confidence is held.
- Project policy. Set model floors for tasks that need more capable models; there is no universal automatic floor by subject.
Telemetry and reportsRecords what happened and reports compaction savings per harness and tokens per completed task.Implemented
- events.jsonl: counts, hashes, timings
- downshift stats, session and watch: switched, held or observed per spawn
- downshift report: compaction savings per harness, then tokens per completed task
Two controlled runs so far, both on mechanical tasks (2026-10-15 and 2026-10-21). The control arm those runs used was removed from the product on 2026-11-02. Child token usage availability varies by harness. stats and report print no dollar amounts.
Mods in Claude CodeMake the work visible: a progress bar with each subagent's Downshift state, a panel of subagents, a file tree and a dock to reopen them.Implemented
- savvy-progress
- filetree
- downshift-dock
- downshift-theme, optional
savvy-progress and filetree are vendored third-party mods; downshift-dock is original and tested only against a mock engine. None holds routing logic. setup installs them, but not the theme.
Measurements and their limits.
These small KiroCrew and Claude Code experiments ran on 2026-10-21, before O8. Their results do not predict your usage.
- ~53%fewer tokens per completed task in one directional experiment, routing and compactor combinedKiroCrew harness2026-10-216 control tasksOne session and six control tasks: treat the result as directional.
- ~24%fewer tokens per accepted run, routing only, historical pre-O8 four-arm trialClaude Code46 runsone operator2026-10-2116% per run; 95% interval +2.1% to +46.7%. Routing only; this does not establish an additional Compactor saving. State isolation bugs found in battery — number may change. Acceptance: 12 of 12 in each routed arm: C (routing) and D (routing + Compactor).
- 67.1%fewer bytes across corpus with CCR (53.0% without CCR)60.3% lossless runnersbest cases 90%–95%24 h retrievalCommand Context Recovery is on by default; downshift retrieve <id> can recover eligible stored output.
Tokens per accepted run, four arms
- A Opus fixed2.25M10 of 11 accepted
- B opusplan2.00M10 of 11 accepted, no routing
- C opusplan + routing1.52M12 of 12 accepted
- D routing + Compactor1.46M12 of 12 accepted
Tokens = input + output + cache read + cache write, all models. Bar length relative to arm A.
Fewer tokens per accepted run, arm against arm
- Routing (B−C)24.1%interval +2.1% to +46.7%. Per run, before charging failures: 16.5%, +0.6% to +29.7%. Includes the cost of one failed run in the opusplan arm (named constants, 2 of 3 accepted).
- Routing + Compactor (B−D)26.8%interval +4.4% to +48.3%
- Compactor alone (C−D)3.5%interval −14.8% to +19.4%, includes zero: not measurable in this part. The agents chained commands with “;”, which Compactor did not wrap until PR #424 (merged 2026-10-21).
- Opus fixed against everything on (A−D)34.8%interval +19.1% to +52.5%
- opusplan alone (A−B)11.0%interval −28.9% to +39.0%, includes zero
solid: interval excludes zero. hatched: interval includes zero.
Earlier trial (2026-10-15, list price)
Up to about 12% cheaper per run on the mechanical batch. One trial, one operator, three runs per cell, list price, Claude Code, 2026-10-15. 12 of 12 checks passed in both arms; checks verify structure, not quality.
Saving per task, routed against control
- Rename~33%all five subagents downshifted
- Named constants~14%
- Doc comments~10%the interval includes zero
- Mirrored testsnoisenothing downshifted in 2 of 3 runs
solid: saving. hatched: interval includes zero, or noise.
List-price estimate. Bar length is relative to the largest saving.
What we have not shown
- A saving on your plan limit. Still being measured.
- Any saving from everyday use. Two controlled runs on mechanical tasks so far; nothing attributable.
- Compactor's own effect on tokens in a run. Not measurable in part 1.
- Routing on natural fixes that run tests. That is part 2.
- Compaction on your own commands. The 67.1% (53.0% without CCR) is from the benchmark corpus, in bytes.
- That the model is honored in every harness. See the table below.
- A false-positive rate for risk detection on real traffic.
Part 1 of 2: mechanical tasks. Part 2 (natural fixes that run tests) is next.
Read the four-arm write-upRead the A/B reportSee the benchmark results
Supported harnesses and their status.
The levels are what was observed, not what is planned. A rewrite emitted proves the hook answered; only the last column says whether the subagent ran on that model.
What each harness does with the rewrite
| Harness | Level | Model rewrite | Subagent used the model | Compactor |
|---|---|---|---|---|
| Claude Code | Completed | Emitted | Observed, 2026-10-06 | Automatic rewrite; or run downshift compact -- <command> |
| Codex | Functional | Emitted | Inferred from the next spawn, not observed | Run the command directly |
| Cursor | Experimental | Emitted | Unconfirmed (P1.6); child end verified 2026-10-24 (Cursor 3.27.12) | Agent runs downshift compact; setup adds Shell hooks (unverified live) |
| OpenCode | Beta | Automatic, through the bridge plugin that downshift setup opencode installs | Observed, OpenCode 2.2.5; retry fallback not verified | Automatic rewrite through the bridge plugin |
| Antigravity | Experimental | PreToolUse hook & MCP server integration | One child observed on Antigravity desktop 2.21.1 | Run directly or via agent wrapper |
| KiroCrew | Experimental | Block and retry (policy mode); no in-place rewrite | Not recorded (block and retry path) | Run downshift compact -- <command> |
Compactor works in KiroCrew by calling the command directly (steering): 223 calls recorded on 2026-10-21. Compactor can also be invoked directly from a shell where Downshift is installed. Automatic shell rewriting varies by harness; the OpenCode bridge also supports it. Model routing has been observed on Claude Code, OpenCode and Antigravity with different evidence and limits; see the matrix for current compatibility.
hook PreToolUse rewrite updatedInput.model keeps every sibling field doubt original model kept
hook PreToolUse rewrite model, reasoning effort keeps every sibling field doubt original model kept
hook preToolUse rewrite updated_input.model keeps every sibling field doubt original model kept
PreToolUse on Agent and Task rewrites updatedInput.model. Rewrite observed on 2026-10-06.
PreToolUse on spawn_agent rewrites model and reasoning effort. Honor inferred, not observed.
preToolUse on Task rewrites updated_input.model; cursor-touch warms composer baseline when model fields are empty. Honor unconfirmed; child end verified on 3.27.12.
Install, preview, then write.
Setup shows the diff for every harness it finds before it writes anything, saves a timestamped backup, and --undo restores it.
curl -fsSL https://raw.githubusercontent.com/tiagovilasboas/downshift-ai/main/install.sh | shDownload the binary for your platform.
downshift setup --dry-runPrint the diff. Writes nothing.
downshift setup --yesWrite the hooks, with a backup. (Run
downshift setupto be asked first.)downshift doctorCheck the binary, the hooks, state and scores.
downshift setup --undoRestore the latest backup.
Binaries for macOS and Linux (amd64, arm64) and Windows (amd64). On Claude Code, setup also sets the main session to opusplan and plan mode, unless you pass --no-session-policy. It shows a diff first.
Open source, Apache-2.0.
Built in the open by Tiago Vilas Boas. Report unexpected routing decisions with relevant details, excluding sensitive information.
Sponsorship funds maintenance, benchmarks and the model catalog.
SponsorFrequently asked questions
Is Compactor the same as /compact?
No. /compact summarises your conversation. Compactor shortens recognized output from commands such as go test and git status while preserving the exit status. With Command Context Recovery (CCR, on by default), the raw output is kept locally for 24 hours, when eligible, so downshift retrieve <id> can recover the stored output.
Does it help with computer use on the desktop?
If your agent drives desktop apps with agent-desktop, which reads the accessibility tree instead of taking screenshots, Compactor shortens each snapshot and find read and keeps every field. In every harness (automatic in Claude Code, through downshift compact elsewhere), a repeat read of the same window within 10 minutes is sent as the lines that changed, and the full read stays one downshift retrieve away. On synthetic fixtures a first read had 53–60% fewer bytes and a repeat read after one action about 97% fewer; it has not been measured on a live desktop yet. How it works.
Does Compactor lose any output? What is CCR?
Output it does not recognise passes through unchanged; failure details depend on the command. Clean output is shortened, and Command Context Recovery (CCR, on by default) keeps the raw output locally (files 0600) for 24 hours, so you or your agent can read it back with downshift retrieve <id>. Some secret-like lines are withheld, but secrets in other formats may remain. Entries over 8 MiB are not stored. Set DOWNSHIFT_CCR=0 to turn storage off.
Does it save my plan limit?
Subscription plan windows are shared across requests and still under measurement. In daily use, Downshift helps by trimming verbose command and tool outputs (recoverable for 24 h via downshift retrieve <id>), routing confident mechanical subagents to lighter tiers without invalidating your main prompt cache, and reporting relative quota-unit estimates (assuming equal tokens) plus main-session mechanical work in downshift report.
What is sent anywhere?
Routing telemetry stores counts, hashes and timings locally, not prompts. CCR can store eligible command output locally. Routing makes no network call. Your harness still sends the subagent's work to your model provider, as before. A detached refresh of public model scores sends no prompt and can be turned off with DOWNSHIFT_SCORES=off.
Will it route to the wrong model?
In doubt your model stays: an unknown model or an unconfident decision leaves the spawn unchanged, and Downshift never moves a spawn above the model it asked for on its own. There is no universal automatic floor for sensitive tasks; configure a policy for your project. A tier the orchestrator or your policy asks for is applied as given, so declare a floor in .downshift/policy.json for a project that must never run small. Run downshift session --why to see any decision, and report a misroute as an issue.
How do I undo it?
downshift setup --undo restores the latest backup of your harness config. Pause one session with downshift session --pause.
Which coding agents does it support?
Claude Code is completed. Codex is functional, OpenCode is beta, and Cursor, Antigravity and KiroCrew are experimental. The table above shows what was observed for each.
What happened to DCI?
Code intelligence (DCI) was removed. It was off by default and no measurement showed it lowered cost. The commands, the hook and the report section are gone.
Where is the dashboard?
The web dashboard was removed on 2026-10-20. Use downshift report, downshift stats and downshift session, which show tokens and coverage in the terminal.
Does it call an AI to pick a model? Do I need another key?
No to both. Routing is local, from scored signals and a model catalog, with no extra model call and no key.
How much does it save?
In one directional KiroCrew experiment with routing and compactor combined, about 53% fewer tokens per completed task (KiroCrew harness, 2026-10-21, 6 control tasks — directional, not definitive). In a historical pre-O8 four-arm Claude Code trial, routing alone used about 24% fewer tokens per accepted run (46 runs, one operator, 2026-10-21; 16% per run, interval +2.1% to +46.7%). In the benchmark, output was 53.0% smaller without CCR and 67.1% smaller with CCR enabled by default (60.3% on lossless test runners, up to 90%–95% in best cases like cargo test 93% and flutter test 92%). These results do not establish universal additional savings. Estimates are not invoices.
Is Downshift related to the React downshift library?
No. The React downshift library builds accessible autocomplete and dropdown components. This project is an unrelated Go tool that routes AI coding agent subagents to right-sized models.
Is it free?
Yes. Apache-2.0, a single Go binary, no daemon.
What changes on my machine?
Setup merges hooks into your harness config files, such as Claude Code's settings.json, and saves a timestamped backup first. A project can add an optional .downshift/policy.json tier floor. Nothing runs as a daemon.
Does it slow down a subagent spawn?
It adds one local process call, with no network and no LLM. In one traced run the binary exited in 30 ms. The hard limits are 2 s to read the payload and 1.5 s of hook budget, and an overrun or error leaves the spawn unchanged. On Claude Code it may also wait up to 400 ms for the parent transcript, to learn the current model. That is one trace, not a benchmark.