This repository is set up so coding agents prove their work before they call it done. This page explains the parts, what each one guarantees, and where it stops.
- Git hooks run for everyone, people and agents alike, on every commit and push.
npm run verifyruns every CI check locally and records a pass.AGENTS.mdtells agents what done means. Claude Code reads it throughCLAUDE.md; Codex and Cursor read it directly.- Skills in
.agents/skills/give step-by-step procedures for recurring work. They load only when a task needs them. - Review: fresh reviewers and Doistbot check a finished change against the checks in
.agents/checks/. - The end-of-turn gate sends an agent back once when its turn changed code that
npm run verifyhas not passed.
| Rule | Held by | Certainty |
|---|---|---|
No commits on main |
pre-commit and commit-msg → .agents/scripts/branch-guard.sh |
Enforced locally; --no-verify skips it |
No pushes to main |
pre-push → branch-guard.sh; the "Protect default branch" ruleset |
Enforced on GitHub |
| Committed files are linted and formatted | pre-commit (lefthook, staged files only); CI |
Enforced in CI |
| Type check passes before a commit | pre-commit; CI |
Enforced in CI |
| Tests pass before a push | pre-push; CI |
Enforced in CI |
| Agent tooling never ships in the npm package | .agents/scripts/package-contents.test.ts |
Enforced in CI |
npm run verify runs what CI runs |
.agents/scripts/lib/steps.test.ts compares it with the workflows |
Enforced in CI |
Run npm run verify before calling work done |
AGENTS.md |
Enforced at turn end (once); AGENTS.md |
| Never weaken a check to pass it | AGENTS.md |
Asked |
| Instructions name only files, links and scripts that exist | .agents/scripts/instructions.test.ts |
Enforced in CI |
| Every skill says when to use it and is linked for Claude Code | .agents/scripts/instructions.test.ts |
Enforced in CI |
| Use the matching skill for each task | AGENTS.md |
Asked |
| Tests meet the quality bar | .agents/skills/write-tests/references/test-rules.md |
Asked |
| Review checks say what to report and what is fine, and AGENTS.md links them | .agents/scripts/instructions.test.ts |
Enforced in CI |
| A finished change gets a task review, a blast-radius review when shared code changed, and a code review | review-changes skill |
Asked |
| Reviewers never edit the shared checkout | the reviewer brief; npm run review:worktree gives them their own |
Asked |
"Enforced in CI" means a pull request cannot merge without it. A local hook alone is a speed bump: git commit --no-verify skips it.
Lefthook runs the hooks, configured in lefthook.yml. npm install installs them into .git/hooks: the prepare script runs lefthook install --reset-hooks-path, then the build. Outside a git checkout, as when npm installs this package from GitHub, it only builds.
pre-commitrefuses a commit onmain, then lints and formats the staged files (re-staging what the tools fix) and runs the type check. Like CI, it lints the SDK but not the docs site inwebsite/. Unstaged changes in a partly staged file are left alone.commit-msgrefuses a commit onmainagain. Lefthook runs no pre-commit job when nothing is staged, so without it an empty commit would get past.pre-pushrefuses a push tomain, then runs the tests. It checksgit push --dry-runtoo. Pushes tonext, the prerelease branch, are allowed.- If node is not on
PATH(some GUI git clients), both hooks still apply the branch rule, skip the checks, and say so. CI runs the same checks. - The default branch is read from
origin/HEAD, falling back tomain. - Worktrees share the hooks in
.git/hooks, so the branch rule works in a new worktree at once. Lint, format, types and tests neednpm ciin that worktree first. - Without the lefthook binary (no
node_modulesin any checkout), the hooks print "Can't find lefthook in PATH" and let the commit through.
The release workflow commits and pushes to main and next from GitHub Actions, and npm ci runs prepare there, which installs the hooks. The release step sets LEFTHOOK=0, so they do not run, and the guard also skips itself when GITHUB_ACTIONS=true. Branch protection on GitHub is the real enforcement; the hooks only catch mistakes early.
One command, every check a pull request's CI runs: lint, format, both type checks, all tests and the build (which npm ci runs in CI, through prepare). It takes about fifteen seconds, so it always checks the whole tree. Picking only the affected tests would save a few seconds and add a way to miss something.
- Before the checks it stops if Node is older than
package.jsonrequires, or ifnode_modulesdoes not match the lockfile. Both make checks fail for reasons unrelated to your change. - Steps run the
package.jsonscripts CI runs (lint,format:check,type-check:src,type-check:tools,build,test) side by side, except the tests: they start once the build has passed, since in CInpm cibuilds first and a test packsdist/. - Only docs changed since the branch left
main: it checks just their formatting, which CI checks too, and records nothing. The agent instructions (AGENTS.md,docs/agents.md,.agents/) count as code, since a test checks every reference in them. So does deleting any doc, since they may name it; adding one makes an earlier pass out of date. - Only CI files changed (Renovate,
.github/config other than workflows): it says no local check reads them, and checks their formatting. Every workflow counts as code, since a local test reads them all. - Output: one line per step. A failing step prints the last 30 lines of its log and the log's path under
.tmp/agents/logs/. - The record: after a full pass it writes a hash of the tree to
.tmp/agents/verified.json: the content of every file local checks read, and the names, not the content, of docs. CI-only files are left out. A run that fails, or sees files change while it runs, deletes it. The end-of-turn gate reads it. - What it cannot see: the real Comms API, Node versions other than yours, the packed package as consumers resolve it (
npm run attw, which only the release runs) and the docs site build. It prints these after every pass.
The docs site build (.github/workflows/validate-docs.yml) is the one pull-request check verify leaves out: it needs its own npm ci in website/ and takes over a minute from cold, several times the rest put together. Run npm ci && npm run build in website/ when a change touches the docs site or the public API's doc comments.
If ci.yml gains a step, or another workflow starts running commands on pull requests, .agents/scripts/lib/steps.test.ts fails until verify accounts for it.
Every agent's hooks call one script, .agents/scripts/guard.ts, so the agents can't drift apart.
- Turn start (you send a message): it hashes every file in the checkout, untracked ones included, into
.tmp/agents/turns/. - Turn end (the agent stops): it compares the tree with the turn's start and with the last
npm run verifypass. If the turn changed code and verify has not passed on exactly this tree, it sends the agent back once, naming the files. The second time, it lets the agent stop and shows you a note. - Passes without a word: turns that changed nothing, changed only docs, or undid their edits. Deleting a doc counts as code, since the agent docs may name it.
- "Once" is deliberate: an agent can stop on purpose and say what is unfinished.
| Agent | Wiring | Known limits |
|---|---|---|
| Claude Code | .claude/settings.json: UserPromptSubmit and Stop |
Tested in a real headless session (claude -p): it sent the agent back once with the message, and the agent ran verify and stopped. |
| Codex | .codex/hooks.json: UserPromptSubmit and Stop |
Runs only in a trusted project, after each person reviews the hooks in /hooks. Versions 0.154 and 0.162.1 ran no project hooks in a linked worktree. Not yet tried in a real session. |
| Cursor | Runs the Claude Code hooks itself; the command falls back to the git root if Cursor does not set CLAUDE_PROJECT_DIR |
No Cursor hooks file: a second one would run every hook twice. A test keeps it out. Not yet tried in a real session. |
Other limits:
- Two sessions in one checkout share its files, so each may be told about the other's edits. Use a worktree per session.
- If the branch's code is back to what
mainhas (an undo, a stash, a switch), the turn passes: CI already checked that code.
Fails open, visibly: a broken guard, bad input or a checkout without the script lets the turn end and says why in a message. DISABLE_AGENT_GUARD=1 in the agent's environment turns the gate off for you.
Speed: turn start takes under 0.1 seconds on this repository.
Each skill is a short procedure with a check at the end of every step. Agents load one when the task matches its description.
| Skill | For | Ends with |
|---|---|---|
verify |
Any change about to be called done | npm run verify, proof matched to the change, an evidence report |
fix-bug |
Something broken | A test that failed on the symptom, the root cause, undo/restore |
build-feature |
A new client method, option or behaviour | Decisions settled up front, test-first slices, a "touches X" map |
refactor |
Structure changes, behaviour unchanged | Pinned tests, no changed assertions |
write-tests |
Writing or changing tests | Tests that failed once, meeting the test rules |
learn |
A correction from you | A type, lint rule, test or script check that catches the mistake |
review-changes |
A change you say is ready | Task, blast-radius and code reviews; each finding fixed, dismissed with evidence or left open |
The evidence report rates each claim: said, cited (a line), traced (followed the code), ran (a test or command executed it), seen (against the real Comms API, or in a consumer built against the change). "Fixed" or "safe" needs ran. Anything less is listed under "Not verified".
The test rules were measured against this repository's tests first, so they accept the patterns that are fine here: .not.toHaveBeenCalled(), toMatchObject on the request fields a test is about, the suite-wide MSW transport seam.
When you say a change is ready, the agent runs review-changes:
- Task review: a fresh subagent gets your request in your words, what done means and the decisions made, never the author's reasoning. It looks for what is missing or unrequested. Doistbot can't do this, since it never sees the task.
- Blast-radius review: only when shared code changed (the exports of
src/index.ts,src/clients/base-client.ts,src/transport/, the schemas insrc/types/, dependencies, build config). It names the one fact that makes the change safe and proves it by running code. - Code review: Doistbot locally (
doistbot review --json, or--base <branch below>in a stack) when version 1.0.12+ is installed anddoistbot doctorpasses. Otherwise one subagent per check in.agents/checks/. Doistbot readsAGENTS.mdand its links, so the checks apply to its pull request reviews too.
Findings are fixed, dismissed with evidence (a line or a test run, never an argument), or left open for you. Reviewers that need to run code get their own worktree from npm run review:worktree -- <dir>; the shared one stays read-only.
The checks cover tests, architecture, security, privacy, the public API and evidence. Two kinds Todoist uses elsewhere don't apply here: there are no translations and no database migrations. The closest thing to a migration is a breaking change to the public API, which the public API check ties to the version the PR title releases.
A review costs several agent runs, so it runs when you ask, not on every change. A Doistbot run with a failed provider (providerFailures) is partial; the agent should say so.
Give it:
- the goal, in a sentence;
- a done check that can pass or fail ("
api.workspaceUsers.getUsersByIdswith 250 ids sends three requests"); - the proof you want (a failing test first, a call against a test account, a docs site build);
- facts you know and real constraints (a deadline, a public API that must not change).
Leave out the method and your theory of the cause. For a vague report, ask the agent to restate it first. Start a new session for unrelated work.
| To start… | Say |
|---|---|
| a bug fix | "Fix: . Call: . Expected: ." (fix-bug) |
| a feature | "Add . Done when ." (build-feature) |
| a refactor | "Refactor so ." (refactor) |
| a review | "Ready for a PR." (review-changes) |
| a release | "Ready to release." Check the PR title type: feat:, fix:, perf: and breaking changes publish; others do not. |
Your part: answer the decision questions, and read the evidence report, especially "Not verified".
.agents/scripts/holds scripts and their tests. Nothing under.agents/ships:package.json#fileslists onlydist/, and a test checks the packed package.- The tooling runs straight from TypeScript with Node's type stripping, so it only uses erasable syntax (
.agents/scripts/tsconfig.jsonenforces this). The one exception is.agents/scripts/verify.mjs, plain JavaScript that checks the Node version before loading the rest, so an old Node gets a message instead of a syntax error.npm run type-checkcovers it, andnpm run checklints it. - Tests run in
npm testand CI. They copy the tools into throwaway git repositories and never touch your checkout. A test helper clears the variables git exports to hooks, sincenpm testitself runs insidepre-push.
semantic-release publishes from main on every merge, and prereleases from next. The squash-merged PR title decides whether anything ships: feat:, fix:, perf: and any breaking change (!) release; chore:, ci:, docs:, test: and refactor: do not. Changes to the agent tooling use chore: or ci:, so they never publish a new version. No path filter is needed.
- No node on
PATHin a GUI client: the hooks skip lint, the type check and the tests, with a message. The branch rule still applies. - The end-of-turn gate: any error lets the turn end, with a message saying why.
DISABLE_AGENT_GUARD=1turns it off. git commit --no-verify: every local hook is skipped. CI and branch protection still apply.- A push that changes no files, such as an empty commit or a branch deletion: lefthook runs no pre-push job for it, so the branch rule is skipped too. The ruleset still refuses it on GitHub.