canonkit

中文文档
2.4.0发布于 2026/11/03MITES Module构建来源已验证

A versioned agent team for Claude Code, Codex and OpenCode. Installs 10 core agents and 5 opt-in domain specialists, each owning a domain and classifying its own risk.

原始使用文档
文档目录12 节
  1. Who it's for
  2. Quickstart
  3. How it decides: LOW vs HIGH
  4. The team
  5. Stack packs, per project
  6. When a gate fires
  7. If no gate ever fires
  8. Runtimes
  9. Commands
  10. FAQ
  11. Documentation
  12. License

canonkit

A versioned team of AI subagents for Claude Code, Codex and OpenCode. Each agent owns one domain: product, architecture, security, quality, UX, performance, operations or docs. Before it recommends anything, it rates the risk of the change. Small, reversible work stays with your main agent. Changes to auth, secrets, migrations or public contracts go to the agent that owns them. In Claude Code, hooks enforce the rules that matter most, so they hold even when the model forgets them. Codex and OpenCode get the two that matter most of all: no git hook bypass and no secrets written to a file.

Each agent is one Markdown file in agents/, already in the format Claude Code reads. For Claude Code, installing is a plain copy. Codex and OpenCode get a generated copy of the same body. Either way there is one source per agent, and nothing to reconcile by hand.

canonkit 1.x is not canonkit 0.x. Versions up to 0.2.0 were a different tool. It generated Spec-Kit-style governance templates (.specify/, a constitution, scale profiles) through canonkit init. That tool is archived and none of its commands exist here. If you used it, pin [email protected].

Who it's for

  • You use Claude Code, Codex or OpenCode with subagents, and you want each one called only when its domain is actually at risk, not on every change.
  • You want a few guarantees to hold even when the model forgets them: confirm before git commit and git push, block secrets, and require a review before a HIGH-risk change counts as done.
  • You want to see what delegation costs (tokens, time, report size per dispatch) without sending anything off your machine.

It is not a fit if you want one agent per task, or a heavy spec-first process. canonkit can work alongside openspec, but it does not replace it.

Quickstart

Requires Node 18+. On Linux, macOS and Windows:

npx canonkit install --wire-hooks

In a terminal, a menu asks which runtimes to install for. Claude Code and Codex come pre-selected; OpenCode is opt-in. --wire-hooks wires the gate hook of each runtime you chose: ~/.claude/settings.json, $CODEX_HOME/hooks.json (then run /hooks in Codex once to trust it), and the OpenCode 2 plugin. It saves a dated .bak of each config file it changes and changes nothing else. If you leave the flag out, install only prints Claude Code's JSON for you to paste yourself. What each choice writes.

Codex agents default to gpt-6.1-sol. To follow your Codex session's model instead of pinning a version, set CANONKIT_CODEX_MODEL=inherit when installing. See model configuration for PowerShell examples, overrides and updating existing agents.

Check that it worked:

npx canonkit doctor

doctor only reads. It prints one line per check (OK, WARN or FAIL) and exits with 1 if anything failed:

OK   agents: 10 core agents in ~/.claude/agents
OK   reference: managed blocks in ~/AGENTS.md and ~/.claude/CLAUDE.md
OK   hook file: ~/.claude/hooks/canonkit-hook.js, same as this package's
OK   hook syntax: node --check passes
OK   hook wiring: registered with its matcher under PreToolUse, PostToolUse, SubagentStop, UserPromptSubmit, Stop
OK   log: ~/.claude/canonkit-activity is writable
OK   forwarder: no meu-time-hook.js left, and no settings in sight run it
OK   config: file none (defaults), root ~/my-project

No check failed.

Then open a new Claude Code session in any project:

  1. /agents should list the ten core agents (scott, archie, bob, ...).
  2. Ask it to commit something. You should get a canonkit gate: git commit/push requires explicit user authorization prompt. Decline it; you just saw a gate fire. No prompt? See If no gate ever fires.

Optional: the dashboard. It runs locally and shows dispatches, tokens and gates:

node ~/.claude/canonkit-dashboard/serve.js          # Linux, macOS, Git Bash
node $HOME\.claude\canonkit-dashboard\serve.js      # Windows PowerShell

