Repository navigation
chore(claude): cut Claude Code token spend and check the LSP servers at session start - #622
Merged
Merged
Conversation
…at session start A measured pass over seven weeks of local Claude Code transcripts (143,618 requests) showed where the tokens go: long-lived agents with 150 or more turns were 47% of spend, subagent caches expired while agents waited, and file reads filled most of the context. This change acts on those findings: - Compact at 400,000 tokens (CLAUDE_CODE_AUTO_COMPACT_WINDOW) in the main session and every subagent, and give each pull request or issue its own fresh agent through a new saved `implementer` agent. - Keep the implementer's prompt cache for one hour, since it waits on builds and CI; other subagents keep five minutes. - Run docs-cold-reader on Sonnet and route prose passes there. - Enable the rust-analyzer and pyright LSP plugins, add a SessionStart hook that warns when either language server is missing, broken, or off the pyright pin, and tell agents to find code by symbol and read line ranges. - Move the delivery-loop rules, the Mechanism 7 list of places where a value reaches the browser, and the changelog rules out of CLAUDE.md into docs/agent/delivery-loop.md, docs/security/where-values-reach-the-browser.md and docs/best-practices/writing-docs.md, with pointers that say when to read them (CLAUDE.md 59 KB -> 50 KB). - Brief only Explore, Plan and Workflow agents to read CLAUDE.md; other agents already load it at start. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Cuts what Claude Code spends on this repository, based on a measured pass over seven weeks of local transcripts (143,618 model requests, priced at Anthropic list prices; about $12,100). Each change below acts on one measured cost.
CLAUDE_CODE_AUTO_COMPACT_WINDOWin.claude/settings.json, applies to subagents too), and one fresh agent per pull request through the new savedimplementeragentimplementerkeeps its prompt cache for 1 hour (experimental.cacheTtl)docs-cold-readeron Sonnet; prose passes and cold reads routed to Sonnetdocs/agent/delivery-loop.md,docs/security/where-values-reach-the-browser.md, anddocs/best-practices/writing-docs.md, with pointers that say when to read eachThe method and findings are recorded in
docs/agent/RATIONALE.md("Token cost of long-running agents"), and the setup indocs/codebase.md("Setting up Claude Code").The LSP servers now fail loudly
The rust-analyzer plugin was already installed on the maintainer's machine, but the language server it starts was missing, so the
LSPtool never worked and nobody noticed. A new SessionStart hook,.claude/hooks/check-lsp-servers.py, checks both servers when a session starts. When one is missing, does not start, or (for pyright) differs from thepackage.jsonpin, it shows the user a warning with the fixing command and tells Claude that theLSPtool will fail for that language. It is silent when both work and takes about 0.1 s.Contributors install the two servers once (
docs/codebase.mdhas the commands). I keptrust-analyzerout ofrust-toolchain.tomlcomponents on purpose: that would add a download to every Rust CI job for a tool only local agents use.Other edits
docs-cold-readerand the fable-mode skill follow suit.docs/codebase.md, andRATIONALE.md.Review
.cmdshims, no rustup toolchain download during session start, the pyright next to the language server, range pins, and running withoutCLAUDE_PROJECT_DIR.claude -psession delivered the warning and the added context.compile_templatethrough theLSPtool.scripts/validate.pypasses.compact_boundarywithpreTokensnear 400,000 in a new subagent transcript.Checklist
python scripts/check.pypasses locally. No automated test for the hook:.claude/hooks/has no test harness and runs only on contributors' machines, so I verified it by hand in the cases above. The change touches no product code. I ranscripts/validate.py, not the full gate.CHANGELOG.mdupdated if the change is user-facing. Not user-facing.🤖 Generated with Claude Code