claude-code-router 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- claude_code_router-0.1.1/.claude/agents/Explore.md +14 -0
- claude_code_router-0.1.1/.claude/agents/ccr-architect.md +16 -0
- claude_code_router-0.1.1/.claude/agents/ccr-critical.md +16 -0
- claude_code_router-0.1.1/.claude/agents/ccr-implement.md +19 -0
- claude_code_router-0.1.1/.claude/agents/ccr-quick.md +16 -0
- claude_code_router-0.1.1/.claude/agents/ccr-small.md +18 -0
- claude_code_router-0.1.1/.claude/settings.json +54 -0
- claude_code_router-0.1.1/.gitattributes +2 -0
- claude_code_router-0.1.1/.github/ISSUE_TEMPLATE/bug_report.md +18 -0
- claude_code_router-0.1.1/.github/ISSUE_TEMPLATE/feature_request.md +11 -0
- claude_code_router-0.1.1/.github/pull_request_template.md +7 -0
- claude_code_router-0.1.1/.github/workflows/ci.yml +29 -0
- claude_code_router-0.1.1/.github/workflows/publish.yml +33 -0
- claude_code_router-0.1.1/.gitignore +17 -0
- claude_code_router-0.1.1/CHANGELOG.md +22 -0
- claude_code_router-0.1.1/CONTRIBUTING.md +33 -0
- claude_code_router-0.1.1/LICENSE +21 -0
- claude_code_router-0.1.1/PKG-INFO +291 -0
- claude_code_router-0.1.1/README.md +264 -0
- claude_code_router-0.1.1/ccr/__init__.py +0 -0
- claude_code_router-0.1.1/ccr/__main__.py +4 -0
- claude_code_router-0.1.1/ccr/cli.py +595 -0
- claude_code_router-0.1.1/ccr/config.py +518 -0
- claude_code_router-0.1.1/ccr/detect/__init__.py +123 -0
- claude_code_router-0.1.1/ccr/doctor.py +208 -0
- claude_code_router-0.1.1/ccr/entry.py +23 -0
- claude_code_router-0.1.1/ccr/evaluate/__init__.py +13 -0
- claude_code_router-0.1.1/ccr/evaluate/classify.py +335 -0
- claude_code_router-0.1.1/ccr/evaluate/llm.py +182 -0
- claude_code_router-0.1.1/ccr/evaluate/locate.py +359 -0
- claude_code_router-0.1.1/ccr/evaluate/risk.py +285 -0
- claude_code_router-0.1.1/ccr/evaluate/text.py +190 -0
- claude_code_router-0.1.1/ccr/graph/__init__.py +15 -0
- claude_code_router-0.1.1/ccr/graph/build.py +475 -0
- claude_code_router-0.1.1/ccr/graph/db.py +88 -0
- claude_code_router-0.1.1/ccr/graph/files.py +169 -0
- claude_code_router-0.1.1/ccr/graph/git.py +90 -0
- claude_code_router-0.1.1/ccr/graph/parse.py +510 -0
- claude_code_router-0.1.1/ccr/graph/query.py +359 -0
- claude_code_router-0.1.1/ccr/graph/resolve.py +256 -0
- claude_code_router-0.1.1/ccr/headless.py +363 -0
- claude_code_router-0.1.1/ccr/history/__init__.py +172 -0
- claude_code_router-0.1.1/ccr/history/calibrate.py +161 -0
- claude_code_router-0.1.1/ccr/history/dashboard.py +374 -0
- claude_code_router-0.1.1/ccr/history/feedback.py +91 -0
- claude_code_router-0.1.1/ccr/history/learn.py +184 -0
- claude_code_router-0.1.1/ccr/history/prompts.py +120 -0
- claude_code_router-0.1.1/ccr/history/redact.py +45 -0
- claude_code_router-0.1.1/ccr/history/savings.py +187 -0
- claude_code_router-0.1.1/ccr/history/shadow.py +114 -0
- claude_code_router-0.1.1/ccr/history/stats.py +172 -0
- claude_code_router-0.1.1/ccr/history/tune.py +80 -0
- claude_code_router-0.1.1/ccr/history/why.py +186 -0
- claude_code_router-0.1.1/ccr/hooks/__init__.py +134 -0
- claude_code_router-0.1.1/ccr/hooks/bg.py +68 -0
- claude_code_router-0.1.1/ccr/hooks/common.py +159 -0
- claude_code_router-0.1.1/ccr/hooks/prompt.py +322 -0
- claude_code_router-0.1.1/ccr/hooks/session_start.py +91 -0
- claude_code_router-0.1.1/ccr/hooks/stop.py +52 -0
- claude_code_router-0.1.1/ccr/hooks/tasks.py +170 -0
- claude_code_router-0.1.1/ccr/install/__init__.py +388 -0
- claude_code_router-0.1.1/ccr/install/agents.py +200 -0
- claude_code_router-0.1.1/ccr/install/command.py +159 -0
- claude_code_router-0.1.1/ccr/install/settings.py +175 -0
- claude_code_router-0.1.1/ccr/memory/__init__.py +87 -0
- claude_code_router-0.1.1/ccr/memory/signals.py +210 -0
- claude_code_router-0.1.1/ccr/memory/sources.py +422 -0
- claude_code_router-0.1.1/ccr/report.py +40 -0
- claude_code_router-0.1.1/ccr/route/__init__.py +527 -0
- claude_code_router-0.1.1/ccr/route/budget.py +166 -0
- claude_code_router-0.1.1/ccr/statusline.py +143 -0
- claude_code_router-0.1.1/ccr/transcript.py +98 -0
- claude_code_router-0.1.1/docs/REFERENCE.md +613 -0
- claude_code_router-0.1.1/docs/images/dashboard.png +0 -0
- claude_code_router-0.1.1/docs/images/explain.png +0 -0
- claude_code_router-0.1.1/pyproject.toml +65 -0
- claude_code_router-0.1.1/scripts/bench_graph.py +89 -0
- claude_code_router-0.1.1/scripts/bench_hooks.py +100 -0
- claude_code_router-0.1.1/scripts/bench_routing.py +121 -0
- claude_code_router-0.1.1/tests/conftest.py +55 -0
- claude_code_router-0.1.1/tests/fixtures/graph/go/go.mod +3 -0
- claude_code_router-0.1.1/tests/fixtures/graph/go/internal/store/store.go +14 -0
- claude_code_router-0.1.1/tests/fixtures/graph/go/internal/store/store_test.go +5 -0
- claude_code_router-0.1.1/tests/fixtures/graph/go/main.go +12 -0
- claude_code_router-0.1.1/tests/fixtures/graph/go/util.go +8 -0
- claude_code_router-0.1.1/tests/fixtures/graph/java/src/main/java/com/acme/app/App.java +10 -0
- claude_code_router-0.1.1/tests/fixtures/graph/java/src/main/java/com/acme/app/Helper.java +5 -0
- claude_code_router-0.1.1/tests/fixtures/graph/java/src/main/java/com/acme/util/Strings.java +7 -0
- claude_code_router-0.1.1/tests/fixtures/graph/py/.gitignore +2 -0
- claude_code_router-0.1.1/tests/fixtures/graph/py/app/__init__.py +0 -0
- claude_code_router-0.1.1/tests/fixtures/graph/py/app/core/__init__.py +1 -0
- claude_code_router-0.1.1/tests/fixtures/graph/py/app/core/engine.py +18 -0
- claude_code_router-0.1.1/tests/fixtures/graph/py/app/main.py +8 -0
- claude_code_router-0.1.1/tests/fixtures/graph/py/app/util.py +6 -0
- claude_code_router-0.1.1/tests/fixtures/graph/py/node_modules/dep/index.py +2 -0
- claude_code_router-0.1.1/tests/fixtures/graph/py/poetry.lock +1 -0
- claude_code_router-0.1.1/tests/fixtures/graph/py/tests/test_engine.py +5 -0
- claude_code_router-0.1.1/tests/fixtures/graph/py/tests/test_util.py +2 -0
- claude_code_router-0.1.1/tests/fixtures/graph/rust/Cargo.toml +2 -0
- claude_code_router-0.1.1/tests/fixtures/graph/rust/src/main.rs +6 -0
- claude_code_router-0.1.1/tests/fixtures/graph/rust/src/net/client.rs +3 -0
- claude_code_router-0.1.1/tests/fixtures/graph/rust/src/net/mod.rs +1 -0
- claude_code_router-0.1.1/tests/fixtures/graph/ts/package-lock.json +1 -0
- claude_code_router-0.1.1/tests/fixtures/graph/ts/src/app.min.js +1 -0
- claude_code_router-0.1.1/tests/fixtures/graph/ts/src/app.ts +3 -0
- claude_code_router-0.1.1/tests/fixtures/graph/ts/src/components/Button.tsx +8 -0
- claude_code_router-0.1.1/tests/fixtures/graph/ts/src/format.ts +1 -0
- claude_code_router-0.1.1/tests/fixtures/graph/ts/src/lib/index.ts +1 -0
- claude_code_router-0.1.1/tests/fixtures/graph/ts/src/lib/math.ts +6 -0
- claude_code_router-0.1.1/tests/fixtures/graph/zig/src/main.zig +8 -0
- claude_code_router-0.1.1/tests/fixtures/graph/zig/src/util.zig +9 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/README.md +3 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/__init__.py +0 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/api/__init__.py +0 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/api/handlers.py +24 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/api/pagination.py +8 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/auth/__init__.py +0 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/auth/session.py +11 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/auth/tokens.py +11 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/core/__init__.py +0 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/core/config.py +8 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/core/engine.py +46 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/main.py +12 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/payments/__init__.py +0 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/payments/ledger.py +24 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/payments/stripe_client.py +12 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/reports/__init__.py +0 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/reports/export.py +11 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/utils/__init__.py +0 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/app/utils/strings.py +8 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/migrations/versions/0001_init.py +9 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/migrations/versions/0002_add_email.py +9 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/pyproject.toml +4 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/tests/test_engine.py +5 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/tests/test_pagination.py +5 -0
- claude_code_router-0.1.1/tests/fixtures/route/shop_py/tests/test_strings.py +9 -0
- claude_code_router-0.1.1/tests/fixtures/route/svc_go/.github/workflows/ci.yml +8 -0
- claude_code_router-0.1.1/tests/fixtures/route/svc_go/cmd/server/main.go +14 -0
- claude_code_router-0.1.1/tests/fixtures/route/svc_go/deploy/terraform/main.tf +3 -0
- claude_code_router-0.1.1/tests/fixtures/route/svc_go/go.mod +3 -0
- claude_code_router-0.1.1/tests/fixtures/route/svc_go/internal/auth/jwt.go +19 -0
- claude_code_router-0.1.1/tests/fixtures/route/svc_go/internal/cache/cache.go +41 -0
- claude_code_router-0.1.1/tests/fixtures/route/svc_go/internal/http/router.go +33 -0
- claude_code_router-0.1.1/tests/fixtures/route/svc_go/internal/store/store.go +25 -0
- claude_code_router-0.1.1/tests/fixtures/route/svc_go/internal/store/store_test.go +11 -0
- claude_code_router-0.1.1/tests/fixtures/route/web_ts/package.json +2 -0
- claude_code_router-0.1.1/tests/fixtures/route/web_ts/src/App.tsx +16 -0
- claude_code_router-0.1.1/tests/fixtures/route/web_ts/src/__tests__/format.test.ts +7 -0
- claude_code_router-0.1.1/tests/fixtures/route/web_ts/src/components/Button.tsx +9 -0
- claude_code_router-0.1.1/tests/fixtures/route/web_ts/src/components/Footer.tsx +5 -0
- claude_code_router-0.1.1/tests/fixtures/route/web_ts/src/components/Navbar.tsx +12 -0
- claude_code_router-0.1.1/tests/fixtures/route/web_ts/src/hooks/useAuth.ts +12 -0
- claude_code_router-0.1.1/tests/fixtures/route/web_ts/src/index.tsx +5 -0
- claude_code_router-0.1.1/tests/fixtures/route/web_ts/src/lib/api.ts +9 -0
- claude_code_router-0.1.1/tests/fixtures/route/web_ts/src/lib/format.ts +10 -0
- claude_code_router-0.1.1/tests/fixtures/route/web_ts/src/pages/Checkout.tsx +26 -0
- claude_code_router-0.1.1/tests/fixtures/route/web_ts/src/pages/Home.tsx +8 -0
- claude_code_router-0.1.1/tests/fixtures/run/error_max_budget_usd.json +37 -0
- claude_code_router-0.1.1/tests/fixtures/run/error_max_turns.json +37 -0
- claude_code_router-0.1.1/tests/fixtures/run/success.json +35 -0
- claude_code_router-0.1.1/tests/test_budget.py +176 -0
- claude_code_router-0.1.1/tests/test_calibrate.py +34 -0
- claude_code_router-0.1.1/tests/test_cli.py +61 -0
- claude_code_router-0.1.1/tests/test_config.py +165 -0
- claude_code_router-0.1.1/tests/test_dashboard.py +62 -0
- claude_code_router-0.1.1/tests/test_detect.py +68 -0
- claude_code_router-0.1.1/tests/test_evaluate.py +419 -0
- claude_code_router-0.1.1/tests/test_feedback_loops.py +123 -0
- claude_code_router-0.1.1/tests/test_graph.py +380 -0
- claude_code_router-0.1.1/tests/test_history.py +453 -0
- claude_code_router-0.1.1/tests/test_hooks.py +556 -0
- claude_code_router-0.1.1/tests/test_install.py +364 -0
- claude_code_router-0.1.1/tests/test_memory.py +267 -0
- claude_code_router-0.1.1/tests/test_privacy.py +75 -0
- claude_code_router-0.1.1/tests/test_route_table.py +215 -0
- claude_code_router-0.1.1/tests/test_routing_gaps.py +32 -0
- claude_code_router-0.1.1/tests/test_run.py +353 -0
- claude_code_router-0.1.1/uv.lock +409 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ccr:generated sha256=76d75111554ee79f -- edit freely; `ccr init` leaves edited files alone (--force regenerates)
|
|
3
|
+
name: Explore
|
|
4
|
+
description: "Fast read-only codebase search on haiku: find files, symbols, usages and config, and answer where/how-is-X questions. Say how thorough to be (quick, medium, very thorough). Use proactively for any search needing more than a couple of greps."
|
|
5
|
+
tools: Read, Grep, Glob
|
|
6
|
+
model: haiku
|
|
7
|
+
omitClaudeMd: true
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
You are a read-only search agent. Never modify files.
|
|
11
|
+
|
|
12
|
+
- Start broad with Glob/Grep, then read only the excerpts you need.
|
|
13
|
+
- Match the requested thoroughness; stop once the question is answered.
|
|
14
|
+
- Report conclusions with file:line references, not file dumps.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ccr:generated sha256=4f2c7d8e80e2cba1 -- edit freely; `ccr init` leaves edited files alone (--force regenerates)
|
|
3
|
+
name: ccr-architect
|
|
4
|
+
description: "Senior engineer for design, unclear or intermittent bugs, performance, migrations and security-sensitive work: investigates first, then implements or proposes a plan. Use proactively when ccr routes a task to T3."
|
|
5
|
+
model: opus
|
|
6
|
+
effort: high
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
You handle hard problems: design, unclear root causes, performance, migrations and security-sensitive changes.
|
|
10
|
+
|
|
11
|
+
1. Investigate before concluding: read the code paths involved, form hypotheses and verify them (tests, logs, small experiments).
|
|
12
|
+
2. Weigh the options explicitly and pick one, saying why.
|
|
13
|
+
3. Implement with tests, or return a concrete plan if the caller asked for one.
|
|
14
|
+
4. Call out risks, migrations and rollback steps.
|
|
15
|
+
|
|
16
|
+
Finish with: root cause or decision, what changed, how it was verified, open risks.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ccr:generated sha256=dff7e7c203adb942 -- edit freely; `ccr init` leaves edited files alone (--force regenerates)
|
|
3
|
+
name: ccr-critical
|
|
4
|
+
description: "Most careful worker for critical-path changes: auth, payments, destructive migrations, infra, secrets, or code marked critical in project memory. Use proactively when ccr routes a task to T4."
|
|
5
|
+
model: opus
|
|
6
|
+
effort: xhigh
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
You change critical code (auth, payments, data migrations, infra, secrets). Correctness beats speed.
|
|
10
|
+
|
|
11
|
+
1. Map every caller and data path the change touches before editing.
|
|
12
|
+
2. Prefer the smallest reversible change; keep backwards compatibility unless told otherwise.
|
|
13
|
+
3. Add tests for the failure modes (bad input, partial failure, retries, permissions), not only the happy path.
|
|
14
|
+
4. Never weaken security checks, delete data or rotate secrets without explicit instruction; flag anything irreversible.
|
|
15
|
+
|
|
16
|
+
Finish with: what changed, how it was verified, risks, and rollback steps.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ccr:generated sha256=22f920732a694773 -- edit freely; `ccr init` leaves edited files alone (--force regenerates)
|
|
3
|
+
name: ccr-implement
|
|
4
|
+
description: "Implements features, endpoints, refactors and multi-file changes that follow existing patterns, with tests. Use proactively when ccr routes a task to T2."
|
|
5
|
+
tools: Read, Grep, Glob, Bash, Edit, Write, NotebookEdit, WebFetch
|
|
6
|
+
model: sonnet
|
|
7
|
+
effort: medium
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
You implement features and multi-file changes.
|
|
11
|
+
|
|
12
|
+
1. Find the existing patterns (similar features, helpers, tests) and reuse them.
|
|
13
|
+
2. Plan the change briefly, then implement it end to end.
|
|
14
|
+
3. Add or update tests; run them and the linters the project uses.
|
|
15
|
+
4. Keep the diff focused: no drive-by refactors.
|
|
16
|
+
|
|
17
|
+
If you hit a design decision with real trade-offs, or the change reaches auth/payments/migrations/infra/secrets, stop and report so the caller can escalate.
|
|
18
|
+
|
|
19
|
+
Finish with a short report: what changed (paths), how you verified it, and anything left open.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ccr:generated sha256=2184ee45b613e8bc -- edit freely; `ccr init` leaves edited files alone (--force regenerates)
|
|
3
|
+
name: ccr-quick
|
|
4
|
+
description: "Fast, cheap worker for lookups and trivial edits: where is X defined, what does Y return, rename, typo, one-line or config tweak. Use proactively when ccr routes a task to T0."
|
|
5
|
+
tools: Read, Grep, Glob, Bash, Edit
|
|
6
|
+
model: haiku
|
|
7
|
+
effort: low
|
|
8
|
+
maxTurns: 25
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
You handle quick lookups and trivial edits.
|
|
12
|
+
|
|
13
|
+
- Answer directly and briefly; cite file:line for code facts.
|
|
14
|
+
- Edits: smallest change that does the job; match surrounding style.
|
|
15
|
+
- Do not refactor, reformat or touch unrelated code.
|
|
16
|
+
- If the work turns out bigger or riskier than described (more files, unclear cause, auth/payments/migrations/infra/secrets, or a design decision), stop and report what you found so the caller can hand it to a stronger agent.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ccr:generated sha256=ac08d0d8ff5d41c6 -- edit freely; `ccr init` leaves edited files alone (--force regenerates)
|
|
3
|
+
name: ccr-small
|
|
4
|
+
description: "Small, well-scoped changes: a bug fix with a known cause, a test for one function, a single-file edit that follows existing patterns. Use proactively when ccr routes a task to T1."
|
|
5
|
+
tools: Read, Grep, Glob, Bash, Edit, Write
|
|
6
|
+
model: sonnet
|
|
7
|
+
effort: low
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
You make small, well-scoped code changes.
|
|
11
|
+
|
|
12
|
+
1. Read the relevant code and its tests before editing.
|
|
13
|
+
2. Make the minimal change; follow the file's existing patterns.
|
|
14
|
+
3. Run the closest tests (or a quick check) and fix what you broke.
|
|
15
|
+
|
|
16
|
+
If the work turns out bigger or riskier than described (more files, unclear cause, auth/payments/migrations/infra/secrets, or a design decision), stop and report what you found so the caller can hand it to a stronger agent.
|
|
17
|
+
|
|
18
|
+
Finish with a short report: what changed (paths), how you verified it, and anything left open.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model": "sonnet",
|
|
3
|
+
"effortLevel": "low",
|
|
4
|
+
"hooks": {
|
|
5
|
+
"SessionStart": [
|
|
6
|
+
{
|
|
7
|
+
"hooks": [
|
|
8
|
+
{
|
|
9
|
+
"type": "command",
|
|
10
|
+
"command": "ccr hook session-start",
|
|
11
|
+
"timeout": 5
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"UserPromptSubmit": [
|
|
17
|
+
{
|
|
18
|
+
"hooks": [
|
|
19
|
+
{
|
|
20
|
+
"type": "command",
|
|
21
|
+
"command": "ccr hook prompt",
|
|
22
|
+
"timeout": 5
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"SubagentStop": [
|
|
28
|
+
{
|
|
29
|
+
"hooks": [
|
|
30
|
+
{
|
|
31
|
+
"type": "command",
|
|
32
|
+
"command": "ccr hook stop",
|
|
33
|
+
"timeout": 5
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"Stop": [
|
|
39
|
+
{
|
|
40
|
+
"hooks": [
|
|
41
|
+
{
|
|
42
|
+
"type": "command",
|
|
43
|
+
"command": "ccr hook stop",
|
|
44
|
+
"timeout": 5
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"statusLine": {
|
|
51
|
+
"type": "command",
|
|
52
|
+
"command": "ccr statusline"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Something routed wrongly or a command failed
|
|
4
|
+
labels: bug
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**What happened**
|
|
8
|
+
|
|
9
|
+
**What you expected**
|
|
10
|
+
|
|
11
|
+
**Steps to reproduce**
|
|
12
|
+
Include the prompt (redact anything private) and the output of `ccr explain "<prompt>" --json`.
|
|
13
|
+
|
|
14
|
+
**Environment**
|
|
15
|
+
- ccr version:
|
|
16
|
+
- Python version:
|
|
17
|
+
- OS:
|
|
18
|
+
- Output of `ccr doctor`:
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.12"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
fetch-depth: 0
|
|
19
|
+
- uses: astral-sh/setup-uv@v5
|
|
20
|
+
- name: Install
|
|
21
|
+
run: uv sync --python ${{ matrix.python-version }}
|
|
22
|
+
- name: Download tree-sitter grammars
|
|
23
|
+
run: >
|
|
24
|
+
uv run python -c "import tree_sitter_language_pack as t;
|
|
25
|
+
t.download(['python','typescript','tsx','javascript','go','java','rust','zig'])"
|
|
26
|
+
- name: Lint
|
|
27
|
+
run: uv run ruff check .
|
|
28
|
+
- name: Test
|
|
29
|
+
run: uv run pytest -q
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: astral-sh/setup-uv@v5
|
|
13
|
+
- name: Build
|
|
14
|
+
run: uv build
|
|
15
|
+
- name: Check metadata
|
|
16
|
+
run: uvx twine check dist/*
|
|
17
|
+
- uses: actions/upload-artifact@v4
|
|
18
|
+
with:
|
|
19
|
+
name: dist
|
|
20
|
+
path: dist/
|
|
21
|
+
|
|
22
|
+
publish:
|
|
23
|
+
needs: build
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
environment: pypi
|
|
26
|
+
permissions:
|
|
27
|
+
id-token: write # PyPI Trusted Publishing
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/download-artifact@v4
|
|
30
|
+
with:
|
|
31
|
+
name: dist
|
|
32
|
+
path: dist/
|
|
33
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*.egg-info/
|
|
4
|
+
.venv/
|
|
5
|
+
.pytest_cache/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
.ccr/graph.db*
|
|
9
|
+
.ccr/local/
|
|
10
|
+
|
|
11
|
+
# this repo's own ccr state (graph, history, local caches); in target projects
|
|
12
|
+
# .ccr/config.yaml and .ccr/history.jsonl are committed instead
|
|
13
|
+
.ccr/
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
|
|
16
|
+
# ccr (local caches, never commit)
|
|
17
|
+
.ccr/backups/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here.
|
|
4
|
+
|
|
5
|
+
## [0.1.1] - 2026-10-17
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Published on PyPI as `claude-code-router` (the command is still `ccr`).
|
|
9
|
+
- CI, contributing guide, issue and PR templates, README screenshots and badges.
|
|
10
|
+
|
|
11
|
+
## [0.1.0] - 2026-10-17
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- Rule-based routing of Claude Code tasks to six tiers (T0 to T4, plus T2H) with matching
|
|
15
|
+
`ccr-*` subagents.
|
|
16
|
+
- Task classification, tree-sitter code graph, and a risk score from dependents, complexity,
|
|
17
|
+
tests, churn, critical paths and memory notes.
|
|
18
|
+
- Learning from past outcomes, weekly budget pressure and an opt-in haiku assist.
|
|
19
|
+
- Commands: `init`, `profile`, `explain`, `run`, `stats`, `dashboard`, `export-benchmark`,
|
|
20
|
+
`calibrate`, `shadow`, `tune`, `purge`, `feedback`, `graph`, `doctor`.
|
|
21
|
+
- Claude Code hooks and a status line relay, all fail-open.
|
|
22
|
+
- MIT license.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping improve ccr.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
git clone https://github.com/ai-solution-architect-roadmap/claude-code-router.git
|
|
9
|
+
cd claude-code-router
|
|
10
|
+
uv sync
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Before you open a pull request
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
uv run ruff check .
|
|
17
|
+
uv run pytest -q
|
|
18
|
+
uv run python scripts/bench_routing.py # if you changed routing rules
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Guidelines
|
|
22
|
+
|
|
23
|
+
- Keep routing rule-based, local and token-free. The only model call allowed is the opt-in
|
|
24
|
+
haiku assist.
|
|
25
|
+
- Hooks must fail open: bad input or an exception means no output and exit 0.
|
|
26
|
+
- Add a test for every behavior change. Routing changes should also add a prompt to
|
|
27
|
+
`scripts/bench_routing.py`.
|
|
28
|
+
- Update the README or `docs/REFERENCE.md` when commands, options or config keys change.
|
|
29
|
+
- Keep commits focused, with a short imperative subject line.
|
|
30
|
+
|
|
31
|
+
## Reporting bugs
|
|
32
|
+
|
|
33
|
+
Use the issue templates. For a routing problem, include `ccr explain "<prompt>" --json`.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Satya Prakash Tiwari
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: claude-code-router
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Route Claude Code tasks to the cheapest sufficient model and effort
|
|
5
|
+
Project-URL: Homepage, https://github.com/ai-solution-architect-roadmap/claude-code-router
|
|
6
|
+
Project-URL: Documentation, https://github.com/ai-solution-architect-roadmap/claude-code-router/blob/main/docs/REFERENCE.md
|
|
7
|
+
Project-URL: Changelog, https://github.com/ai-solution-architect-roadmap/claude-code-router/blob/main/CHANGELOG.md
|
|
8
|
+
Project-URL: Issues, https://github.com/ai-solution-architect-roadmap/claude-code-router/issues
|
|
9
|
+
Author: Satya Prakash Tiwari
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: claude-code,cli,cost-optimization,llm,model-routing,routing
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Software Development
|
|
21
|
+
Classifier: Topic :: Utilities
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: pyyaml>=6
|
|
24
|
+
Requires-Dist: tree-sitter-language-pack>=0.2
|
|
25
|
+
Requires-Dist: typer>=0.12
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# ccr: the cheapest sufficient model for Claude Code
|
|
29
|
+
|
|
30
|
+
[](https://github.com/ai-solution-architect-roadmap/claude-code-router/actions/workflows/ci.yml)
|
|
31
|
+
[](https://github.com/ai-solution-architect-roadmap/claude-code-router/blob/main/LICENSE)
|
|
32
|
+
[](https://github.com/ai-solution-architect-roadmap/claude-code-router/blob/main/pyproject.toml)
|
|
33
|
+
[](https://claude.com/claude-code)
|
|
34
|
+
[](#how-it-works)
|
|
35
|
+
[](https://github.com/ai-solution-architect-roadmap/claude-code-router/commits/main)
|
|
36
|
+
|
|
37
|
+
`ccr` routes each Claude Code task to the cheapest model and effort level that should be
|
|
38
|
+
enough for it, so your subscription goes further without you picking models by hand. You keep
|
|
39
|
+
typing plain `claude`.
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
ccr: T2 (sonnet/medium) — touches app/payments/ledger.py, 2 dependents, no tests found,
|
|
43
|
+
critical path: payments. Delegate implementation to ccr-implement; use Explore (haiku) for search.
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Screenshots
|
|
47
|
+
|
|
48
|
+
`ccr explain` shows the tier and exactly why, without running anything:
|
|
49
|
+
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
`ccr dashboard` writes a self-contained HTML report of tiers, success rate, estimated savings and
|
|
53
|
+
every routing decision:
|
|
54
|
+
|
|
55
|
+

|
|
56
|
+
|
|
57
|
+
## How it works
|
|
58
|
+
|
|
59
|
+
For every prompt, a hook decides a tier using local, rule-based checks (no tokens spent, under
|
|
60
|
+
half a second):
|
|
61
|
+
|
|
62
|
+
1. **Classify** the task: question, bugfix, feature, refactor, migration, security, and so on.
|
|
63
|
+
2. **Locate** the code it touches, using a local tree-sitter code graph (`.ccr/graph.db`).
|
|
64
|
+
3. **Score risk**: dependents, complexity, test coverage, churn, critical paths (auth, payments,
|
|
65
|
+
migrations, infra, secrets) and notes in `CLAUDE.md` or memory.
|
|
66
|
+
4. **Adjust** with your team's past outcomes and your weekly usage.
|
|
67
|
+
5. **Hint** Claude with one line, which delegates the work to a tiered `ccr-*` subagent.
|
|
68
|
+
|
|
69
|
+
| Tier | Model / effort | Agent | Typical work |
|
|
70
|
+
|------|-----------------|-----------------|--------------|
|
|
71
|
+
| T0 | haiku / low | `ccr-quick` | questions, lookups, typos, renames |
|
|
72
|
+
| T1 | sonnet / low | `ccr-small` | tests, clear bug fixes, small edits |
|
|
73
|
+
| T2 | sonnet / medium | `ccr-implement` | features, refactors, perf work |
|
|
74
|
+
| T2H | sonnet / high | `ccr-senior` | risky or complex multi-file changes |
|
|
75
|
+
| T3 | opus / high | `ccr-architect` | migrations, security, unclear bugs, design |
|
|
76
|
+
| T4 | opus / xhigh | `ccr-critical` | critical-path changes only |
|
|
77
|
+
|
|
78
|
+
## Install
|
|
79
|
+
|
|
80
|
+
Requires Python 3.10+, git, and Claude Code (`claude`) on PATH.
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
uv tool install claude-code-router
|
|
84
|
+
# or
|
|
85
|
+
pipx install claude-code-router
|
|
86
|
+
# or
|
|
87
|
+
pip install claude-code-router
|
|
88
|
+
|
|
89
|
+
ccr --help
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The package is `claude-code-router`; the command it installs is `ccr`. To install the latest
|
|
93
|
+
unreleased code instead, use `uv tool install git+https://github.com/ai-solution-architect-roadmap/claude-code-router.git`.
|
|
94
|
+
|
|
95
|
+
> Name clash: the npm package *claude-code-router* also installs a `ccr` command. Install
|
|
96
|
+
> this tool so `ccr` on your PATH is this one. `ccr doctor` checks.
|
|
97
|
+
|
|
98
|
+
The `.claude/` folder in this repo is a working example of what `ccr init` generates (agents and
|
|
99
|
+
settings), because ccr routes its own development.
|
|
100
|
+
|
|
101
|
+
## Quick start
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
cd your-project
|
|
105
|
+
ccr init --dry-run # show the exact diff of every file it would touch; writes nothing
|
|
106
|
+
ccr init # apply it (modified files are backed up to .ccr/backups/)
|
|
107
|
+
ccr doctor # check the setup
|
|
108
|
+
ccr explain "Fix the off-by-one in paginate() in app/api/pagination.py" # preview a decision
|
|
109
|
+
claude # work as usual
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Re-running `ccr init` is safe. To skip routing for one prompt, put `!noroute` at the end of it.
|
|
113
|
+
|
|
114
|
+
## Commands
|
|
115
|
+
|
|
116
|
+
Every command accepts `--path DIR` (project root, default `.`) and `--help`. Run `ccr --help`
|
|
117
|
+
for the list.
|
|
118
|
+
|
|
119
|
+
### Setup
|
|
120
|
+
|
|
121
|
+
**`ccr init`** installs settings (model, hooks, status line), the `ccr-*` agents and
|
|
122
|
+
`.ccr/config.yaml`. Safe to re-run; modified files are backed up to `.ccr/backups/`.
|
|
123
|
+
|
|
124
|
+
| Option | Effect |
|
|
125
|
+
|--------|--------|
|
|
126
|
+
| `--dry-run` | Print the exact diff; write nothing |
|
|
127
|
+
| `--force` | Override your `model`/`effortLevel` and regenerate edited ccr agent files (with backups) |
|
|
128
|
+
| `--local` | Write settings to `.claude/settings.local.json` (personal, uncommitted) |
|
|
129
|
+
| `--no-statusline` | Do not install the status line relay |
|
|
130
|
+
| `--no-graph` | Skip building the code graph |
|
|
131
|
+
| `--command CMD` | Command prefix the hooks use to run ccr (default: auto-detect) |
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
ccr init --dry-run
|
|
135
|
+
ccr init --local --no-statusline
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**`ccr profile [PATH]`** prints the detected languages, frameworks, file count and LOC, and the
|
|
139
|
+
suggested session default model/effort.
|
|
140
|
+
|
|
141
|
+
| Option | Effect |
|
|
142
|
+
|--------|--------|
|
|
143
|
+
| `--apply` | Write the suggestion into `.claude/settings.json` (overrides existing values) |
|
|
144
|
+
| `--dry-run` | With `--apply`: print the diff only |
|
|
145
|
+
| `--local` | With `--apply`: write `.claude/settings.local.json` instead |
|
|
146
|
+
|
|
147
|
+
**`ccr doctor`** checks the environment and project setup. `--verbose` logs details to
|
|
148
|
+
`.ccr/local/ccr.log`.
|
|
149
|
+
|
|
150
|
+
**`ccr graph`** builds or refreshes the code graph incrementally, or inspects it.
|
|
151
|
+
|
|
152
|
+
| Option | Effect |
|
|
153
|
+
|--------|--------|
|
|
154
|
+
| `--rebuild` | Drop and rebuild the graph |
|
|
155
|
+
| `--stats` | Show graph statistics |
|
|
156
|
+
| `--query SYMBOL` | Look up a symbol |
|
|
157
|
+
| `--offline` | Never download tree-sitter grammars |
|
|
158
|
+
|
|
159
|
+
### Routing
|
|
160
|
+
|
|
161
|
+
**`ccr explain "<task>"`** shows the tier, scores, touched files and reasoning. Runs nothing.
|
|
162
|
+
`--json` gives machine-readable output; `--llm` asks haiku (your `claude` CLI) when rule
|
|
163
|
+
confidence is low.
|
|
164
|
+
|
|
165
|
+
```sh
|
|
166
|
+
ccr explain "Fix the off-by-one in paginate() in app/api/pagination.py"
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**`ccr run "<task>"`** runs the task headlessly with `claude -p` at the routed tier and climbs
|
|
170
|
+
one tier if the attempt fails. Omit the task or pass `-` to read it from stdin.
|
|
171
|
+
|
|
172
|
+
| Option | Effect |
|
|
173
|
+
|--------|--------|
|
|
174
|
+
| `--tier T0..T4` | Start at this tier instead of the routed one |
|
|
175
|
+
| `--max-turns N` | Turn cap per attempt (default `run.max_turns`) |
|
|
176
|
+
| `--max-budget-usd X` | Spend cap for the whole run, all attempts |
|
|
177
|
+
| `--max-escalations N` | Tiers to climb after a failure, 0 to 4 (default 1) |
|
|
178
|
+
| `--test-command CMD` | Shell command that must exit 0 for success (default `run.test_command`) |
|
|
179
|
+
| `--no-test` | Skip the test command |
|
|
180
|
+
| `--permission-mode MODE` | Passed to claude, e.g. `acceptEdits` |
|
|
181
|
+
| `--no-llm` | Rules only; never ask haiku to help classify |
|
|
182
|
+
| `--dry-run` | Show the routing and the command; run nothing |
|
|
183
|
+
| `--json` | Print a JSON summary instead of the result text |
|
|
184
|
+
|
|
185
|
+
```sh
|
|
186
|
+
ccr run "add a --dry-run flag to app/main.py" --test-command "pytest -q" --max-budget-usd 2
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Feedback, stats and learning
|
|
190
|
+
|
|
191
|
+
**`ccr feedback [good|bad]`** marks the last routed task good or bad (a correction record is
|
|
192
|
+
appended; history is never rewritten). With no verdict it shows the last task. Use `--id PREFIX`
|
|
193
|
+
to target a task by id instead of the most recent one.
|
|
194
|
+
|
|
195
|
+
**`ccr stats`** shows usage, estimated savings, misroutes, tier distribution, and success and
|
|
196
|
+
escalation rates per tier, area and task class.
|
|
197
|
+
|
|
198
|
+
| Option | Effect |
|
|
199
|
+
|--------|--------|
|
|
200
|
+
| `--days N` | Only the last N days |
|
|
201
|
+
| `--misroutes` | List each over- and under-routed task |
|
|
202
|
+
| `--json` | Machine-readable output |
|
|
203
|
+
|
|
204
|
+
**`ccr dashboard`** writes a self-contained HTML dashboard (charts, savings, misroutes, recent
|
|
205
|
+
tasks). Options: `--days N`, `--out FILE` (default `.ccr/local/dashboard.html`), `--open` to open
|
|
206
|
+
it in the browser.
|
|
207
|
+
|
|
208
|
+
**`ccr calibrate`** fits failure odds on the routing signals and compares them with the rules.
|
|
209
|
+
Report only; it never changes routing. Needs about 30 decided tasks. `--json` for machine output.
|
|
210
|
+
|
|
211
|
+
**`ccr tune`** proposes config edits from misroute evidence as a diff. Nothing changes unless
|
|
212
|
+
you pass `--apply`, which backs up the config first.
|
|
213
|
+
|
|
214
|
+
**`ccr shadow`** re-runs sampled deep-tier tasks at a lower tier in a throwaway git worktree to
|
|
215
|
+
measure over-routing. Opt-in and costs real usage; without `--yes` it only prints the plan.
|
|
216
|
+
Needs `hooks.store_prompts`.
|
|
217
|
+
|
|
218
|
+
| Option | Effect |
|
|
219
|
+
|--------|--------|
|
|
220
|
+
| `--from-tier T` | Sample tasks routed to this tier or above (default `T3`) |
|
|
221
|
+
| `--shadow-tier T` | Tier to try instead (default: one below the task's tier) |
|
|
222
|
+
| `--sample N` | How many tasks to re-run, 1 to 50 (default 3) |
|
|
223
|
+
| `--max-budget-usd X` | Total spend cap across the sample |
|
|
224
|
+
| `--test-command CMD` | Must exit 0 for a shadow run to count as success |
|
|
225
|
+
| `--yes` | Actually run |
|
|
226
|
+
|
|
227
|
+
**`ccr export-benchmark`** writes a replay set from decided tasks with stored prompts to
|
|
228
|
+
`--out FILE` (default `ccr-benchmark.json`). Replay it with
|
|
229
|
+
`uv run python scripts/bench_routing.py --prompts FILE`.
|
|
230
|
+
|
|
231
|
+
### Privacy
|
|
232
|
+
|
|
233
|
+
**`ccr purge`** deletes or scrubs locally stored prompts and shadow results. It shows what it
|
|
234
|
+
would do first and deletes only with `--yes`.
|
|
235
|
+
|
|
236
|
+
| Option | Effect |
|
|
237
|
+
|--------|--------|
|
|
238
|
+
| `--prompts` | Stored prompts and decisions |
|
|
239
|
+
| `--shadow` | Shadow-run results |
|
|
240
|
+
| `--older-than N` | Only prompts older than N days |
|
|
241
|
+
| `--redact` | Re-scrub existing stored prompts |
|
|
242
|
+
| `--yes` | Actually delete |
|
|
243
|
+
|
|
244
|
+
### Internal (called by Claude Code, not by you)
|
|
245
|
+
|
|
246
|
+
- **`ccr hook session-start|prompt|stop`** is the hook entry. It reads hook JSON on stdin and
|
|
247
|
+
always exits 0.
|
|
248
|
+
- **`ccr statusline`** is the status line relay. It records model, effort and rate limits, and
|
|
249
|
+
prints a short line. `--wrap "<cmd>"` runs your own status line command and prints its output.
|
|
250
|
+
|
|
251
|
+
## Configuration
|
|
252
|
+
|
|
253
|
+
`ccr init` creates `.ccr/config.yaml`; commit it. Any key you leave out uses the default. You
|
|
254
|
+
can change the tiers, class base tiers, critical paths and terms, risk weights, budget limits
|
|
255
|
+
and learning thresholds. See the [full reference](https://github.com/ai-solution-architect-roadmap/claude-code-router/blob/main/docs/REFERENCE.md).
|
|
256
|
+
|
|
257
|
+
## Accuracy
|
|
258
|
+
|
|
259
|
+
`scripts/bench_routing.py` replays a labelled prompt set against a fixture project with no API
|
|
260
|
+
calls. It reports under-routed and over-routed prompts and the estimated cost against all-Opus
|
|
261
|
+
and all-Sonnet baselines. The labels are judgment calls, so edit them to match your own work.
|
|
262
|
+
It measures routing quality, not answer quality.
|
|
263
|
+
|
|
264
|
+
Routing is strongest for clearly worded prompts in a supported language with a fresh graph.
|
|
265
|
+
It is weaker for prompts that name no code and for projects with unusual folder names until
|
|
266
|
+
you add your own `critical_paths`, `critical_terms` and `hard_terms`.
|
|
267
|
+
|
|
268
|
+
## Privacy
|
|
269
|
+
|
|
270
|
+
All routing decisions run locally. The only model call ccr makes on its own is an optional,
|
|
271
|
+
opt-in classification by haiku through your own `claude` CLI. Local state lives in `.ccr/`.
|
|
272
|
+
|
|
273
|
+
## Documentation
|
|
274
|
+
|
|
275
|
+
The [reference](https://github.com/ai-solution-architect-roadmap/claude-code-router/blob/main/docs/REFERENCE.md) covers the full configuration, team workflow, status line and
|
|
276
|
+
budget pressure, hooks and fail-open behavior, headless runs, feedback and learning, privacy,
|
|
277
|
+
limitations and troubleshooting.
|
|
278
|
+
|
|
279
|
+
## Development
|
|
280
|
+
|
|
281
|
+
See [CONTRIBUTING.md](https://github.com/ai-solution-architect-roadmap/claude-code-router/blob/main/CONTRIBUTING.md) and the [changelog](https://github.com/ai-solution-architect-roadmap/claude-code-router/blob/main/CHANGELOG.md).
|
|
282
|
+
|
|
283
|
+
```sh
|
|
284
|
+
uv sync
|
|
285
|
+
uv run pytest
|
|
286
|
+
uv run python scripts/bench_routing.py
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## License
|
|
290
|
+
|
|
291
|
+
[MIT](https://github.com/ai-solution-architect-roadmap/claude-code-router/blob/main/LICENSE)
|