Then open http://localhost:4317. What it records.

How it decides: LOW vs HIGH

Every agent uses one shared risk scale:

  • LOW: local and reversible. No public contract, auth, sensitive data or shared runtime.
  • MEDIUM: a new rule, flow, integration, permission or configuration; a shared refactor; a plausible regression.
  • HIGH: auth, secrets, migrations, public contracts, new services, payment, a production deploy, or anything that is hard to roll back.

Both examples below come from the routing eval cases:

"Fix the typo recieve in README.md." This is LOW. The main agent fixes it inline and dispatches no one. A dispatch would cost a cold start, plus a report that gets re-read on every later turn, for a one-word fix.

"Add refresh tokens to src/auth/session.js." This is HIGH, because it touches auth. Here is what happens:

  1. The main agent plans to bring in Gard (security), the owner of auth.
  2. Editing src/auth/session.js fires the HIGH-risk gate, and you confirm the edit.
  3. The work is not done on the author's word. When the turn ends, the Stop gate checks whether an independent reviewer (Quinn, Gard, Archie, Perry or a project reviewer) was dispatched, or resumed with a message, after the last gated edit. If none was, it blocks the turn once and asks for one.

There is a case in between: fixing a typo in a comment in src/auth/messages.js. The gate still fires, because the file is in auth/. The risk is still LOW, though, and the expected behavior is to confirm, explain why, and not pull in Gard. A gate tells you to look again at the risk; it does not make the change HIGH.

The team

Core: installed at user level and available in every project.

AgentOwnsBlocking authority
Scottproduct: problem, scope, acceptance criteria, success metricsveto
Archiearchitecture: patterns, module/service boundaries, public contracts, new servicesveto
Bobimplementation: code, debugging, refactoring, integrationnone
Quinnquality: test strategy, coverage, edge cases, regression riskveto
Gardsecurity: auth, permissions, secrets, exposure, dependencies, Docker/Composeveto
PixieUX: flows, UI states, accessibility, microcopyveto
Perryperceived speed: budgets, measurement, production-build evidenceblocks; sole authority to loosen a budget
Pipeoperations: CI/CD, deploy, rollback, observability, jobs, running migrationsblocks
Spencerdocumentation: ADRs, specs, API docs, runbooks, release notesveto
Virgothe team's own configuration: agents, skills, these managed blocksnone

Specialists: not installed by default. A project gets one only when you add it, so no agent gets called just to round out the list:

AgentInstall when the project has...
mayagameplay or gamification: core loop, progression, balance
novaa visual identity at stake: palette, composition, VFX language
echosound that carries meaning: SFX as feedback, adaptive music
danareal users and data: telemetry, funnels, A/B tests
irisML or computer vision: extraction, datasets, model evaluation
cd my-project
npx canonkit add maya nova      # writes Claude Code, Codex and OpenCode copies + the project's AGENTS.md

A veto is narrow. An agent can use its veto only inside its own domain, on a MEDIUM or HIGH change, and only against a risk it can name. You can overrule a veto. When you do, the agent records the open risk and keeps helping. Who owns what at the boundaries, the conventions every agent follows, and the Integration Review are in docs/team.md.

Stack packs, per project

Optional skills add language and framework guidance to the existing team. Choose the packs your project uses; each is installed separately from the core.

StackGuidanceInstall in your project
TypeScriptType safety, async boundaries and module/build diagnosticsnpx canonkit add typescript
C++Resource ownership, lifetimes, concurrency and compiler/linker diagnosticsnpx canonkit add cpp
C# / .NETNullability, async/resource lifetimes and solution/project buildsnpx canonkit add csharp
JavaResources, concurrency and Maven/Gradle diagnosticsnpx canonkit add java
PythonRuntime data, mutable state, resources, async and environmentsnpx canonkit add python
ReactHooks, state/effects, hydration and configured framework boundariesnpx canonkit add react
RustOwnership, lifetimes, async/unsafe invariants and Cargo diagnosticsnpx canonkit add rust
GoErrors, goroutines/channels and module/workspace buildsnpx canonkit add go
KotlinNullability, coroutines/Flow and JVM/Android/multiplatform buildsnpx canonkit add kotlin
SwiftARC, actors/concurrency and SwiftPM/Xcode diagnosticsnpx canonkit add swift

