LLM plugin that turns a spec into milestones, then builds each as a stack of small, reviewed, test-first jj changes, planned as it goes.
README.md

cairn #

cairn is a Claude Code plugin that turns an approved design into small, deployable jj changes. You settle the decisions in conversation; cairn writes tests, builds each change, and checks it against the design and your repository's standards. You review the finished changes.

Each change—called a sliver—is chosen against the code built so far. cairn has already been used successfully across several milestones in a target repository.

Install and configure #

You need Claude Code, a jj repository, Matt Pocock's skills (for the spec, tdd, and grilling), and your repository's test and check commands.

Install from a local checkout:

claude plugin marketplace add /path/to/cairn
claude plugin install cairn@cairn

In the repository you want to work on, ignore .scratch/ and run:

/cairn:setup

Setup discovers how the repository's engineers run tests and checks, runs each suite to confirm cairn can read its output, and walks you through the configuration before writing .scratch/cairn.conf. You do this once per repository.

Configuration, plans, and reports stay untracked under .scratch/. Application code and tests go in the repository's normal locations. cairn uses your existing test and check commands unchanged; it reads the same printed output you see.

Supported test runners are nextest, libtest (cargo test), and vitest. Setup leaves out suites whose output it cannot read and explains why. During a build, unrecognized output or an incomplete test run stops cairn rather than being counted as a pass. For example, cargo test can stop after the first failing test binary; adding --no-fail-fast to your repository's task lets the remaining binaries run.

The configuration keys are documented in scripts/lib/config.sh.

Example configuration: a mise monorepo with Rust and TypeScript

For Rust API, CLI, and bridge crates plus a TypeScript web client, setup might produce:

