claude-code-router
AGENTS.md12 starsChanged 16 days agoMITView on GitHub
This private repo builds ccr, a local Go gateway and CLI for same-session Claude Code model routing. Before non-trivial implementation or review, read the matching files under agents/ and agents/_data/. Core contracts: Role guidance: Run the affected subset first, then the full local gate before claiming done: For router behavior that touches Claude Code runtime semantics, also run: If live Claude Code is unavailable, mark the feature unverified instead of done.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository11 other files it gives its agents.
- cli-uxSkill
- docs-updaterSkill
- go-concurrencySkill
- go-implementerSkill
- go-reviewerSkill
- go-test-writerSkill
- live-e2eSkill
- releaseSkill
- researchSkill
- router-architectSkill
- security-auditorSkill
The file
We split this AGENTS.md into the rules it gives an agent
9 rules. About 0 are common, 8 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
Before non-trivial implementation or review, read the matching files under agents/ and agents/_data/.
- Distinctive: line 46
Prefer concrete types until a real boundary requires an interface.
- Distinctive: line 47
No package-level mutable state except sentinel errors.
- Distinctive: line 49
Use constructor injection for dependencies.
- Distinctive: line 51
Every goroutine must have an owner, cancellation path, and wait/cleanup path.
- Distinctive: line 53
Never log and return the same error.
- Distinctive: line 54
Use structured logs when logging is introduced.
- Distinctive: line 59
Run the affected subset first, then the full local gate before claiming done:
- Distinctive: line 75
If live Claude Code is unavailable, mark the feature unverified instead of done.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Claude Code Router Agent Instructions
This private repo builds ccr, a local Go gateway and CLI for same-session
Claude Code model routing.
Product Invariants
- Claude Code launches once through one fixed local gateway.
/model <alias>must route future requests in that Claude Code session to the selected alias.- New subagents, workflow agents, and teammates should use the active model where safely possible.
- Compatibility policy is maximum safe degradation, not all-or-nothing conformance.
- Degradation must be visible; silent fallback to Claude is forbidden.
- Provider secrets must never be logged, printed, committed, or stored raw in SQLite.
- Significant router behavior is not done until a live Claude Code E2E test proves it.
- CLI commands are product surface: validate args strictly and explain behavior clearly.
Required Guidance
Before non-trivial implementation or review, read the matching files under
agents/ and agents/_data/.
Core contracts:
agents/_data/ai-agent-quality-contract.mdagents/_data/engineering-quality-gate.mdagents/_data/maintainability-quality-gate.mdagents/_data/code-quality-floor.mdagents/_data/router-product-invariants.mdagents/_data/cli-contract.mdagents/_data/secret-storage-contract.mdagents/_data/live-e2e-contract.md
Role guidance:
- Architecture/protocol boundaries:
agents/architect.md - Go implementation:
agents/go-implementer.md - Go review:
agents/go-reviewer.md - Concurrency/streaming/session lifecycle:
agents/go-concurrency.md - Tests/live harness:
agents/go-test-writer.md - Secret/auth/security:
agents/security-auditor.md - User docs/help output:
agents/docs-updater.md - External provider research:
agents/researcher.md
Go Rules
- Prefer concrete types until a real boundary requires an interface.
- No package-level mutable state except sentinel errors.
- No
init()for runtime wiring. - Use constructor injection for dependencies.
- Pass
context.Contextthrough request, gateway, provider, and subprocess paths. - Every goroutine must have an owner, cancellation path, and wait/cleanup path.
- Wrap errors with operation context and
%w. - Never log and return the same error.
- Use structured logs when logging is introduced.
- Tests must cover validation, error paths, and persistence behavior.
Verification
Run the affected subset first, then the full local gate before claiming done:
go test ./...
go test -race -count=1 -p 4 ./...
go vet ./...
golangci-lint run ./...
govulncheck ./...For router behavior that touches Claude Code runtime semantics, also run:
go test -tags=live -count=1 -p 1 ./...If live Claude Code is unavailable, mark the feature unverified instead of done.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