Run these commands from your project. You can add several packs at once, inspect what is installed and remove a pack when you stop using it:

cd my-project
npx canonkit add typescript react
npx canonkit list
npx canonkit remove react

React and TypeScript are independent. Adding a pack installs its instructions; it does not install compilers, runtimes or project dependencies.

Copies go to the project's .agents/skills/canonkit-<stack>/ and .claude/skills/canonkit-<stack>/. Local edits and unrelated files are preserved; repeating add updates intact copies. Details, recovery and removal are in docs/install.md.

When a gate fires

This table is Claude Code. Codex and OpenCode, once wired, enforce only the git bypass block and the secret block, with the same reason text (which gate does what where). The git, secret, HIGH-risk and performance prompts start with canonkit gate. The Stop gate starts with Definition-of-done gate. The context-size reminder is plain text.

GateFires whenWhat to do
git commit / pushany git commit or git push, including behind git -C dir or git -c key=valueConfirm only if you asked for it.
git hook / signing bypass (block)--no-verify, git commit -n, --no-gpg-sign, -c core.hooksPath=... or -c commit.gpgsign=falseIt is denied. Fix what the hook reported. If you really mean to skip it, run the command yourself (! in Claude Code). Details in docs/hooks.md.
Secret (block)a private key or cloud key would be written to a fileIt is denied. Move the value to an env var or a secret store.
Secret (ask)something looks like a hardcoded credentialConfirm only if it is not a real secret, such as a test fixture.
HIGH-risk surfacean edit or shell write to an auth, secret, migration or contract pathThe prompt asks for who imports or calls the file, which public contract it touches (or "none") and the rollback: answer before confirming. Look again at the risk. If it really is HIGH, plan the owner's review (Gard, Archie). If it is LOW, confirm and say why.
Performance budgetan edit to a budget file (lighthouserc, size-limit, budget.json, ...)The prompt fires either way, because the hook sees the path and not the direction. Confirm a tightening. Loosening is Perry's call, with a measured floor.
Definition of done (Stop)gated files were edited and no reviewer was dispatched after the last editDispatch (or resume) Quinn, Gard, Archie, Perry or a project reviewer, or say explicitly why review isn't needed. Fires once per turn.
Context sizethe session passes ~100k, 150k or 200k tokensA reminder, not a block. If the subject changed, start a new session from a handoff.

False alarms. The HIGH-risk gate matches paths, so it will sometimes fire on a folder named sessions/ or contracts/ that has nothing to do with auth. Each project can tune this in .claude/canonkit.json:

{
  "version": 1,
  "highRisk": { "include": ["src/billing/**"], "exclude": ["src/domain/contracts/**"] },
  "perfBudgets": ["perf/thresholds.yml"]
}

exclude can only silence ambiguous words. It never silences the secret check, credential paths (.env, *.pem, ...) or strong terms (auth, jwt, migrations in code). Editing canonkit.json is itself a gate. Don't edit the hook to make a gate stop firing: the next install overwrites it. The full rules are in docs/hooks.md.

If no gate ever fires

Run npx canonkit doctor. The hook fails open on purpose, so a broken or unregistered hook never blocks your session. That also means a broken hook gives no warning of its own.

Runtimes