suite.api.cmd=mise test api
suite.api.runner=nextest
suite.cli.cmd=mise test cli
suite.cli.runner=libtest
suite.bridge.cmd=mise test bridge
suite.bridge.runner=libtest
suite.web.cmd=mise test web
suite.web.runner=vitest
check.api=mise check api
check.cli=mise check cli
check.bridge=mise check bridge
check.web=mise check web
check.rustfmt=cargo fmt --all --check
check.biome=bun run --cwd web check
test_glob=**/*_test.rs
test_glob=**/tests/**
test_glob=**/*.test.ts
test_glob=**/*.test.tsx
config_glob=.config/nextest.toml
config_glob=Cargo.toml
config_glob=mise.toml
config_glob=**/biome.json
config_glob=**/vitest.config.ts
config_glob=**/vite.config.ts
config_glob=**/tsconfig*.json
suppress=#[ignore]
suppress=#[allow(
suppress=.skip(
suppress=.only(
suppress=biome-ignore
suppress=@ts-ignore
suppress=@ts-expect-error
generated=server/queries/**
generated=web/src/routeTree.gen.ts

Setup can run in any session. Afterwards, use /clear or start a fresh session before planning.

Build a milestone #

1. Prepare the spec and milestones #

Use Matt Pocock's /to-spec workflow to settle what you want to build, then invoke /cairn:to-milestones to divide the spec into milestones you approve. Milestones describe observable behavior; the individual slivers are chosen later, during the build.

Clear the session after this step, before researching each milestone.

2. Research and settle the design #

Run /cairn:research for the milestone's ticket. A researcher examines the code through questions that hide the feature's goal, helping keep its answers grounded in what exists. The result is saved as research.md.

Continue in the same session with /cairn:design. It records criteria, shared interfaces, test boundaries, compatibility, and risks in design.md. New decisions are taken to you one at a time, followed by a walkthrough of the design. You can request changes, and cairn may recommend an optional adversarial review before you approve it. The portion you review is limited to 200 lines.

Keep research and design together: the design builds on that conversation. After approval, start a fresh session for the build.

3. Run the build #

Invoke /cairn:run with the ticket or its cairn folder. It chooses and builds slivers until the milestone's criteria hold, subject to the stopping rules below. Start with a clean jj working copy: unfinished changes outside .scratch/ make the run stop before building.

If you want to watch one risky sliver, use /cairn:build instead. It builds and reviews one sliver, then leaves it unsealed for you to review and seal. Once the working copy is clean again, run or build can pick up the next sliver.

The run finishes with a conversational overview: what was built, why the slivers came in that order, the detours, and what remains for you. Its detailed report is saved as runs.md.

4. Review for bugs #

The run's reviewers judge each sliver against its plan, the design, and your standards, not for runtime bugs. In a fresh session, run /cairn:review-slivers with the ticket or its cairn folder. It runs Claude Code's built-in /code-review over every sliver, then walks you through its findings, the milestone review's, and any design conflicts the run collected. Each fix you accept is made inside the sliver it belongs to, and every sliver above it is gated again and repaired in place if a fold broke it.

5. Review and revise #

Review the slivers in your forge. To apply a review comment, start a fresh session and use:

/cairn:revise <folder> S<N> <comment>

revise is beta. It folds the fix into that sliver and re-checks the changes above it. When later slivers fail or conflict, it discards those slivers and directs you back to run to choose and build replacements.

Workflow artifacts live under .scratch/, so a fresh build or revision session can read the files it needs. Revision needs the folder, sliver id, and your pasted comment.

What cairn checks #

For each sliver, a planner chooses one reviewable claim and writes its plan. When new tests are needed, a separate test writer makes them fail on their assertions before the builder implements the change. Those tests are then locked: the builder cannot weaken them to make the code pass.

Automated checks compare results with the run's initial baseline, verify the locked tests, and check the change's size and files. Fresh reviewers then check two things in order: whether the change correctly delivers its claim, and whether it follows the repository's standards. The driver—the main conversation coordinating the workers—seals a passing sliver with a jj description and starts the next change.

Reviewers judge a saved patch against the plan, without the builder's account of its work. Findings are checked against the code they quote before they can trigger a fix.

Technical details: the per-sliver checks
Step Who Required result
Choose and plan Planner One claim advancing a criterion or preparing its next step; a plan within 200 lines, or complete
Red, when the plan names test cases Test writer, red-check.sh The suite builds, every new test fails, and no other failure is new relative to the baseline
Green Builder Reports built; tests remain locked
Gate baseline.sh, locked-tests.sh, size.sh, driver No new test or check failures; locked tests unchanged; nonempty diff within the size ceiling and planned files or recorded deviations
Spec review Spec reviewer, verdict.sh, quote-check.sh The change delivers its entry correctly, with evidence and actionable quoted findings
Standards review Standards reviewer, same scripts The change follows repository standards and the smell baseline
Seal, under run Driver jj describe, then jj new

When the plan names no new test cases, the baseline or the plan's safety script provides the proof. See the run skill for the full driver protocol.

When a run stops #

A failing gate or review gets one fix attempt by a fresh builder; a second failure stops the run with a diagnosis. Findings that show the plan or design is wrong stop the run for a decision instead of sending the builder around again.

A required restructuring that preserves behavior can be inserted as a prefactor sliver. This is limited to one level: an inserted tidying that needs another prerequisite stops the run. Missing design decisions also stop it, with a proposed amendment or a proposal to drop the milestone. Milestones are never added during a run.

Every run stops after 15 slivers, including inserted ones, even if criteria remain. This is a checkpoint: the run reports which criteria hold and what's left, you can review the slivers so far, and rerunning continues the same milestone. Work is left for inspection when a run stops for any other reason; approve any necessary design amendment before resuming. Infrastructure failures such as API errors are reported for a later retry.

Checks across the whole milestone #

When the planner reports completion, a fresh criteria auditor checks each built criterion's literal wording against the whole milestone. Criteria requiring a production action are reported with who must perform them and how to confirm the result; cairn leaves those actions and checkboxes to the operator.

A fresh milestone reviewer then looks for problems visible only across slivers. Its findings each name their owning sliver and wait for /cairn:review-slivers, which settles them with you and fixes each inside that sliver.

Permissions and recovery #

Only the driver receives permissions to change jj state, and only within three skills:

Skill Granted commands
/cairn:run jj describe, jj new, and jj restore to discard an attempt before inserting a tidying
/cairn:revise jj new, jj squash --into, jj abandon
/cairn:review-slivers jj new, jj squash --into, jj abandon

The grants live in each skill's allowed-tools frontmatter and apply to its invocation, never to worker agents. Claude Code applies those only to the invoking turn, so each skill also writes .scratch/cairn-grant, naming its session, and the guard hook allows the same commands in that session's later turns until the skill deletes it. Your deny and ask rules still take precedence; you do not need a repository-wide allow rule for jj describe or jj new.

The guard hook denies VCS mutations inside cairn workers and prevents the builder from writing to current locked tests or check configuration. It denies only inside cairn:* workers; in the main conversation it only allows a running skill's grant. The locked-test verification also checks changes after the builder returns.

For unattended runs, allow your repository's test commands and cairn's scripts in your settings, or use auto mode; otherwise a run can wait for a permission prompt.

The driver records the starting jj operation id. To restore VCS state to that point, you can run jj op restore <id> yourself. Workflow artifacts under .scratch/ are untracked.

Choose the session model #

Worker agents pin Opus 5.5 in their frontmatter. run, build, and revise also pin their driver to Opus 5.5 at medium effort for their turn, and review-slivers pins Opus 5.5 at high effort for the turn that runs /code-review. For conversational planning skills, set the session model yourself because their conversation spans multiple turns.

Skill Session model and effort
/cairn:to-milestones, /cairn:research, /cairn:design Opus 5.5, high effort
/cairn:setup Opus 5.5, default medium effort
/cairn:review-slivers Opus 5.5, default medium effort; the skill pins Opus 5.5 at high for the review
/cairn:run, /cairn:build, /cairn:revise Any; the skill pins its own model and effort

Current per-role settings and the model-selection rationale are in DECISIONS.md.

Contributing and repository layout #

Read AGENTS.md for contributor guidance and DECISIONS.md for settled design choices and their rationale. TODO.md holds candidates for future improvements.

Path Contents
skills/ User-invoked workflows; run contains the driver that build and revise also follow
agents/ Planner, test writer, builder, spec and standards reviewers, criteria auditor, milestone reviewer, researcher, question auditor
hooks/hooks.json Connects Bash and file-edit tools to the guard
scripts/ Output parsers and gates: test-results.sh, baseline.sh, red-check.sh, locked-tests.sh, verdict.sh, quote-check.sh, guard.sh, size.sh, paths.sh; headers document usage and exit codes
reference/ Shared vocabulary, smell baseline, change-message rules, optional design review commands, driver setup and reporting instructions, and worked examples
prompts/ The optional adversarial design review prompt
tests/ Plain Bash script tests and captured runner output in tests/fixtures/
evals/ Model-driven evaluations in throwaway repositories; see the evaluation guide for commands, cases, and billing details
.claude-plugin/ Plugin and marketplace metadata