CLI reference
Every groundwork-ai command, its flags and an example.
Run any command with npx groundwork-ai <command>. Needs Node.js 22 or later.
--version prints the version; help prints usage.
| Command | What it does |
|---|---|
init | Install Groundwork in this project |
brief | Print what a session needs to resume |
checkpoint | Save the handoff |
status | Show where things stand |
decide | Record a decision |
lesson | Record a lesson |
index | Rebuild the decisions index |
worker | Track parallel workers |
compact | Archive old memory |
doctor | Check the install and the memory |
upgrade | Update Groundwork's files |
adapter add | Add or refresh a tool's files |
flow | Turn the optional flow on or off |
uninstall | Remove Groundwork |
mode, check, reassess, migrate, retro | Flow only |
init
Installs project memory: .groundwork/, AGENTS.md and your tool's files. Existing AGENTS.md and
CLAUDE.md are appended to, never replaced.
npx groundwork-ai init| Flag | Effect |
|---|---|
--adapter claude-code|opencode|codex|cursor|gemini|none | Skip the question. Several with commas: --adapter claude-code,codex. none stands alone |
--flow | Also install the flow |
--dry-run | Show what would change, write nothing |
brief
Prints what an agent needs to resume: the handoff, how fresh it is, the decisions in force, rules and the map. Read-only. The session-start hook prints the same text.
npx groundwork-ai brief| Flag | Effect |
|---|---|
--json | The same, machine-readable |
--budget <tokens> | Override budgets.brief (1,500) for this run |
--worker <id> | Brief that worker's handoff |
--root | Use the root handoff even where a worker's would be chosen |
The first line is the verdict:
| Verdict | Meaning |
|---|---|
fresh | Written at the current commit |
behind | Commits landed since; they are listed with the files they changed |
diverged | Its commit isn't in this branch's history, or no longer exists |
stale | Older than staleAfterDays (14) |
unstamped | Never checkpointed |
Commits that only touch .groundwork/ don't count.
checkpoint
Saves the handoff. You write the prose; the command stamps time, commit, branch and writer, adds a journal entry from git, and keeps the decisions index in step.
npx groundwork-ai checkpoint --now "Login form renders; validation not wired" --next "Wire validation in src/login.ts"| Flag | Effect |
|---|---|
--now, --next, --blockers, --failing, --workers, --notes | Replace that section; the others keep their text |
--note "<text>" | Add a journal entry with this note, even with no new commits |
--worker <id> | Write that worker's handoff |
--root | Write the root handoff even where a worker's would be chosen |
--tool, --model, --session | Say who is writing (or set GROUNDWORK_TOOL, GROUNDWORK_MODEL, GROUNDWORK_SESSION) |
--json | Print the result as JSON |
- With no section flags it stamps the file as it is: edit the handoff, then run
checkpoint. - It refuses to stamp a handoff nobody has written.
- It warns if another session stamped the same handoff in the last 30 minutes.
- The hooks run it automatically when a turn ends, before a compaction and at session end. An
automatic checkpoint doesn't restamp a handoff nobody touched, so that one stays
behind.
status
Prints the handoff's Now and Next, its verdict and the workers in flight. Read-only.
npx groundwork-ai statusNow: Login form renders; validation is not wired to the API
Next step: Wire validation in src/login.ts, then add the first test
Handoff: behind: 2 commits landed after it was written, changing 3 files (.groundwork/HANDOFF.md)With the flow on it adds the phase, the current card, and cards by status, ready and blocked.
decide
Creates the next numbered record in .groundwork/decisions/ and updates the index.
npx groundwork-ai decide "Use SQLite for storage" --status accepted--status is proposed (default), accepted or superseded.
lesson
Adds the next L-NNN entry to .groundwork/LESSONS.md.
npx groundwork-ai lesson "Run migrations before the test suite" --origin "tests failed on a stale schema"--level is NOTE (default) or RULE.
index
Rebuilds .groundwork/DECISIONS.md from the records. --check exits 1 when it is out of step.
npx groundwork-ai indexworker
Tracks parallel workers. Run it from the main checkout.
npx groundwork-ai worker start auth-tests --goal "Write the auth test suite" --branch feat/auth-tests
npx groundwork-ai worker done auth-tests --outcome "accepted: 14 tests rerun, merged"
npx groundwork-ai worker list| Subcommand | Effect |
|---|---|
start <id> [--goal] [--branch] | Adds the worker to Workers in flight and to .groundwork/work/LEDGER.md |
done <id> [--outcome] | Takes it out, logs the outcome, marks its handoff done |
list [--json] | Lists worker handoffs. The text output also lists workers started but not yet saved |
Each worker saves to .groundwork/work/<id>/HANDOFF.md. In a linked git worktree that is chosen
automatically; elsewhere pass --worker <id> to checkpoint and brief.
compact
Moves old material to .groundwork/archive/. Nothing is deleted. --dry-run previews.
npx groundwork-ai compact| What | Goes to |
|---|---|
Journal entries beyond budgets.journal, oldest first | archive/JOURNAL-<year>.md |
| Superseded decisions, every run | archive/decisions/ |
| Handoff sections Groundwork doesn't define | archive/HANDOFF-<date>.md, with the whole previous handoff |
doctor
Checks the install and the memory. Exits 1 on a problem, so it can run in CI.
npx groundwork-ai doctor| Check | What it looks at |
|---|---|
| Handoff | Its stamp, its Now and Next sections, and the verdict. Behind is a suggestion, not a problem |
| Memory files | Each against its budget; DECISIONS.md in step; MAP.md filled in, naming paths that exist |
| Brief | Its size against budgets.brief |
| Always loaded | An estimate (characters ÷ 4) of AGENTS.md, CLAUDE.md and your tool's skill and subagent lists, against tokenBudget |
| Lessons | Lessons cited nowhere; rules in AGENTS.md with no lesson ID |
| Install | A broken config.json, a hook or guard script that won't load, a missing hook, adapter files that drifted, a CLAUDE.md that doesn't load AGENTS.md |
| Version | Project files older than the CLI |
| Claude Code | A version older than 2.1.295, which the flow's guard needs |
| Flow only | The check rules, cards over about 1,500 tokens, long History or Evidence lines, evidence saved as UTF-16, and what /gw and each role load at startup |
upgrade
Updates Groundwork's own files to this version, after asking once.
npx groundwork-ai upgrade| Flag | Effect |
|---|---|
--dry-run | Preview |
--yes | Don't ask. Needed where there is no terminal |
- Your handoff, map, decisions, lessons, journal, spec, cards, evidence, rules,
AGENTS.md,CLAUDE.mdand config values are never touched. - A Groundwork file you edited is kept; the new version is saved next to it as
<file>.new. - New config keys are added.
- A 1.x project keeps the flow on. See Upgrading from 1.x.
adapter add
Adds or refreshes one tool's files. Use it when you switch tools or want a second one. It asks before overwriting.
npx groundwork-ai adapter add opencode # or claude-code, codex, cursor, geminiflow
Shows whether the optional flow is on, and turns it on or off.
npx groundwork-ai flow
npx groundwork-ai flow on
npx groundwork-ai flow offoff removes Groundwork's flow files and keeps your spec, cards, evidence and rules. Only you can
run it: the agent is refused. Without a terminal, pass --yes.
uninstall
Removes what Groundwork added and keeps anything you changed.
npx groundwork-ai uninstall| Flag | Effect |
|---|---|
--dry-run | Preview |
--keep-state | Keep .groundwork/ without asking |
It removes unchanged adapter files, Groundwork's hook entries, the lines it added to AGENTS.md
and .gitattributes, and a CLAUDE.md it wrote. Then it asks once before deleting
.groundwork/; the default is to keep it.
mode
Flow only. Shows or changes when you approve. You run it; the agent can't loosen approval.
npx groundwork-ai mode # show
npx groundwork-ai mode per-phase # or per-cardSee Approval modes.
check
Flow only. Checks cards against the flow's rules and exits 1 when one breaks them. Read-only.
/gw-approve, the commit gate and CI rely on it.
npx groundwork-ai check # every card
npx groundwork-ai check 1.2 # one card
npx groundwork-ai check --task 1.2 --base origin/main # team context checkA card passes when:
- its status is real, and every status change in its History is allowed
- waiting for approval or done, it has Evidence, every linked file exists and isn't empty, and
every criterion is ticked or gives its reason (
- [ ] <criterion> — <why>) - in
per-cardmode, a done card's History has the "approved by human" line (not needed withintegration: "pr", where pull-request review is the approval) - it is within the size limit, about 1,500 tokens
--base <ref> also reports branch freshness and context changes for tasks that have
.groundwork/work/<id>/context.json.
reassess
Flow only. Records the versions of the decisions and spec a task has just been checked against, in
.groundwork/work/<id>/context.json. Run it after reading the change and reconciling the code and
card. It runs no tests.
npx groundwork-ai reassess 1.2 --target origin/main --dep decision:0001| Flag | Effect |
|---|---|
--target <ref> | The upstream ref it was checked against |
--dep <ref> | Add a dependency. The first run needs at least one |
--drop <ref> | Remove a dependency, such as one missing locally |
migrate
Flow only. Records done cards that Git shows predate the approval rule, so they aren't failed for a missing approval line. Evidence and the other rules still apply, and a recorded card loses the exemption if it changes.
npx groundwork-ai migrate legacy --dry-run
npx groundwork-ai migrate legacy --yesCards whose history Git can't show are listed under review. Check each is old work, then add
--reviewed. The agent can't run migrate.
retro
Flow only. Writes .groundwork/retro.md: reverts, fixes soon after a card, rejections, send-backs,
judgment calls later rejected, and a count per lesson cited. It only reports; gw-retro proposes
the changes, with your OK.
npx groundwork-ai retro