RuntimeAgentsRulesHooks and gates
Claude Code~/.claude/agents~/AGENTS.md + block in ~/.claude/CLAUDE.mdyes
Codex$CODEX_HOME/agents/*.toml (~/.codex)~/AGENTS.md + block in $CODEX_HOME/AGENTS.mdthe two deny gates (git bypass, secrets), once wired; the rest by judgment
OpenCode 2 (opt-in)~/.config/opencode/agentsblock in ~/.config/opencode/AGENTS.mdthe two deny gates, plus a prompt on git commit/git push as typed, once wired; the rest by judgment

How each target is generated, and why OpenCode is opt-in: docs/install.md. Which gate does what in each runtime: docs/hooks.md.

Commands

CommandWhat it does
installcore agents, hook, dashboard, global blocks, skills (--claude / --codex / --opencode skip the menu)
install --wire-hooksthe same, and wires the hook of each runtime installed (Claude Code, Codex, OpenCode)
doctorchecks the installation; exits 1 on FAIL
referenceonly the global blocks and skills
uninstall [--claude] [--codex] [--opencode]remove tracked global artifacts; without flags, all recorded harnesses
add <name>... / remove <name>...specialists or stack-pack skills in the current project
listthe roster and what is installed where
tool add|remove|listintegrate graphify or openspec in the current project

--dry-run works on every command that writes: it reports what would change and writes nothing.

FAQ

What does it cost per turn? Claude Code lists every installed agent's description on every turn. That list plus the two global blocks comes to about 3k tokens. An agent's full body (~1–2k tokens) loads only when the agent is dispatched. Measurements.

Will it dispatch agents on every small change? It shouldn't. LOW work stays inline by rule. Before each release that changes the instructions, the routing eval checks this with cases like the typo fix above. If you see it happen anyway, please open an issue.

Can I edit an installed agent? Not in place: the next install overwrites ~/.claude/agents and the managed blocks. To change one, create a project agent with a different name, or change the source here and reinstall (docs/maintaining.md). Text outside the managed block markers in ~/AGENTS.md and ~/.claude/CLAUDE.md is yours and is preserved.

Does anything leave my machine? The hook keeps telemetry local in ~/.claude/canonkit-activity/; new records omit task descriptions and command fragments, but still include paths and identifiers alongside counts and timing. Older records can retain those texts until rotation. Both incidental project issues and the optional Learning Loop contribution supply sanitized drafts; publication requires your review and explicit authorization. Raw logs and personal memories do not belong in a contribution. Field list.

A gate fired on a change I'm sure is LOW. Confirm it and say why. If the same path keeps triggering the gate for no reason, add it to highRisk.exclude (see When a gate fires).

How do I uninstall? Run npx canonkit uninstall --dry-run to preview, then npx canonkit uninstall (or select harnesses with flags). It uses the install manifest, backs up edited owned artifacts, preserves observed artifacts intact and keeps content outside managed blocks. Pre-manifest installations and ambiguous wiring need manual cleanup; see docs/install.md.

I'm upgrading from meu-time. install migrates the log folder and leaves a forwarder for the old hook name. See docs/install.md.

Documentation

DocFor
docs/install.mdwhat each install writes, Codex/OpenCode details, specialists, reference blocks and skills, upgrade, uninstall
docs/hooks.mdhook wiring, the gates per runtime, failure mode, canonkit.json rules and glob dialect
docs/telemetry.mddispatch metrics, log fields, context contributors, the dashboard
docs/team.mdfull roster, domain boundaries, agent conventions, Integration Review
docs/tools.mdgraphify and openspec integration, with their security notes
docs/maintaining.mdediting an agent, file format, validate.sh, tests
docs/evals.mdrouting and quality evals, methodology and results
docs/learning-loop.mdinvestigate mistakes and propose evaluated instruction changes
docs/out-of-scope-issues.mdpreserve incidental project findings and approve issue drafts in a batch
docs/adr/architecture decisions

License

MIT

版本与发布记录

canonkit 共发布 13 个版本,首次发布于 2026/05/08;过去 12 个月发布了 13 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.4.0latest2026/11/03今天
2.3.02026/11/021 天前
2.2.02026/11/021 天前
2.1.02026/11/012 天前
2.0.02026/10/304 天前
1.1.52026/10/2311 天前

关于 canonkit 的常见问题

canonkit 是什么?

一个版本代理团队,为Claude Code, Codex和OpenCode。安装10个核心代理和5个可选域专家,每个拥有一个域并对自己的风险进行分类。

如何安装 canonkit?

在项目目录运行 npm install canonkit,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 canonkit,可以用 npx canonkit 直接运行。

canonkit 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/canonkit 是否存在。

canonkit 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

canonkit 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

canonkit 可以商用吗?

canonkit 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

canonkit 还在维护吗?

最新版本 2.4.0 发布于 2026/11/03(今天);至今共发布 13 个版本,其中过去 12 个月发布了 13 个;首次发布于 2026/05/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。