~/groundwork

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.

CommandWhat it does
initInstall Groundwork in this project
briefPrint what a session needs to resume
checkpointSave the handoff
statusShow where things stand
decideRecord a decision
lessonRecord a lesson
indexRebuild the decisions index
workerTrack parallel workers
compactArchive old memory
doctorCheck the install and the memory
upgradeUpdate Groundwork's files
adapter addAdd or refresh a tool's files
flowTurn the optional flow on or off
uninstallRemove Groundwork
mode, check, reassess, migrate, retroFlow 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
FlagEffect
--adapter claude-code|opencode|codex|cursor|gemini|noneSkip the question. Several with commas: --adapter claude-code,codex. none stands alone
--flowAlso install the flow
--dry-runShow 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
FlagEffect
--jsonThe same, machine-readable
--budget <tokens>Override budgets.brief (1,500) for this run
--worker <id>Brief that worker's handoff
--rootUse the root handoff even where a worker's would be chosen

The first line is the verdict:

VerdictMeaning
freshWritten at the current commit
behindCommits landed since; they are listed with the files they changed
divergedIts commit isn't in this branch's history, or no longer exists
staleOlder than staleAfterDays (14)
unstampedNever 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"
FlagEffect
--now, --next, --blockers, --failing, --workers, --notesReplace 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
--rootWrite the root handoff even where a worker's would be chosen
--tool, --model, --sessionSay who is writing (or set GROUNDWORK_TOOL, GROUNDWORK_MODEL, GROUNDWORK_SESSION)
--jsonPrint 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 status
Now:           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 index

worker

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
SubcommandEffect
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
WhatGoes to
Journal entries beyond budgets.journal, oldest firstarchive/JOURNAL-<year>.md
Superseded decisions, every runarchive/decisions/
Handoff sections Groundwork doesn't definearchive/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
CheckWhat it looks at
HandoffIts stamp, its Now and Next sections, and the verdict. Behind is a suggestion, not a problem
Memory filesEach against its budget; DECISIONS.md in step; MAP.md filled in, naming paths that exist
BriefIts size against budgets.brief
Always loadedAn estimate (characters ÷ 4) of AGENTS.md, CLAUDE.md and your tool's skill and subagent lists, against tokenBudget
LessonsLessons cited nowhere; rules in AGENTS.md with no lesson ID
InstallA 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
VersionProject files older than the CLI
Claude CodeA version older than 2.1.295, which the flow's guard needs
Flow onlyThe 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
FlagEffect
--dry-runPreview
--yesDon't ask. Needed where there is no terminal
  • Your handoff, map, decisions, lessons, journal, spec, cards, evidence, rules, AGENTS.md, CLAUDE.md and 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, gemini

flow

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 off

off 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
FlagEffect
--dry-runPreview
--keep-stateKeep .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-card

See 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 check

A 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-card mode, a done card's History has the "approved by human" line (not needed with integration: "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
FlagEffect
--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 --yes

Cards 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

On this page