agentleFS
hishamkaramhishamkaram/claude-code-router/AGENTS.md

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.

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
  1. Very specific:

    Before non-trivial implementation or review, read the matching files under agents/ and agents/_data/.

    line 19
  2. Distinctive:

    Prefer concrete types until a real boundary requires an interface.

    line 46
  3. Distinctive:

    No package-level mutable state except sentinel errors.

    line 47
  4. Distinctive:

    Use constructor injection for dependencies.

    line 49
  5. Distinctive:

    Every goroutine must have an owner, cancellation path, and wait/cleanup path.

    line 51
  6. Distinctive:

    Never log and return the same error.

    line 53
  7. Distinctive:

    Use structured logs when logging is introduced.

    line 54
  8. Distinctive:

    Run the affected subset first, then the full local gate before claiming done:

    line 59
  9. Distinctive:

    If live Claude Code is unavailable, mark the feature unverified instead of done.

    line 75

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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.md
  • agents/_data/engineering-quality-gate.md
  • agents/_data/maintainability-quality-gate.md
  • agents/_data/code-quality-floor.md
  • agents/_data/router-product-invariants.md
  • agents/_data/cli-contract.md
  • agents/_data/secret-storage-contract.md
  • agents/_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.Context through 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.