@pmelab/gtd 9.10.3 → 9.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +47 -1600
  2. package/dist/gtd.bundle.mjs +1011 -3016
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -7,11 +7,41 @@
7
7
 
8
8
  **gtd** is a git-aware CLI that derives the entire agentic workflow — capture,
9
9
  plan, build, check, review — from your repository state, and prints the next
10
- prompt for whatever agent you point at it. Every turn is a commit. The test
11
- command is printed for your driver to run, and the branch is decided by what the
12
- run leaves in the tree — so the agent never grades its own homework.
10
+ prompt for whatever agent you point at it. Every turn is a commit, so the
11
+ process survives a crash, a reboot, or a week away, and travels with the branch
12
+ to any machine that checks it out.
13
13
 
14
- No chat scrollback. No lost sessions. No infinite fix loops. Just git.
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install -g @pmelab/gtd
18
+ ```
19
+
20
+ Or run without installing (prefix every `gtd` below with `npx`) — see
21
+ [Configuration](https://github.com/pmelab/gtd/blob/main/docs/configuration.md)
22
+ for the settings most projects tune.
23
+
24
+ ## First run
25
+
26
+ Paste this into your coding agent:
27
+
28
+ ```
29
+ !gtd install
30
+ ```
31
+
32
+ It prints a self-contained briefing that teaches the agent to set the project
33
+ up, build two commands for itself in whatever shell or runtime it runs, and ask
34
+ you what you want before it starts driving. You get one prompt to paste, not a
35
+ state name to choose. The two commands: a **loop command** that drives beats
36
+ until the process rests, and an **edit command** that opens the steering file
37
+ the process is waiting on right now — falling back to `.gtd/TODO.md` when the
38
+ resting state declares none. That fallback is also how you begin: on a clean
39
+ repository the edit command opens the empty `.gtd/TODO.md`, and whatever you
40
+ write there is the first sketch the whole process gets planned from.
41
+
42
+ Writing a driver by hand instead? See
43
+ [Driving the loop](https://github.com/pmelab/gtd/blob/main/docs/driver.md) for
44
+ the full protocol and a complete minimal reference implementation.
15
45
 
16
46
  ## Why
17
47
 
@@ -28,1614 +58,31 @@ No chat scrollback. No lost sessions. No infinite fix loops. Just git.
28
58
  - **Harness agnostic.** gtd emits prompts to stdout (or JSON). Claude Code, a
29
59
  bash loop, a CI job, or you reading it out loud — the workflow doesn't care
30
60
  who executes it.
31
- - **Bounded, not runaway.** A check/fix loop's fix attempts are capped per red
32
- episode (`retry` on a state) — the count resets once the process moves on and
33
- a later red starts fresh. When the cap is hit, gtd redirects to a human gate
34
- instead of burning tokens rewriting the same test for the 47th time. Not every
35
- loop in the bundled workflow carries a cap, though: the per-package
36
- spec-review loop has none, and spins until it's satisfied.
37
- - **Your call on history.** Every intermediate `gtd(actor): from → to` commit is
38
- a real, attributed commit — the subject names both the state the work was done
39
- in and where it advanced to, nothing hidden in chat. Squash them into one
40
- conventional commit if you want that (an interactive rebase, an amend, a PR's
41
- squash-merge, or a custom workflow with a `commit:` finale), or don't — gtd
42
- makes no assumption.
43
-
44
- ## Install
45
-
46
- ```bash
47
- npm install -g @pmelab/gtd
48
- ```
49
-
50
- Or run without installing (prefix every `gtd` below with `npx`):
51
-
52
- ```bash
53
- npx @pmelab/gtd next
54
- ```
55
-
56
- That's it — gtd ships the **unified** workflow as its **built-in default**, so a
57
- state command works out of the box with no configuration at all.
58
-
59
- Optionally, seed the settings a project usually tunes — run once:
60
-
61
- ```bash
62
- gtd init
63
- ```
64
-
65
- This writes a minimal `.gtdrc.json` seeding the one variable most projects
66
- change — the test command (`vars.testCommand`, defaulting to `npm test`) — plus
67
- a top-level `modes:` block suggesting **Prettier** as the steering-file
68
- formatter (`npx prettier --write` for the built-in `qa`/`review` modes — format
69
- only, so gtd still validates them); edit or drop either freely (point
70
- `testCommand` at your suite, swap Prettier for dprint or a script, delete a
71
- key). It writes **no** `workflow:` key — the machine is built in — so review and
72
- commit the file before your first `gtd land`. `gtd init` takes no argument and
73
- refuses to clobber an existing config; it may also run in a plain parent
74
- directory (not a git repo) to seed a shared config a nested repo picks up. To
75
- customize the machine itself, add a `workflow:` key (there is no default
76
- fallback to merge over — a `workflow:` is the whole definition).
77
-
78
- gtd requires a repository with **at least one commit** before any state command
79
- (`land`, `--entry`, `next`, `status`, `abandon`, `restore`, `validate`) will run
80
- — there is no workflow state to derive from an empty history. Committing the
81
- `.gtdrc.json` above (or anything else) satisfies this by construction;
82
- `gtd init`, `gtd install`, `gtd lsp`, `gtd visualize`, and `gtd check` are
83
- unaffected since none of them derive workflow state.
84
-
85
- ## How it works
86
-
87
- gtd is a small **pattern machine**: named states, each awaiting one actor and
88
- carrying one piece of content (a script, a prompt, a message, or a squash commit
89
- template), with an ordered set of change-patterns routing to the next state.
90
-
91
- The loop is one beat, repeated: run `gtd next --json` and dispatch on `kind` —
92
- `"message"` means it's a human's move (stop and hand off, unless it's the run's
93
- opening beat, which the human triggered by re-running the driver: land that one,
94
- since changing nothing is itself a declared outcome at some gates); `"capture"`
95
- means a human gate the human already acted on (land it immediately); `"script"`
96
- means the driver runs `gtd next`'s own plain-text output itself, then lands it;
97
- `"prompt"` means feed `gtd next`'s output to your agent — using the accompanying
98
- `session.id`/`session.resume` fields off `gtd next --json` to continue or start
99
- that agent conversation (see "Driving the loop" below) — then run `gtd land`
100
- once it's done. gtd itself never executes anything — the driver owns running
101
- scripts. Every `gtd next` call is strictly mutation-free, safe to poll or peek
102
- at any time: `session.id`/`session.resume` are DERIVED, never stored, so looking
103
- is free — nothing distinguishes a peek from a dispatch, and there is no separate
104
- claiming form at all. A `prompt` beat whose turn changes nothing still lands:
105
- `gtd land` commits an EMPTY `gtd(<actor>): <state>` attempt instead of silently
106
- doing nothing, so the fruitless dispatch is visible in history rather than
107
- invisible. `"kind": "stalled"` is derived from that history — HEAD is an empty
108
- attempt at the resting state and the tree is clean — so every `gtd next --json`
109
- call reports it, and it stays reported on a repeat (there's no marker to
110
- consume) until something actually changes. The fix for a repeated stall is
111
- either a better prompt, a `retry:` cap on the state that redirects to an
112
- escalation state after N fruitless attempts, or — if the state can legitimately
113
- finish with nothing to change — declaring a `C` (clean-tree) pattern on it.
114
-
115
- An `on` edge may also carry a short imperative `action` (e.g. `Accept plan`)
116
- alongside its existing `describe` sentence — a human-facing name for the choice
117
- itself, not just the underlying glob pattern. `gtd next` (plain and `--json`)
118
- and `gtd visualize`'s diagram and inspector all render the two composed
119
- together: the `action` leads when the edge declares one, with the raw pattern
120
- (and `describe`) still shown alongside it, so a human choosing between routes
121
- reads intent first, glob second.
122
-
123
- **Your input is a spec, not the work.** The unified workflow treats ANY change
124
- to the tree — a hand-edit to real code, a scratch note in some file, anything at
125
- all — as a sketch to be finished, never as work to be preserved: there is no
126
- fork on which steering file you happen to create, and `idle` has exactly one
127
- outgoing edge, into `unwind`. `.gtd/TODO.md` is a good default place to start
128
- sketching when you'd rather write a note than touch code — despite living beside
129
- the workflow's own state files, that sketch is your input for `design.triage` to
130
- fold in, never gtd bookkeeping to preserve or ignore. `unwind` reverts that
131
- whole diff back out of your working tree (`git revert --no-commit` against the
132
- commit it just landed in) before planning ever starts — your tree is back to
133
- exactly what it was, and your intent doesn't disappear, it survives in history
134
- for `design.triage` to read.
135
-
136
- From there, `start-gate.check` runs your test suite on the tree as it now stands
137
- — which, thanks to the unwind, is simply your repo's own baseline. The rule is
138
- the plain one: the baseline must be green. A red run halts the process and tells
139
- you to repair it first (that's what `gtd --entry fix-precheck` is for);
140
- `review-gate` follows the same rule.
141
-
142
- Once past the gate, `design.triage` reads the diff that started the process
143
- itself — the prompt never inlines it; it finds the entry commit (the one
144
- `unwind` reverted) and runs `git show` against it — and groups that diff into an
145
- ORDERED list of **concerns**, each one able to leave the test suite green on its
146
- own, classifying each as **product** (a user-facing/requirements decision) or
147
- **technical** (an implementation decision). A concern's open point clears a
148
- three-part bar before it's ever raised as a question: the answer must be a
149
- genuine fork with divergent outcomes, the sketch/entry diff/history must not
150
- already settle it, and getting it wrong must survive all the way to human
151
- review. Anything below that bar — product or technical alike — triage decides
152
- itself, recording the decision and a one-line rationale under
153
- `## Answered Questions`, the same section a human-answered question lands in;
154
- only a product point that clears the bar is raised as an open question in
155
- `.gtd/REQUIREMENTS.md` (a technical point that clears it waits for the
156
- architecture phase to raise it), folding EVERYTHING the entry commit added into
157
- those concerns — a scratch sketch and a hand-edited code change alike, since the
158
- unwind already reverted both; nothing is left to delete. When every concern
159
- turns out to be technical, triage writes no `## Open Questions` section at all.
160
- A shared check+answer gate then probes `.gtd/REQUIREMENTS.md` for unanswered
161
- questions: each open question offers a couple of candidate answers plus a
162
- `- [ ] _your answer_` slot, and you tick exactly one per question (the gate
163
- won't let the phase advance while any question is unanswered) — but a phase
164
- whose document has no open questions skips that human stop entirely and falls
165
- straight through. If a question's options ever come out as prose instead of
166
- `- [ ]` rows, there is no checkbox for the gate to see, so it stays permanently
167
- unanswered; un-wedge it yourself: hand-write the `- [ ]` rows and tick one,
168
- delete that question, or delete the whole `## Open Questions` section to accept
169
- the plan as-is.
170
-
171
- Once the product questions are settled, `architecture.author` picks up as a
172
- **cold reader** — a separate machine with its own memory scope, so it does not
173
- resume the triage conversation but reads `.gtd/REQUIREMENTS.md` in full (cold
174
- means no memory of that conversation, never no git access — it finds and reads
175
- the entry commit from history exactly as triage did) — and develops the _how_
176
- for each settled concern. Because it is the first state that knows the _how_, it
177
- is also the one state allowed to re-merge concerns whose file footprints
178
- coincide (never split), recording every merge under a `## Merged Concerns`
179
- heading. The same three-part bar applies to every technical point here too: only
180
- one that clears it is raised as an open question in `.gtd/ARCHITECTURE.md`;
181
- everything below the bar, author decides itself and records under
182
- `## Answered Questions` right alongside triage's own settled points, all of
183
- which author treats as SETTLED regardless of whether they're product or
184
- technical. Open questions are routed through that same shared check+answer gate
185
- shape, again skipping the human stop when nothing is open, and
186
- `.gtd/REQUIREMENTS.md` is deleted once its content is folded in. A process where
187
- nothing ever clears the bar runs both phases straight through with no human stop
188
- at all — the existing review tail, which sees the whole diff anyway, is the
189
- veto. Once those are settled, `architecture.decompose` is a purely mechanical
190
- write-out — **one package file per concern**, in the settled order, with no
191
- merge/split judgement of its own (triage grouped the concerns, and
192
- `architecture.author` may already have re-merged some of them by file footprint)
193
- — handing off to the per-package build queue: each package (a set of independent
194
- tasks a single build turn fans out to parallel subagents) runs its own test loop
195
- and a per-package **agentic review** that verifies it against its own spec. A
196
- package whose work already landed (an earlier package's fix turn pulled it in)
197
- is not a dead end: the build turn records per-criterion evidence in
198
- `.gtd/SATISFIED.md` instead of implementing anything, and the package still goes
199
- through the checks and the spec review before closing out. If a queue item ever
200
- _does_ dead-end (a build turn that authors nothing stalls), the supported
201
- recovery is to write that same file yourself and `gtd land` — no hand-authored
202
- state commit.
203
-
204
- The process converges on that same shared tail: an agent hands you a
205
- `.gtd/REVIEW.md` checkbox review of the diff — the prompt never inlines the diff
206
- itself; it names the commit the changes are based at and the agent runs
207
- `git diff` to read the range before writing the review. Each hunk is a
208
- `- [ ] ./path/to/file.ts#42` pointer, and its explanation can either trail the
209
- pointer on the same line after a dash or sit on the line(s) below it — both
210
- forms are equally valid, but the same-line form is the reflow-proof one, since a
211
- continuation line has to be indented exactly two spaces (four or more, after a
212
- blank line, reads as an indented code block and never reflows):
213
-
214
- ```
215
- - [ ] ./path/to/file.ts#42 — what this hunk does, with room to run to
216
- several lines
217
- - [ ] ./path/to/file.ts#99
218
- a note on the line below the pointer works too
219
- ```
220
-
221
- The one rule an explanation must follow either way: it must never itself START
222
- with a bare `./path` token, since that parses as a second hunk pointer rather
223
- than a note. If a styled `.gtd/REVIEW.md` ever comes out malformed some other
224
- way (a paragraph where a `- [ ] ./path#line` row belongs), `gtd check review`
225
- refuses the step the same way: the file stays exactly as written in the working
226
- tree, unlanded, and re-running the same prompt is the recovery — nothing is
227
- lost. While the process rests at that gate, the landing script opens a **review
228
- checkout window**: HEAD is rewound to the review base with the working tree
229
- untouched, so the whole reviewable change shows up as ordinary uncommitted
230
- changes in your editor's normal git integration (and files added during the
231
- process show up as ordinary untracked files, so discarding one deletes it — an
232
- untracked file you leave alone is not a pending change, and only actually
233
- removing it from disk counts as a deletion). The next landing's own script
234
- closes the window before it commits. Tick a box as you review each hunk (ticking
235
- just records "I read this"), and leave a **comment** to request changes: a note
236
- on a line, an inline `// TODO`-style comment in the code, or a direct code edit.
237
- A comment sends a FULL development lap, not a quick fix-and-re-review: an agent
238
- first judges whether your comment is actually actionable (a genuinely approving
239
- remark with no code edit short-circuits straight to sign-off instead), and an
240
- actionable round is re-planned from scratch through triage, architecture, and
241
- the package queue again — a hand-edit you made during review is treated as a
242
- **sketch**, the same as any other change that starts a process, not a fix the
243
- agent builds on: it is reverted out of the tree first, and your intent survives
244
- only in your own review-round commit for triage to read. There is no baseline
245
- check on the way back into planning. Only the turn that drafts the final squash
246
- message resumes the session that built the feature in the first place (the
247
- review tail is nested inside that build identity rather than sitting beside it)
248
- — an actionable round leaves that identity entirely, so it starts a fresh
249
- session like any other process. A comment is what asks for changes; landing with
250
- no comment signs off, whatever the boxes say, which collapses the whole process
251
- into one commit (a **squash finale** whose message an agent drafts). Deleting
252
- `.gtd/REVIEW.md` is refused — the guard only asks whether the step's diff
253
- deletes the file.
254
-
255
- A second entry, the same review tail's own direct entry point —
256
- `gtd --entry review-gate.check --var reviewBase=<commitish>` starts a brand new
257
- process reviewing `<commitish>..HEAD` with no build of its own on a clean
258
- sign-off, e.g. a colleague's PR branch (`review-gate.check`'s `reviewBase:` is a
259
- template bound to the `reviewBase` var, so supplying it via `--var` fixes the
260
- whole process's diff base to that commitish) — though an actionable round on
261
- this entry runs the same full triage → gates → architecture → package-queue lap
262
- as any other, same as `re-unwind` re-plans a build process's own review
263
- feedback. A clean sign-off's squash keeps and describes only the fixes made
264
- _during_ the review (not the reviewed changeset); a clean sign-off with no fixes
265
- becomes an empty `chore: human review` commit. A third entry,
266
- `gtd --entry fix-precheck`, starts from a clean `idle` and goes straight into
267
- repairing a red baseline — repair, review, and squash into one commit. If the
268
- suite is already green there is nothing to fix, and the log is left untouched —
269
- no commit is left behind.
270
-
271
- `--entry` itself isn't limited to states flagged `entry: true` — it accepts
272
- **any** declared, non-commit state of the active workflow (see
273
- [`gtd --entry`](#commands) below). `entry: true` only marks a state as an
274
- _extra_ reachability root (and drives a badge in `gtd visualize`) for a state
275
- that would otherwise be unreachable from the ordinary `idle` rest —
276
- `review-gate.check` and `fix-precheck` need it for exactly that reason, while
277
- `start-gate.check` carries it too (the bundled template dedups its two
278
- `entryGate` instances — `start-gate` and `review-gate` — into one shared
279
- machine, so flagging the shared state flags both) even though `idle` already
280
- reaches it the ordinary way. `entry: true` is not a precondition for `--entry`
281
- to target a state.
282
-
283
- Every agent state routes its model through two `vars` tiers — `plannerModel`
284
- (heavier planning and review) and `coderModel` (the coding turns) — so you can
285
- repoint the models globally in one place (a `vars:` edit or a `GTD_PLANNERMODEL`
286
- override) instead of per state. Every steering file the bundled workflow reads
287
- or writes lives at a fixed path under `.gtd/`; `testCommand`, `plannerModel`,
288
- `coderModel`, and `reviewBase` are the only vars left to tune.
289
-
290
- To inspect or change the machine itself, see [Configuration](#configuration) —
291
- the workflow is just `.gtdrc` config.
292
-
293
- ## Commands
294
-
295
- ```
296
- Usage: gtd [command] [options]
297
-
298
- Commands:
299
- init Scaffold a minimal .gtdrc.json for this repo, seeding the
300
- default variables you are most likely to change (the test
301
- command) and a Prettier formatting suggestion. gtd runs its
302
- built-in workflow by default, so no workflow is written —
303
- add a workflow: key only to customize the machine itself.
304
- Takes no argument. Run once per repo; refuses if a gtd
305
- config already exists. Leaves the file uncommitted for you
306
- to review and commit
307
- land Land whatever the tree now shows at the currently resolved
308
- rest — a human capture, an agent/check turn, an empty
309
- attempt (a fruitless prompt turn), or a squash. Pass
310
- --cost=<n> (optionally --model=<name>) to record the
311
- just-finished invocation's token cost and model on the
312
- turn commit (summed into it.processCost/
313
- processCostByModel). Plain (the default) prints ONLY the
314
- script that records the landing; a driver runs it, e.g.
315
- `gtd land | sh`. --json/--sh instead emit script (that
316
- same script, byte-identical) alongside settled, idle,
317
- state (the post-land target), subject, cost and model —
318
- --json/--sh are mutually exclusive. Exits 0 on success, 1
319
- on any refusal — see the Exit codes section below
320
- (no command) --entry <state>
321
- Starts a new process authenticated as human, e.g.
322
- 'gtd --entry <state>'
323
- abandon End the process currently underway without completing it:
324
- close any open review checkout window, then rewind HEAD to
325
- the commit the process started from, keeping everything it
326
- produced as uncommitted changes. A no-op when no process is
327
- underway
328
- restore Hard-reset HEAD back to the pre-squash tip retained by the
329
- last squash/abandon (refs/worktree/gtd/history), undoing a
330
- squash or bringing back an abandoned process's turns.
331
- Refuses on a dirty working tree, when there is no retained
332
- history, or when HEAD has advanced past the squash with
333
- commits that would be lost
334
- next Print the resolved rest's beat (no mutation, safe to
335
- poll), in one of three encodings. Plain (the default): a
336
- status summary, a blank line, then the step verbatim —
337
- except at a prompt rest, which is the bare step (plus the
338
- self-validation instruction when applicable) with no
339
- header, since those bytes are the agent's own input. --json
340
- emits the one structured surface gtd has: kind
341
- (capture|message|script|prompt|stalled) selects what a
342
- driver does, content is what it runs or shows, idle marks
343
- the workflow's initial state with a clean tree, plus the
344
- prompt session, model, validate script, log path, changes,
345
- next and the resting state's own fields. --sh emits the
346
- same fields as gtd_-prefixed POSIX shell assignments.
347
- --json/--sh are mutually exclusive. Exits 0 — see the
348
- Exit codes section below
349
- validate Print the script that formats (when declared) then
350
- validates the resolved rest's steering file, using its
351
- mode's commands (its file:/mode:), instead of running it —
352
- a driver runs the script and reads the findings from its
353
- own exit code/output. Always exits 0; prints "nothing to
354
- validate" when the resolved rest declares nothing to run.
355
- On a non-zero validate exit the emitted script prints a
356
- ready-to-send fix prompt (instruction + findings) and
357
- exits with the validator's own code
358
- lsp Start the LSP server for .gtd/ steering files (stdio)
359
- visualize Serve an interactive diagram of the active workflow on a
360
- local web server (--port <n>, --no-open). Prints the
361
- chosen port on its own line — with --port 0, this is the
362
- only way to learn which port was picked
363
- check <mode> <file>
364
- Read <file> and run the built-in steering format named
365
- <mode> (see `gtd validate`'s modes: qa, review) over its
366
- contents, printing each finding one per line and exiting
367
- non-zero when there are any. Resolves no workflow state and
368
- reads no config — standalone, runnable from any directory
369
- with <mode>/<file> given explicitly. This is what a
370
- workflow's emitted validation script invokes as a leaf step.
371
- --open-questions runs the qa unanswered-questions predicate
372
- instead (see --help)
373
- install Print a complete, self-contained briefing that teaches an
374
- agent (or a human) to build a gtd driver in any shell or
375
- runtime — the self-serve version of README's 'Writing
376
- your own driver'. Writes nothing: this installs knowledge
377
- into the calling agent's context, not files on disk. Runs
378
- from any directory, in or out of a repository
379
- version Print version and exit
380
- help Print this help and exit
381
-
382
- Options:
383
- --json (gtd next/gtd land only) output structured JSON
384
- instead of plain text. Mutually exclusive with --sh
385
- --sh (gtd next/gtd land only) output gtd_-prefixed POSIX
386
- shell assignments instead of plain text. Mutually
387
- exclusive with --json
388
- --port=<n> (gtd visualize only) port to serve on (default: a free port)
389
- --no-open (gtd visualize only) do not open the browser
390
- --cost=<n> (gtd land only) record the invocation's token cost
391
- --model=<name> (gtd land only, with --cost) tag that cost's model
392
- --entry <state> (with no command at all) start a brand new process at
393
- <state> — any declared, non-commit state — authenticated
394
- as human
395
- --var <name>=<value>
396
- (with --entry; repeatable) supply a fixed it.vars
397
- override for the new process; the name must already be
398
- declared by the workflow's own vars: or the .gtdrc vars:
399
- --open-questions (gtd check only) ignore <mode>'s structural findings and
400
- instead run the qa open-questions predicate over <file>,
401
- printing each unanswered question one per line and exiting
402
- non-zero when any remain
403
- --verbose enable stderr narration for this invocation: which rest
404
- resolved, which declared pattern each pending change
405
- matched, which review-window action was emitted, and how
406
- config resolved across layers. Aliased to -v
407
- --version, -V Print version and exit
408
- --help, -h Print this help and exit
409
- ```
410
-
411
- ### Plain output is not a parsing surface
412
-
413
- `gtd next`'s plain encoding is for a human, or a driver that merely displays it
414
- — never for scraping. Parsing lives in `--json`/`--sh`, both of which read from
415
- the exact same field set (`gtd install`'s briefing has the full reference);
416
- anything that greps, cuts, or `awk`s plain text is unsupported, and its shape
417
- may change across releases with no warning.
418
-
419
- ### Exit codes
420
-
421
- Closed at five numbers, five meanings — a new command never grows this table;
422
- whose turn is next lives in `gtd next --json`'s own `kind` field instead.
423
-
424
- | Code | Meaning |
425
- | --------- | ---------------- |
426
- | 0 | success |
427
- | 1 | runtime error |
428
- | 2 | usage error |
429
- | 130 / 143 | SIGINT / SIGTERM |
430
-
431
- Every command follows this table uniformly, `next`/`land` included: `0` on
432
- success, `1` on refusal, `2` on usage error, `130`/`143` when gtd itself dies by
433
- that signal — a parent's `wait` sees a real signal death (`WIFSIGNALED`), not a
434
- chosen exit code that merely reuses the same number. No command's exit code
435
- carries a second meaning.
436
-
437
- **Migration — read this even if you already migrated for a prior release.** This
438
- is the second inversion in as many releases, folded into one note rather than
439
- two to compose in your head: `10`/`20` (whose turn was next) are gone — every
440
- command exits `0`/`1`/`2` uniformly now; `gtd status` is gone (folded into
441
- `gtd next`); and plain `gtd next` now prints a status header at every kind
442
- EXCEPT `prompt` — agent input is untouched, since plain `gtd next` at a `prompt`
443
- rest is byte-identical to before. A driver must read whose turn is next off
444
- `gtd next --json`'s own `kind` field
445
- (`capture`/`message`/`script`/`prompt`/`stalled`) — never off gtd's exit code,
446
- which no longer carries that signal at all.
447
-
448
- Every usage mistake — an unknown option or command, missing/extra arguments, a
449
- scope violation (e.g. `--cost` on a command other than `gtd land`), a bad flag
450
- value — is a USAGE error (`2`), never a runtime error (`1`): nothing was even
451
- attempted. `--help`/`--version` still exit `0`.
452
-
453
- `--version` (`-V`) / `gtd version` and `--help` (`-h`) / `gtd help`
454
- short-circuit before any git or repository-state work — they run outside a repo
455
- and in any repo state, and print to **stdout** at exit 0. `--verbose` (`-v`) is
456
- not a short-circuit — it gates narration for whatever command follows (see
457
- [Narration and remediation](#narration-and-remediation) below). Bare `gtd` (no
458
- subcommand) is a usage error that exits 2 — gtd decides and prints, full stop;
459
- driving a loop is a driver's job, not a bundled command (see
460
- [Driving the loop](#driving-the-loop) below) — printing its help text to
461
- **stderr**, not stdout: stdout stays byte-empty on every failure, a usage error
462
- included (see [Error envelope](#error-envelope) below). Any other, truly unknown
463
- subcommand is likewise a usage error exiting 2 without touching the repository.
464
- The state commands (`land`, `--entry`, `abandon`, `restore`, `next`, `status`,
465
- `validate`) must run from the **repository root** — gtd derives the workflow,
466
- pending changes, and process history relative to cwd, so they refuse with a
467
- clear error from a subdirectory; `lsp`, `init`, `visualize`, `check`, and
468
- `install` are standalone and run from anywhere (see each command's own help
469
- entry).
470
-
471
- `--json`, `--cost=<n>`, `--model=<name>` (the latter two only for `gtd land`),
472
- `--entry <state>` (no other command at all), and `--var <name>=<value>` (with
473
- `--entry`, repeatable) are the only long options the compiled bundle recognizes.
474
- `--entry`/`--var` accept both the `--flag=value` and the space-separated
475
- `--flag value` form. Any other `--` option (including a typo like `--jsn`) is
476
- rejected with a usage error rather than silently ignored, so a mistyped flag can
477
- never degrade a JSON caller to plain-text mode. `--var` with no `--entry`, a
478
- duplicate `--var` name, or `--cost`/`--model`/`--entry` combined with another
479
- command are all usage errors too — landing and entering are different verbs, so
480
- `gtd land --entry <state>` is a usage error, not a synonym. A bare
481
- `--cost`/`--model` with no value, a non-numeric or negative `--cost`, an empty
482
- `--model`, `--model` without `--cost`, or `--cost`/`--model` on any command
483
- other than `gtd land` are all usage errors.
484
-
485
- ### `gtd next`'s `Next:`/`next`
486
-
487
- Both plain and `--json` output include a headline preview of what would happen
488
- next: the first declared `on` edge whose pattern matches the pending changes AS
489
- A WHOLE (the same first-match-wins semantics `gtd land` itself uses), using its
490
- `action` when the edge declares one, else its raw pattern, alongside its target
491
- state. Plain output prints a `Next: <action-or-pattern> → <target>` line (or
492
- `Next: (no match — nothing would happen)`); `--json`'s `next` key mirrors it as
493
- `{ action?, pattern, target }`, or `null` on no match.
494
-
495
- This reports the **declared** route only: a capped `retry` may redirect
496
- elsewhere when the land is decided, which `Next:`/`next` does not apply — it
497
- previews what the declared `on` patterns would match, not a guarantee of where a
498
- real `gtd land` lands.
499
-
500
- ### Error envelope
501
-
502
- **stdout is either the complete artifact or byte-empty — never a partial write
503
- followed by an error.** Every command buffers everything it would print and
504
- flushes that buffer to stdout exactly once, only after it succeeds; on any
505
- failure the buffer is simply discarded, so stdout never carries a half-written
506
- prompt/script alongside a message about why it stopped. `gtd visualize` is the
507
- one exception worth knowing: it flushes its served-URL line immediately, before
508
- blocking on `Ctrl-C`, since a flush-on-success would never otherwise fire.
509
-
510
- Any invocation that carries `--json` (valid only for `gtd next`/`gtd land` —
511
- every other command usage-errors on it) reports a failure as a machine-readable
512
- envelope on **stderr** — including the scope violation itself, so a driver that
513
- always adds `--json` still gets a parseable envelope on every failure, not only
514
- `gtd next`'s/`gtd land`'s own:
515
-
516
- ```json
517
- { "state": "error", "prompt": "<message>" }
518
- ```
519
-
520
- This covers every failure mode, not just a command's own refusal (exit 1): a
521
- **usage error** (an unknown flag, a missing argument, `gtd --entry version`'s
522
- "not an enterable state" — exit 2) and a **defect** (a layer throwing outside
523
- the ordinary error channel — exit 1) both get the same envelope shape — there is
524
- no failure path that reaches `--json` without one — but a usage error's exit
525
- code is 2, never 1, so a driver can tell "you invoked gtd wrong" apart from "gtd
526
- refused/broke" (see [Exit codes](#exit-codes)).
527
-
528
- A human-readable `gtd: <message>` line is also always written to **stderr**,
529
- right after the envelope — stdout carries neither one on a failing run. Stderr
530
- always carries exactly one `gtd: ` prefix: a message already authored with its
531
- own `gtd:`/`gtd <cmd>:` prefix is never doubled.
532
-
533
- **Accepted cost:** a driver that pipes stdout into `jq` on a failed run now
534
- reads nothing instead of a parseable error object — it must read stderr or the
535
- exit code to learn why a run failed.
536
-
537
- ### Narration and remediation
538
-
539
- Stderr carries two things beyond the `gtd: ` message line above: NARRATION,
540
- gated by `--verbose`/`-v`, and REMEDIATION, unconditional.
541
-
542
- `--verbose` (alias `-v`) turns on one line of commentary per in-process fact a
543
- command's dispatch already computes — which rest resolved, which declared
544
- pattern each pending change matched, which review-window action was emitted, and
545
- how config resolved across `.gtdrc` layers. Without it, none of this is printed;
546
- stdout is never touched either way — narration is a stderr-only concern, exactly
547
- like the error envelope above.
548
-
549
- A failure's remediation detail is unconditional — it prints at every verbosity,
550
- on the line(s) right after the `gtd: `-prefixed message, each indented two
551
- spaces: a bad config key names the offending key and which `.gtdrc` layer it
552
- came from, a corrupted ref names the ref, and a missing binary in a steering
553
- mode's `format:`/`validate:` command names the resolved `$PATH` it was looked up
554
- in.
555
-
556
- ### Non-interactive today
557
-
558
- gtd is non-interactive: no readline, no `/dev/tty`, no prompt call anywhere in
559
- `src/`. If interaction is ever added, it goes to `/dev/tty`, never stderr, and
560
- never blocks — a question fails with a code when the tty cannot be opened rather
561
- than hanging. The reason is the section above: stderr already has two occupants,
562
- narration and remediation, and a question mixed into that stream would deadlock
563
- a driver that never reads stderr.
564
-
565
- ## Driving the loop
566
-
567
- gtd itself is not a loop — it decides and prints, full stop; driving a loop is a
568
- driver's job. The README's minimal driver below (see
569
- [A complete minimal driver](#a-complete-minimal-driver)) is that driver: save it
570
- as `~/.local/bin/gtd-loop`, `chmod +x` it, and run it from a repository root —
571
- it takes no arguments and runs the loop until it's your turn. It drives the
572
- autonomous states (agent turns, check runs) and stops at the first
573
- non-autonomous one: reaching a human gate it prints the gate's message and
574
- exits. You act by editing files (answer a plan question, tick a review box, fix
575
- code) and re-running it — your pending edit arrives as the loop's first beat
576
- (`kind: "capture"`, landed immediately), so you never run `gtd land` by hand.
577
-
578
- Some gates could accept by INACTION instead: a workflow may declare a `"C"`
579
- (clean-tree) pattern on a human-actor state that routes onward, so changing
580
- nothing there means "accept as-is" rather than nothing happening. That reaches
581
- the driver as `kind: "message"` either way, which no inspection can tell apart
582
- from a gate you have not read yet — so the driver treats its OPENING beat as
583
- yours regardless and lands it: you re-ran it while resting there, and that
584
- invocation IS the decision. Every later beat halts as usual, because a gate the
585
- driver produced mid-run is one you have not seen. Landing an opening beat at a
586
- gate with no `"C"` pattern is harmless — a benign no-op (see `gtd land`'s exit
587
- codes below) — and the gate then prints on the next beat. A mid-process restart
588
- simply resumes driving from whatever beat is actually next.
589
-
590
- Anything richer at that boundary — opening your editor, desktop notifications,
591
- terminal-multiplexer status — is the job of an outer wrapper around the driver,
592
- not of the loop itself; see
593
- [Terminal-multiplexer status: a herdr wrapper](#terminal-multiplexer-status-a-herdr-wrapper)
594
- below for a worked example.
595
-
596
- A workflow state can declare an optional `label:` — a human-readable display
597
- name surfaced in `gtd next --json`/plain `gtd next`. The driver uses it for its
598
- per-beat progress lines; an outer wrapper (a terminal multiplexer, a notifier)
599
- can use it the same way.
600
-
601
- A machine may also declare `system:` — like `model:`, stamped once at the
602
- machine level onto every one of that machine's own `prompt` states, never
603
- authored on an individual state. It is passed to the agent CLI as (in the
604
- reference driver's case) `--system-prompt`, which **replaces** the harness's own
605
- default system prompt outright rather than appending to it (contrast with an
606
- `--append-system-prompt`-shaped flag) — so a machine declaring `system:` loses
607
- not only the harness's own tool-use instructions but also its dynamic per-turn
608
- sections: current working directory, environment info, memory-path information,
609
- git status. A workflow author reaching for `system:` for the first time is
610
- therefore writing a complete replacement system prompt, not a tweak on top of
611
- the harness's own. The scoping is machine-level for the same reason memory is
612
- machine-scoped below: a machine is the unit of conversational identity, so its
613
- system prompt — like its model tier — is one property of that identity, constant
614
- across every turn of the one resumed session, never a per-state override. Like
615
- `model:`/`file:`, a `system:` value prefixed `./` or `../` is inlined from the
616
- declaring config file's own directory at compile time — for a user's own
617
- `.gtdrc` `workflow:` config only; the bundled template ships no filesystem
618
- references at all, since it has to work inside a single-file build. The bundled
619
- default template ships six such personas already, one per prompt-bearing machine
620
- — `designPersona`, `architectPersona`, `reviewerPersona`, `specReviewerPersona`,
621
- `builderPersona`, `finisherPersona` — and, like any other bundled var, each is
622
- overridable through a top-level `.gtdrc` `vars:` key or a `GTD_<NAME>`-style
623
- environment variable (e.g. `GTD_DESIGNPERSONA`) — gtd's existing, generic
624
- vars-override mechanism, nothing new.
625
-
626
- Memory is **entry-scoped to a machine**, not a state-authored label: each
627
- machine instance (a node in the `machines:` tree, e.g. `build`, `build.health`,
628
- `packages.item`, `packages.item.health`) owns its own conversational scope, and
629
- a `prompt`-content state's `memory` key — surfaced in `gtd next --json`'s
630
- `memory` field, and as a `Memory: <key>` line in plain `gtd next` — is computed,
631
- never authored, as `<scope>#<hash7>`: `<scope>` is that machine instance's
632
- dotted path (the root instance is shown as `root`), and `<hash7>` anchors to the
633
- commit the CURRENT unbroken entry into that scope started FROM. Entering a
634
- **descendant** scope (e.g. dipping from `build` into `build.health`) does not
635
- break the parent's unbroken run — a full agent turn in a nested child machine,
636
- then back to the parent, still resumes the SAME parent conversation; entering a
637
- **sibling or unrelated** scope does start a fresh one. The bundled template's
638
- `build.review` (the human review tail) is a worked example: it is nested INSIDE
639
- `build` (the builder's own machine) so that a `gtd --entry fix-precheck` run —
640
- `build.fix` -> `build.health.check` -> `build.review.*` -> `build.squashing` —
641
- stays inside one subtree, letting `build.squashing` resume the SAME session that
642
- made the fixes instead of a root-level sibling forcing it to re-derive the range
643
- from scratch on every pass through the tail. (An actionable review round breaks
644
- the run on purpose instead — it leaves `build` entirely through a root-level
645
- `re-unwind` state and a full re-plan, since a hand-edit made during review is a
646
- sketch to reconsider, not a fix to build on.) Two instances of the same reusable
647
- machine (e.g. `build.health` and `packages.item.health`, both instantiating
648
- `healthGate`) get different scopes and so never share a key, even though they're
649
- the "same shaped" machine. One consequence is a structural guarantee: **a
650
- reviewer's turn never resumes an implementer's session, and vice versa** — a
651
- reviewer machine and the implementer machine it reviews are always different
652
- instances with different scopes.
653
-
654
- `gtd` itself stores NOTHING to make this work: `session.id` is
655
- `UUIDv5(<fixed gtd namespace>, <memory key>)` — a deterministic hash of the
656
- computed `<scope>#<hash7>` key above — so the same scope-run always re-derives
657
- the exact same id, and there is no table, no file, no write to keep in sync.
658
- `session.resume` is `true` iff a prior `prompt` turn already landed within that
659
- same scope-run. Because nothing is written, calling `gtd next --json` twice in a
660
- row — a driver's own opening peek, a status poll, a curious human — derives
661
- IDENTICAL `session.id`/`session.resume` values both times, since there is
662
- nothing to poison: looking is free, and there is no separate claiming form to
663
- protect. The per-scope survival story (a child machine's own excursion doesn't
664
- disturb the parent's session) falls out of the key itself, not out of a
665
- per-scope row: the parent's anchor commit is unaffected by whatever the child
666
- scope does in between. A driver maps `session.id`/`session.resume` straight onto
667
- the agent CLI's own session flags — the README's minimal driver passes them as
668
- `--session-id <id>`/`--resume <id>` to `claude -p`, but treats `resume` as a
669
- HINT rather than a contract: it tries the flag `resume` points at first and
670
- falls back to the other on failure. That fallback is what recovers BOTH
671
- mismatches that used to need manual intervention — a crashed prior turn that
672
- minted an id but landed no commit (so the next lap re-derives the SAME id with
673
- `resume: false`, and `--session-id` on an already-used id fails, so the driver
674
- falls back to `--resume`), and the inverse (`resume: true`, but the remembered
675
- session is gone — retention expired, `~/.claude/projects` wiped — so `--resume`
676
- fails and the driver falls back to `--session-id`). There is no file to delete
677
- and nothing to restart.
678
-
679
- ### Terminal-multiplexer status: a herdr wrapper
680
-
681
- [herdr](https://herdr.dev) shows a per-pane status in its sidebar. This wrapper
682
- reports `gtd`'s own lifecycle to that status without any herdr-specific
683
- knowledge in `gtd` itself: `working` while the loop drives, `blocked` when it
684
- comes to rest on a human (a gate, a stall, a non-zero exit), and `idle`
685
- (rendered as "done" once the pane's tab is unfocused) when a run ends without
686
- anything owed. It needs nothing from `gtd` beyond `gtd next --sh`'s `gtd_actor`
687
- field — a strictly read-only orientation peek.
688
-
689
- Save this as `~/.local/bin/gtdh`, `chmod +x` it, and run `gtdh` in place of
690
- `gtd-loop` — it's a plain bash file, so it works from fish or any other shell.
691
-
692
- ```bash
693
- #!/usr/bin/env bash
694
- # Report gtd's own lifecycle to the herdr pane it runs in: working while the
695
- # loop drives, blocked when it rests on you, idle (shown as "done") otherwise.
696
- # Needs nothing from gtd but `gtd next --sh`. Outside herdr it is a plain
697
- # passthrough.
698
- set -uo pipefail
699
-
700
- pane="${HERDR_PANE_ID:-}"
701
-
702
- # `--agent gtd` is deliberate: herdr only lets screen detection (or a visible
703
- # approval prompt) override a reported state when the reported label names a
704
- # KNOWN agent. "gtd" names none, so the loop's `claude -p` turns can never move
705
- # this pane's status.
706
- report() { # report <state>
707
- [ -n "$pane" ] || return 0
708
- herdr pane report-agent "$pane" \
709
- --source custom:gtd --agent gtd --state "$1" >/dev/null 2>&1 || true
710
- }
711
-
712
- report working
713
- trap 'report blocked; exit 130' INT TERM
714
-
715
- # HERDR_PANE_ID is unset for the loop: herdr's Claude Code hook needs it, and
716
- # without it no `claude -p` turn reports a claude SESSION identity for this
717
- # pane. That is load-bearing, not cosmetic — a pane that owns one rejects every
718
- # later state report, so the report below would be dropped.
719
- env -u HERDR_PANE_ID gtd-loop
720
- rc=$?
721
-
722
- # Whose turn is it now? `gtd next --sh` is a strictly read-only peek — every
723
- # gtd command is, including `gtd next` (its prompt session id is derived,
724
- # never minted/stored) — only the emitted scripts a driver runs actually
725
- # touch git. A human actor means gtd is waiting on you; anything else means
726
- # the run ended with nothing owed. Assign first, THEN eval — same reason as
727
- # the driver above.
728
- out="$(gtd next --sh 2>/dev/null)" || out=""
729
- eval "${out:-}" 2>/dev/null || true
730
-
731
- if [ "$rc" -ne 0 ] || [ -z "${gtd_actor:-}" ] || [ "$gtd_actor" = human ]; then
732
- report blocked
733
- else
734
- report idle
735
- fi
736
-
737
- exit $rc
738
- ```
739
-
740
- A few things to know before relying on it:
741
-
742
- - **Give `gtd` its own pane.** Run an interactive `claude` (or any agent whose
743
- herdr integration reports session identity) in the same pane and that pane
744
- owns a `herdr:claude` session until the process exits; while it does, the
745
- wrapper's reports are silently ignored and the sidebar stops tracking `gtd`.
746
- - **`blocked` covers the resting `idle` state too** — gtd's own `idle` is a
747
- human gate (it waits for you to write a steering file), so a finished process
748
- reads as "your turn", which is what it is.
749
- - The status **persists after the wrapper exits** — that's the point: the
750
- sidebar keeps showing which worktree is waiting on you. Hand the pane back to
751
- ordinary detection with
752
- `herdr pane release-agent "$HERDR_PANE_ID" --source custom:gtd --agent gtd`.
753
- - A non-zero exit (a stall, a refusal, an error) reports `blocked`: herdr has no
754
- failure state, and those all need a human.
755
- - Ctrl-C reports `blocked` rather than leaving a stale `working`.
756
-
757
- Optionally,
758
- `herdr pane report-metadata "$HERDR_PANE_ID" --source custom:gtd-display --token summary=<text>`
759
- sets a value renderable as `$summary` in an Agent sidebar row, if you want more
760
- than the state itself.
761
-
762
- ## Writing your own driver
763
-
764
- Run `gtd install` to print this whole chapter's protocol as a complete,
765
- self-contained briefing — paste it into an agent's context (or read it yourself)
766
- to build a driver without leaving your terminal. The briefing ends by directing
767
- the agent to INTERVIEW you first — which agent CLI runs the turns, under what
768
- permission model, how you want to invoke the loop, what should happen at a human
769
- gate — and to build the driver your answers describe rather than copying the
770
- reference sh. It writes nothing: "install" means installing knowledge into the
771
- calling agent's context, and the briefing it prints is always exactly as current
772
- as the `gtd` that printed it.
773
-
774
- The README's minimal driver below is gtd's own reference driver, not a
775
- privileged one — the engine itself is a supported public surface, and anything
776
- below holds for any driver you write against it. gtd decides and prints; it
777
- never touches git itself. The four commands that change anything — `gtd land`,
778
- `gtd --entry <state>`, `gtd abandon`, and `gtd restore` — perform no git write
779
- when run: each one prints ONE POSIX sh script for YOU to execute
780
- (`src/Emit.ts`'s `combinedScript`) — a leading comment ("gtd emitted this and
781
- did NOT run it — pipe it into `sh` to land the turn"), then the REQUIRED half
782
- verbatim, then, only when there's a presentation-only follow-up, a second
783
- comment ("presentation only — safe to skip") and the OPTIONAL half wrapped in a
784
- subshell whose own non-zero exit is swallowed (reported to stderr as a warning,
785
- never turning a landed turn into a failing one). Printing gtd's output and never
786
- running it is not driving anything; a driver must pipe or execute what gtd
787
- prints — e.g. the capture-then-pipe form the reference driver below uses — never
788
- a bare `gtd land | sh`, which would hand an empty script to a shell on a refusal
789
- instead of stopping first (see the reference driver's own use of `gtd land --sh`
790
- below).
791
-
792
- Every script gtd emits — `gtd land`, `gtd --entry <state>`, `gtd abandon`,
793
- `gtd restore`, and the format/validate script `gtd validate` prints — is POSIX
794
- `sh`, portable to `dash`: a driver may run any of them with any POSIX-compliant
795
- shell, not specifically bash. The same convention extends to the workflow's own
796
- `vars.testCommand` (what a `script`-content check state actually executes): it
797
- is expected to be POSIX sh-compatible too, but this is a DOCUMENTED CONVENTION
798
- only — gtd never inspects or validates `testCommand`'s shell dialect itself, it
799
- only renders the value into a script and hands it to whatever shell the driver
800
- invokes that script with.
801
-
802
- - **The required half** is everything that decides what lands in git — closing
803
- an open review checkout window, the resting state's own steering-mode
804
- `format:`/`validate:` commands, the commit or squash itself (`gtd land` and
805
- `gtd --entry <state>`), or the ref update and reset that undo a process
806
- (`gtd abandon`, `gtd restore`) — and, last, a printed line naming what just
807
- landed (`src/OutcomeScript.ts`'s `gtd_report_*` calls): a transition or
808
- capture's changed-file rows, or the abandon/restore prose, resolved from the
809
- repository AFTER the write above it. Its own exit code IS the printed script's
810
- exit code — skipping it means the turn never lands, and you never see what it
811
- did.
812
- - **The optional half** is presentation only: re-opening the review checkout
813
- window (the `<<<<<<< HEAD` diff view) after `gtd land` lands at a
814
- `reviewWindow: true` state, so an editor's diff view has something to show.
815
- Its own failure is swallowed by the wrapping subshell (a warning on stderr,
816
- nothing more) — skip it (or let it fail) and you lose nothing but that view,
817
- the workflow is still driven correctly. `gtd abandon`/`gtd restore` never
818
- carry one — there is no window to reopen after either, so their printed
819
- artifact is the required half alone, with no trailing comment/subshell at all.
820
-
821
- `gtd next --json` carries one more field worth a custom driver's attention:
822
-
823
- - **`log`** — the per-worktree loop log path, always present. It's derived from
824
- the worktree's own git dir, so two worktrees looping concurrently never share
825
- one file; set `$GTD_LOOP_LOG` to override it verbatim, or `$GIT_DIR` to name
826
- the git dir directly (both honored the same way every git subprocess already
827
- honors them — an inherited `$GIT_DIR` moves the log path along with it). gtd
828
- itself neither creates nor truncates this file — a driver appends subprocess
829
- output to it and truncates once at the start of a run, exactly like the driver
830
- above does.
831
-
832
- Even a genuine no-op `gtd land` (a clean tree matching no `on` pattern) prints a
833
- PRINT-ONLY script: no git write, just the same `nothing to do at "<state>"` line
834
- the script prints when a driver runs it. Every encoding (plain, `--json`,
835
- `--sh`) carries that same script verbatim in its `script` field — running it is
836
- never optional, whichever encoding a driver reads it from. The script is
837
- self-contained (it carries its own precondition assert and retry helper) and
838
- safe to run standalone, in sequence, or not at all — paste it into a terminal
839
- and it does exactly what it says, printed output included: it detects its own
840
- tty/`NO_COLOR` at RUN time (not at the moment gtd generated it), so the
841
- fancy/plain rendering always matches wherever you actually run it.
842
-
843
- A driver has no opening move. It does not need to know whose turn it is before
844
- it starts — `gtd next --json`/`--sh` tells it, and a human's pending edit
845
- arrives as an ordinary `kind: "capture"` beat that the driver lands like any
846
- other. The rule this replaces: never `gtd land` outside a beat you dispatched. A
847
- stray land at a clean `prompt` rest authors an empty attempt on purpose (that IS
848
- the stall bookkeeping), so an unconditional opening land would manufacture a
849
- stall out of a fresh start. The one EXCEPTION is the run's very first beat: land
850
- it before trusting `idle` there too, so a workflow whose initial state declares
851
- its own clean-tree `"C"` pattern still gets a chance to advance on a human's
852
- bare re-invocation, rather than the driver concluding "nothing owed" without
853
- ever giving that edge a turn (see the reference driver's own comment on this).
854
61
 
855
- Exit code carries none of this any more — every command, `next`/`land` included,
856
- exits `0` on success (see [Exit codes](#exit-codes) above). Whose turn is next,
857
- and whether a landing settles, are both PLAIN FIELDS on `gtd next --json`/`--sh`
858
- and `gtd land --json`/`--sh`: `next`'s own `kind`
859
- (`capture`/`message`/`script`/`prompt`/`stalled`) and `idle`; `land`'s own
860
- `settled` and `idle`. `gtd land --sh` carries `settled`/`idle` alongside the
861
- script itself, so ONE invocation both runs the landing and tells the driver
862
- whether to stop — no second read needed to decide. A no-op at a `script` rest
863
- settles right where it rests (stop immediately, nothing more to read); an
864
- ordinary or squash landing that finishes the whole process instead resolves
865
- `idle` on the FOLLOWING `gtd next` — the reference driver below reads once more
866
- only to DISPLAY that gate's message, never to decide whether to stop. Declaring
867
- a `C` edge on a `script` state is the workflow-side way to make the state
868
- advance instead of settling.
869
-
870
- ### Drivers other than sh
871
-
872
- The protocol above is JSON in (from `gtd next --json` alone), subprocesses out —
873
- sh is one convenient shape, not the only one. A **program** parses
874
- `gtd next --json`, switches on `kind`, and runs `gtd next`'s (plain-text) output
875
- and `gtd land`'s (POSIX sh) output as subprocesses — no sh anywhere in it. A
876
- **human** runs plain `gtd next` (there is no JSON form of it at all), does what
877
- it says, and pastes `gtd land | sh`: plain-text output exists for exactly this,
878
- printing the combined script ready to paste. An **agent** gets `gtd install` as
879
- its instructions — the same protocol, in a form built to be pasted into a
880
- context window rather than read. A **CI job** is the program case with the
881
- `prompt` arm pointed at a headless agent CLI, and
882
- `kind: "message"`/`kind: "stalled"` mapped onto "stop and report".
883
-
884
- ### A complete minimal driver
885
-
886
- This is the whole protocol described above, compressed into a loop small enough
887
- to paste from this README and own outright — save it as `~/.local/bin/gtd-loop`
888
- (`chmod +x`) and it's the ready-to-run driver
889
- [Driving the loop](#driving-the-loop) above points at; swap the `claude` line
890
- for any agent CLI and it keeps working.
891
-
892
- This exact fenced block is extracted and executed by
893
- `tests/integration/features/readme-driver.feature` — renaming the heading above
894
- or splitting the block into more than one fence breaks the build.
895
-
896
- **Pipe the prompt to the agent CLI on stdin — never pass it as a command-line
897
- argument.** A `prompt` beat's content embeds a full diff, and argv is capped:
898
- roughly 1 MB on macOS, and POSIX guarantees only 4 KB (`ARG_MAX`). Both are
899
- reachable by an ordinary diff, so a driver that passes the prompt as an argument
900
- works in testing and then fails on the first large change, in a way that looks
901
- like an agent error rather than a driver bug. The driver below pipes `$c`/`$out`
902
- into `claude -p` over stdin for exactly this reason.
62
+ The loop behind all of this is one beat, repeated:
903
63
 
904
64
  ```bash
905
- #!/usr/bin/env sh
906
- set -eu
907
-
908
- beat=1
909
65
  while :; do
910
- # One invocation per beat: assign first, THEN eval — command substitution
911
- # inside eval's own argument would swallow a failed `gtd next` under
912
- # `set -e` (eval would see only the empty string and abort on some later
913
- # unset variable with a confusing message). Assigning to `out` first makes
914
- # this a simple command whose own exit status IS the substitution's, so
915
- # `set -e` aborts correctly on a genuine failure.
916
66
  out="$(gtd next --sh)"
917
67
  eval "$out"
918
-
919
- # `gtd_idle` (true iff the initial state, clean tree) is the one shape
920
- # that means the process is genuinely done — EXCEPT on the run's opening
921
- # beat: land it anyway, so a workflow whose initial state declares its own
922
- # clean-tree "C" pattern still gets a chance to fire.
923
- if [ "$beat" -gt 1 ] && [ "${gtd_idle:-}" = true ]; then
924
- gtd next
925
- exit 0
926
- fi
927
-
928
68
  case "$gtd_kind" in
929
- stalled) printf '%s\n' "$gtd_content" >&2; exit 1 ;;
930
- # you re-ran us resting here: you either edited something or accepted by
931
- # editing nothing, so land the opening beat either way. Later beats are
932
- # gates we just produced and you have not read yet — hand off.
933
- message) [ "$beat" = 1 ] || { gtd next; exit 0; } ;;
934
- capture) ;; # the human already acted — just land it
935
- script)
936
- sh -c "$gtd_content" >>"$gtd_log" 2>&1 || true ;;
937
- prompt)
938
- # $gtd_content embeds a full diff, so it goes to the agent over
939
- # stdin, never as an argv positional — argv is capped (~1 MB on
940
- # macOS, and POSIX guarantees only 4 KB, ARG_MAX), and a diff crosses
941
- # that far sooner than you'd expect.
942
- agent_turn() { printf '%s' "$gtd_content" | claude -p "$1" "$gtd_session_id" \
943
- ${gtd_model:+--model "$gtd_model"} \
944
- ${gtd_system:+--system-prompt "$gtd_system"} \
945
- --dangerously-skip-permissions >>"$gtd_log" 2>&1; }
946
- if [ "${gtd_session_resume:-}" = true ]
947
- then agent_turn --resume || agent_turn --session-id
948
- else agent_turn --session-id || agent_turn --resume
949
- fi
950
- n=0
951
- while [ -n "${gtd_validate:-}" ] && ! fix="$(sh -c "$gtd_validate" 2>&1)"; do
952
- n=$((n + 1)) && [ "$n" -gt 3 ] && { printf '%s\n' "$fix" >&2; exit 1; }
953
- # $fix IS the fix prompt, verbatim — piped for the same reason as
954
- # $gtd_content above. Whether `claude --resume` re-applies the
955
- # original session's model/system prompt is a harness detail gtd
956
- # cannot verify from outside, so this passes the identical
957
- # $gtd_model/$gtd_system on both calls rather than assume it does —
958
- # otherwise this fix turn might silently fall back to Claude Code's
959
- # own defaults while the turn that produced the file ran under the
960
- # workflow's own model and persona.
961
- printf '%s' "$fix" | claude -p --resume "$gtd_session_id" \
962
- ${gtd_model:+--model "$gtd_model"} \
963
- ${gtd_system:+--system-prompt "$gtd_system"} \
964
- --dangerously-skip-permissions >>"$gtd_log" 2>&1
965
- done ;;
69
+ script) sh -c "$gtd_content" ;;
70
+ prompt) printf '%s' "$gtd_content" | your-agent ;;
966
71
  esac
967
-
968
- # `gtd land --sh` carries `settled`/`idle` alongside the script itself —
969
- # one invocation tells us both what to run and whether to stop, with no
970
- # second read needed to decide either.
971
- out="$(gtd land --sh)"
972
- eval "$out"
973
- printf '%s\n' "$gtd_script" | sh
974
- if [ "${gtd_settled:-}" = true ]; then
975
- [ "${gtd_idle:-}" = true ] && gtd next
976
- exit 0
977
- fi
978
- beat=$((beat + 1))
72
+ gtd land
979
73
  done
980
74
  ```
981
75
 
982
- Line by line it is the protocol described above: `out="$(gtd next --sh)"` then
983
- `eval "$out"` is one invocation per beat — assigning first is what lets `set -e`
984
- abort correctly on a genuine failure, where `eval "$(gtd next --sh)"` would
985
- instead eval the empty string and die later on some unrelated unset variable;
986
- the driver carries no `unset` of its own, since the `--sh` document's own
987
- preamble makes `eval` self-contained. The very first beat lands even when
988
- `gtd_idle` is already true, so a workflow whose initial state declares its own
989
- clean-tree `"C"` pattern still gets a chance to fire before the driver calls it
990
- done. `kind: "stalled"` prints `$gtd_content` (the diagnosis itself) to stderr
991
- and stops — no re-invocation needed, since the beat already fetched it;
992
- `message` halts unless it is the opening beat, which the human's own
993
- re-invocation authored and which therefore lands like any other decision (see
994
- [Driving the loop](#driving-the-loop) above — this is the one place the driver,
995
- not gtd, decides, because "has the human read this gate" is run-scoped knowledge
996
- gtd deliberately does not keep); `capture` lands a human's already-made edit
997
- outright, no display needed; `script` runs `$gtd_content` in the driver;
998
- `prompt` sends it to the agent over stdin with
999
- `$gtd_session_id`/`$gtd_model`/`$gtd_system` mapped onto the agent's session
1000
- flags — trying `resume`'s hinted flag first and falling back to the other on
1001
- failure, since the session id is derived, not remembered (see
1002
- [Driving the loop](#driving-the-loop) above) — and its own `$gtd_validate`
1003
- script's output re-prompted verbatim on failure (the driver owns only the retry
1004
- cap). Every optional variable (`$gtd_model`, `$gtd_system`, `$gtd_validate`,
1005
- `$gtd_session_resume`, `$gtd_idle`, `$gtd_settled`) is read as `${var:-}` or
1006
- `${var:+...}` — under `set -u`, the `--sh` document's own `unset` preamble makes
1007
- an absent field genuinely unset, not empty, so a bare `$gtd_model` would abort
1008
- the driver. Every landed turn is executed — and reported — by the emitted
1009
- scripts themselves, via `gtd land --sh`'s own `$gtd_script` field, captured then
1010
- piped to `sh`. `$gtd_settled` ends a run that has nothing left to do: a no-op at
1011
- a `script` rest settles right where it rests (stop immediately, nothing more to
1012
- read), while an ordinary or squash landing that finishes the whole process
1013
- instead resolves `$gtd_idle` on the FOLLOWING beat's own `gtd next --sh` read —
1014
- the reference driver reads once more (a plain `gtd next`) only to DISPLAY that
1015
- gate's own message, the decision to stop already made from `$gtd_settled`/
1016
- `$gtd_idle` alone.
1017
-
1018
- This paste passes `$gtd_system` on argv, and POSIX guarantees only 4 KB of argv
1019
- (`ARG_MAX`) — real systems are far higher (roughly 1 MB on both macOS and
1020
- Linux), and the bundled personas are only a few KB each, so this works
1021
- everywhere in practice. A driver shipping much larger system prompts, or
1022
- targeting a platform sitting at the POSIX floor, should write the string to a
1023
- file and pass that instead: gtd's own contract ends at emitting `gtd_system` as
1024
- a string, and how a driver hands that string to its agent CLI — argv, a temp
1025
- file, or something else — is the driver's own call, since it alone knows its
1026
- platform's argv limit and whether it has a writable temp directory; gtd adds no
1027
- flag, no file, and no mechanism of its own for this. (The doc-test below only
1028
- proves this paste parses and runs against a `claude` shim — not that the flag is
1029
- spelled or placed correctly; that's a `claude --help` check plus one live run,
1030
- not something the green suite can catch.)
1031
-
1032
- ### The self-validation gate
1033
-
1034
- After an agent turn at a state that declares `file:`+`mode:`, run the script:
1035
- either `gtd next --json`'s own embedded `.validate` field (present at every
1036
- `prompt` beat that hands over a validatable file), or, standalone,
1037
- `gtd validate`'s own plain-text output — both resolve the exact same script from
1038
- one shared resolver. This field is now populated even at a FIRST-WRITE beat,
1039
- before the steering file exists at all: the script itself carries a leading
1040
- `[ -f <file> ] || exit 0` guard rather than gtd checking existence ahead of
1041
- time, so a driver's `while [ -n "$gtd_validate" ]` repair loop is armed from the
1042
- very first turn at a state, not just the second and later ones. Exit 0 means the
1043
- file is well-formed (or genuinely doesn't exist yet) — proceed to `gtd land`. A
1044
- non-zero exit usually means the script's own captured output IS a complete,
1045
- ready-to-send fix prompt (an instruction plus the findings, see `src/Emit.ts`'s
1046
- `failurePromptWrapper`): send it back to the same agent session verbatim, and
1047
- cap how many fix attempts you allow yourself — the driver owns that retry count,
1048
- not gtd. Landing never TRUSTS that you validated, either: the emitted `land`
1049
- script carries the same format/validate commands ahead of its own commit and
1050
- fails without committing when they fail, so a malformed file is never captured
1051
- whether or not you ran the validate script first.
1052
-
1053
- A non-zero exit can ALSO mean something the fix loop cannot fix: a mode whose
1054
- `format:` command breaks its own validator, a config bug gtd detects by
1055
- formatting a canonical sample and re-checking it before the real file's own
1056
- findings are ever reported. That message is unmistakably different — it says
1057
- this is a CONFIGURATION BUG, not the steering file, and tells the agent to stop
1058
- and end its turn rather than edit anything. gtd's exit-code contract stays
1059
- closed at five numbers (below), so nothing distinguishes the two cases at the
1060
- process level — a driver's fix loop is still the CORRECT thing to run in both
1061
- cases, it just can never win a contradiction: its 3-attempt cap is what ends
1062
- one, not a fix. Reading the message text before re-prompting is what keeps an
1063
- agent from thrashing on a document it cannot fix.
1064
-
1065
- ### Failure taxonomy and recovery
1066
-
1067
- Several different things can go wrong, and they mean different things — and most
1068
- non-zero-looking exits are not a failure at all:
1069
-
1070
- - **`gtd` itself exits 1.** Nothing was attempted — this is a refusal (a guard
1071
- rejected the turn). No script was ever produced.
1072
- - **`gtd` itself exits 2.** A usage error — nothing was even attempted, the
1073
- invocation itself was wrong (unknown option/command, bad arity, a scope
1074
- violation).
1075
- - **`gtd land` succeeds (exit 0) but doesn't settle.** This is NOT a failure:
1076
- whose turn is next lives in the FOLLOWING `gtd next`'s own `kind` field, not
1077
- in `gtd land`'s exit code (see [Exit codes](#exit-codes)) — and `gtd land`'s
1078
- own stdout still carries a script (a print-only note, or a genuine
1079
- retain+rewind, or an ordinary commit) that a driver must still run.
1080
- - **An emitted script exits non-zero when YOU run it.** Something may have
1081
- partially happened — e.g. a `gtd_retry`-wrapped git write landed but a later
1082
- step in the same script failed.
1083
-
1084
- Recovery is the same in every case: **ask gtd again** (`gtd next`, then land).
1085
- It re-reads the real repository state fresh every time — never a cached plan —
1086
- and emits whatever still needs to happen from there. This works because every
1087
- emitted script opens by asserting its own precondition
1088
- (`[ "$(git rev-parse --verify --quiet HEAD 2>/dev/null)" = <expected> ] || { ...; exit 1; }`,
1089
- and the same shape for a review window's saved ref — see `src/Emit.ts`'s
1090
- `headAssertion`/`reviewWindowAssertion`), so a script generated against a
1091
- repository state that has since moved refuses loudly instead of corrupting
1092
- anything. **Emitted scripts are re-runnable**: this is the single most important
1093
- property for a driver's recovery logic. Re-running a script that already fully
1094
- applied is a no-op (its git writes are `--allow-empty` commits, idempotent ref
1095
- updates, and tolerant staged-restore calls), and re-running one that only
1096
- partially applied resumes correctly, because the precondition either still holds
1097
- (nothing landed yet — safe to retry verbatim) or gtd's next invocation reads the
1098
- new real state and emits a fresh script for what remains. A driver never needs
1099
- its own retry/resume logic beyond "if the script failed, ask gtd again."
1100
-
1101
- ### Prerequisites
1102
-
1103
- - **A POSIX `sh`** (dash, ash, bash's own POSIX mode, etc.) — gtd's own emitted
1104
- scripts (`gtd land`, `gtd --entry <state>`, `gtd abandon`, `gtd restore`) are
1105
- POSIX sh; captured, then piped into it (see
1106
- [Writing your own driver](#writing-your-own-driver) above).
1107
- - **`gtd` on `PATH`** — a mode's seeded `validate:` command (the one the
1108
- compiler fills in for the built-in `qa`/`review` formats) is literally the
1109
- string `gtd check <mode> '<file>'`, invoked by NAME from inside an emitted
1110
- script, not by absolute path (see `src/SteeringFormats.ts`'s
1111
- `seededValidateCommand`). This is a deliberate trade: a readable, overridable,
1112
- copy-pasteable command in exchange for depending on shell name resolution at
1113
- the moment the script runs. The sharp edge: if the `gtd` binary you invoked to
1114
- GENERATE the script differs from the `gtd` that resolves on `PATH` when the
1115
- script later RUNS (a locally-built dev binary vs. a globally-installed
1116
- release, say), you can get version skew between the two — the command that
1117
- validates may not be the command that decided. Keep the two in sync (one `gtd`
1118
- on `PATH`, consistently) if you care about that gap.
1119
-
1120
- ### The normalization-only contract on `format:`
1121
-
1122
- A mode's `format:` command may reformat a steering file — whitespace, wrapping,
1123
- reordering — but must NEVER change what a land-capture guard would decide. gtd's
1124
- guards (the review-doc check, the feedback-progress check, the
1125
- answer-completeness check, the require-revert check — `src/StepGuards.ts`)
1126
- decide ONCE, against whichever bytes are on disk at the moment `gtd land` runs,
1127
- which may be before OR after an emitted script's own `format:` line has run (the
1128
- script runs `format:` then `validate:` then the commit — see
1129
- `src/SteeringMode.ts`'s `renderSteeringCommands` — but gtd's decision and the
1130
- driver's script execution are different processes at different times, so there's
1131
- no guaranteed ordering between "gtd decided" and "the script formatted"). That's
1132
- only safe because every built-in guard judges only the content it explicitly
1133
- cares about, not incidental formatting around it — the feedback-progress guard,
1134
- for instance, only checks whether a deleted file's trimmed first line is the
1135
- `NOTHING ACTIONABLE` sentinel, so reindenting the rest of it changes nothing the
1136
- guard reads. If you plug in your own `format:` command, the same rule binds it:
1137
- a formatter that also changes meaning — stripping a paragraph a guard reads —
1138
- makes the guard's decision and the file's actual content disagree, and gtd will
1139
- not catch that for you.
1140
-
1141
- One case never runs your `format:` (or `validate:`) at all: a step whose diff
1142
- DELETES the state's own `file:`. Deleting it is a legitimate outcome — a review
1143
- sign-off's whole diff is the review doc's deletion — and there is nothing left
1144
- to format. Emitting the command anyway would make such a step unlandable, since
1145
- `format:` is the first line of a `set -eu` script and a formatter like
1146
- `prettier --write` exits non-zero on a path that is not there.
1147
-
1148
- ### Built-in steering formats are ordinary modes
1149
-
1150
- `qa` and `review` are gtd's two built-in steering-file formats (parsed and
1151
- validated in-process because `gtd lsp` needs the same parsers for live
1152
- diagnostics), but their `validate:` is not hardcoded or hidden: the compiler
1153
- SEEDS every workflow's `modes:` map with `qa`/`review` entries whose `validate:`
1154
- is the same `gtd check <mode> '<file>'` string described above
1155
- (`src/PatternConfig.ts`, `src/SteeringFormats.ts`'s `seededValidateCommand`).
1156
- That seeded command is visible in `gtd visualize`'s compiled model and in the
1157
- editor JSON schema like any other mode, and it's overridable the same way any
1158
- mode is — declare `modes: { qa: { validate: "your-own-command" } }` (in the
1159
- workflow or in `.gtdrc`) and your command displaces the seed; declaring only a
1160
- `format:` for `qa`/`review` composes with the seeded `validate:` rather than
1161
- replacing it. There is no special-cased built-in behavior a driver needs to know
1162
- about beyond the ordinary mode-resolution rules already documented under
1163
- [The `workflow:` key](#the-workflow-key).
1164
-
1165
- ## Configuration
1166
-
1167
- gtd reads an optional `.gtdrc` config file via
1168
- [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig). With no `workflow:`
1169
- configured anywhere in the cwd→home config chain, the bundled unified workflow
1170
- is used automatically, so a state command works out of the box with no config at
1171
- all. Supported filenames (searched in this order):
1172
-
1173
- - `.gtdrc`
1174
- - `.gtdrc.json`
1175
- - `.gtdrc.yaml`
1176
- - `.gtdrc.yml`
1177
- - `gtd.config.json`
1178
- - `gtd.config.yaml`
1179
-
1180
- ### Schema
1181
-
1182
- `.gtdrc` has exactly three blessed top-level keys:
1183
-
1184
- - **`workflow`** (object, optional) — the whole machine definition (its states,
1185
- plus its own `vars:` defaults and `modes:`). Absent = gtd's built-in default
1186
- is used. Declare it to fully REPLACE that default with your own machine (there
1187
- is no `extends`/merge).
1188
- - **`vars`** (object, optional) — a flat `name -> scalar` map, one layer of the
1189
- merged `it.vars` every template sees.
1190
- - **`modes`** (object, optional) — steering-file modes (`format:`/`validate:`
1191
- shell commands), layered over the active workflow's own `modes:` and gtd's
1192
- built-in validators, so a project can plug in its formatter or linter without
1193
- re-declaring that mode on the workflow itself.
1194
- - **`$schema`** (string, optional) — stripped before validation, so it never
1195
- counts as an unknown key. Point it at the published schema for editor-backed
1196
- autocompletion (this is what `gtd init` writes):
1197
-
1198
- ```
1199
- https://cdn.jsdelivr.net/npm/@pmelab/gtd/schema.json
1200
- ```
1201
-
1202
- That URL serves `schema.json` straight out of the published npm tarball, so it
1203
- always matches the latest release. Pin it to a major with
1204
- `@pmelab/gtd@8/schema.json`, or point at your own install
1205
- (`./node_modules/@pmelab/gtd/schema.json`) to work offline.
1206
-
1207
- Any other top-level key is **rejected**. The engine blesses no VARIABLE NAMES
1208
- either — `testCommand` is workflow-authored data like any other `it.vars` entry,
1209
- not a special key gtd interprets.
1210
-
1211
- ### The `workflow:` key
1212
-
1213
- A declared `workflow:` key fully REPLACES gtd's built-in default. The built-in
1214
- default is itself a YAML asset (`src/workflows/unified.yaml`) compiled through
1215
- the exact same compiler your own `workflow:` value goes through — no privileged
1216
- code path. Its shape:
1217
-
1218
- ```yaml
1219
- workflow:
1220
- vars: # optional — the workflow's own declared `it.vars` defaults
1221
- anyKey: anyScalarValue
1222
- modes: # optional — steering-file modes a state's `mode:` may name
1223
- <name>:
1224
- format: <shell command> # both optional — {} is the format-only tier
1225
- validate: <shell command>
1226
- entry:
1227
- default: <machine name> # which machine is the ROOT instance
1228
- machines:
1229
- <name>:
1230
- model: <string> # optional, opaque harness hint — stamped onto every one of THIS machine's own `prompt` states; declared ONCE per machine, never per state
1231
- params: [<param>, ...] # optional, advisory — documents which $params a caller may bind
1232
- entry: <local or ref key> # this machine's own default local, resolved recursively
1233
- states:
1234
- <local>:
1235
- actor: <string> # forbidden on a commit state, required otherwise
1236
- script: <string> # exactly one of script/prompt/message/commit
1237
- prompt: <string>
1238
- message: <string>
1239
- commit: <string>
1240
- on: # a mapping, DECLARATION ORDER PRESERVED
1241
- "<pattern>": <targetState> # short form
1242
- "<pattern>": {
1243
- to: <targetState>,
1244
- describe: <sentence>,
1245
- action: <label>,
1246
- } # description/action
1247
- retry:
1248
- max: <number>
1249
- otherwise: <targetState>
1250
- label: <string> # optional, opaque display name passed through `gtd next --json`
1251
- file: <string> # optional, an Eta template naming the state's steering file RELATIVE to ".gtd/" — the compiler prepends that directory automatically
1252
- mode: <modeName> # optional, requires "file" — must be declared in `modes:` (qa/review are seeded for you; everything else, including prose, you declare)
1253
- reviewWindow: true # optional — open the review checkout window at rest here
1254
- reviewBase: true # optional — anchor the review window's diff base to this state's most-recent commit
1255
- # reviewBase: <Eta template> # OR a template — rendered (only meaningful entering via --entry) to a commitish that fixes the WHOLE PROCESS's diff base
1256
- requireProgress: true # optional, requires "file" — refuse a turn whose only change deletes this state's own `file:`
1257
- answerGate: true # optional, requires "file" — refuse a turn until every open question in the (qa-mode) `file:` is answered
1258
- requireRevert: true # optional, requires "file" — refuse a turn until the human's review-round paths actually match the review base's parent
1259
- entry: true # optional — an EXTRA reachability root (`entries.manual`), enterable via `gtd --entry <this state's qualified name>` — NOT a precondition for `--entry` (any declared, non-commit state is a valid target)
1260
- <local>: { machine: <name>, with: { <param>: <value> } } # a REFERENCE — instantiates <name> as a child, qualified as `<local>.<childLocal>`
1261
- ```
1262
-
1263
- There is no `memory:` key anywhere in this shape — a state's memory scope is
1264
- never authored, only computed from its position in the machine tree (see
1265
- [Driving the loop](#driving-the-loop) above for the key format and how it
1266
- derives a driver's session id).
1267
-
1268
- The top-level `entry:` key (naming the root machine, `entry.default`) and a
1269
- state's own `entry: true` flag are the same word at two different levels, by
1270
- design: one selects the workflow's root machine, the other opts one state in as
1271
- an extra manual entry point.
1272
-
1273
- A workflow is authored as a TREE of reusable, parameterized machines — a
1274
- gate/loop written once and instantiated several times with different `with:`
1275
- bindings (dedup), or a complex cluster grouped under one name for source
1276
- comprehension (encapsulation). Every reference is expanded at load time into
1277
- concrete, qualified states (`<local>.<childLocal>`, however deep) before the
1278
- engine ever sees the definition — see `src/Machines.ts` for the mechanism.
1279
- MACHINE BOUNDARIES ARE THE UNIT OF CONVERSATIONAL IDENTITY: a machine that holds
1280
- an identity (a planner or a coder persona) declares its own `model:` once, at
1281
- the machine level, instead of repeating it per state — and, per the memory rule
1282
- above, two references to the SAME machine (a dedup instantiation) are always two
1283
- independent instances with two independent memory scopes, never one shared
1284
- conversation across both call sites.
1285
-
1286
- Besides `it.vars` (below), a `script`/`prompt`/`message`/`commit` template sees:
1287
-
1288
- - **`it.startCommit`** — the process's diff base (the commit the current process
1289
- started from, or the base a `--var reviewBase=<commitish>` entry resolved to).
1290
- - **`it.reviewBase`** — the previous review round's boundary, falling back to
1291
- `it.startCommit` on a first review. In the bundled template, an actionable
1292
- round's NEXT review therefore covers the revert of the human's own lines
1293
- (`re-unwind`) followed by the whole lap that re-derives and re-implements them
1294
- — the net diff is the final implementation, the right thing to review, but no
1295
- longer the tiny "just the fixes" delta a quick fix-and-re-review would have
1296
- shown.
1297
- - **`it.retainedBase`** — the process's trace/retry boundary, what a squash
1298
- actually keeps (never moved by a review entry's fixed base).
1299
- - **`it.currentCommit`** / **`it.previousCommit`** — HEAD's hash and its parent,
1300
- at render time.
1301
-
1302
- A template never sees rendered diff CONTENT — no field carries a diff. It names
1303
- a base and leaves the agent to run `git diff <base>` itself; this keeps every
1304
- render cheap (no diff computed on `gtd next`/`gtd lsp`) and the prompt small and
1305
- cacheable.
1306
-
1307
- Authoring or editing a workflow with a coding agent? `skills/authoring/SKILL.md`
1308
- is the agent-facing contract for producing a valid `workflow:` — the state
1309
- model, pattern grammar, load-time rules, and how to verify a change compiles.
1310
-
1311
- > **Upgrading from a pre-8.2 `workflow:`?** The old flat `states:` shape (with a
1312
- > per-state `initial: true`/`reviewEntry: true`/`fixEntry: true` flag) is no
1313
- > longer accepted — finish or `gtd abandon` any in-flight process before
1314
- > upgrading, since the old and new shapes aren't compatible mid-process. Wrap
1315
- > your states under a single
1316
- > `machines: { <name>: { entry: <initial state>, states: {...} } }` and declare
1317
- > `entry: { default: <name> }` at the top level (moving any
1318
- > `reviewEntry`/`fixEntry` state to a plain per-state `entry: true` flag,
1319
- > entered via `gtd --entry <state>` — see the next note).
1320
-
1321
- > **Upgrading a `workflow:` that still declares `entry.review`/`entry.fix`?**
1322
- > Those two keys, and the `gtd review <commitish>`/`gtd fix` commands that used
1323
- > them, are gone. Replace `entry.review: <target>`/`entry.fix: <target>` with a
1324
- > plain `entry: true` flag on that same state, and enter it with
1325
- > `gtd --entry <state>` instead of the removed commands.
1326
- > `gtd review <commitish>` required a clean tree and a `<commitish>` argument;
1327
- > the replacement instead captures whatever is pending in the working tree (just
1328
- > like an ordinary `gtd land`) and takes the commitish as a
1329
- > `--var reviewBase=<commitish>` override consumed by that state's own
1330
- > template-form `reviewBase:` (see the `workflow:` shape above and
1331
- > [`gtd --entry`](#commands)). `gtd fix` likewise becomes
1332
- > `gtd --entry <the state that was entry.fix>` (e.g. the bundled template's
1333
- > `gtd --entry fix-precheck`).
1334
-
1335
- > **Upgrading a `workflow:` that still declares a per-state `model:` or
1336
- > `memory:`?** `model:` moved from a state key to a MACHINE key: declare it once
1337
- > on the `machines.<name>:` entry instead of on every one of that machine's
1338
- > states — it is stamped onto every one of that machine's own `prompt` states
1339
- > automatically (see the `workflow:` shape above). A state that still declares
1340
- > its own `model:` is a load error naming the machine to move it to, never a
1341
- > silently ignored key. `memory:` is gone outright, with **no** replacement key
1342
- > — a workflow author simply removes it; a state's memory scope is now computed
1343
- > from its position in the machine tree instead of authored (see
1344
- > [Driving the loop](#driving-the-loop)). The bundled template was also
1345
- > restructured so machine boundaries line up with this new identity model,
1346
- > renaming twenty-two states:
1347
- >
1348
- > - `building` → `build.building`
1349
- > - `decompose` → `build.decompose` → `design.decompose`
1350
- > - `squashing` → `build.squashing`
1351
- > - `review.building` → `build.addressing`
1352
- > - `packages.building` → `packages.item.building`
1353
- > - `packages.closing` → `packages.item.closing`
1354
- > - `packages.health.check` → `packages.item.health.check`
1355
- > - `packages.health.fix` → `packages.item.fix-suite`
1356
- > - `packages.health.escalate` → `packages.item.health.escalate`
1357
- > - `packages.spec.review` → `packages.item.spec.review`
1358
- > - `packages.spec.fix` → `packages.item.fix-spec`
1359
- > - `build.check` → `build.health.check`
1360
- > - `build.escalate` → `build.health.escalate`
1361
- > - `review.reviewing` → `build.review.reviewing`
1362
- > - `review.await-review` → `build.review.await-review`
1363
- > - `review.deciding` → `build.review.deciding`
1364
- > - `review.collecting` → `build.review.collecting`
1365
- > - `product.author` → `design.product-author`
1366
- > - `product.answer` → `design.product-answer`
1367
- > - `technical.author` → `design.technical-author`
1368
- > - `technical.answer` → `design.technical-answer`
1369
- >
1370
- > (`decompose`'s two hops both land in this same release, so a process upgrading
1371
- > from before either restructure only ever sees one hop: `decompose` →
1372
- > `design.decompose`.) Because of these renames, an in-flight process left
1373
- > resting at one of the old qualified state names can no longer be resumed after
1374
- > upgrading — those names no longer exist in the definition, and gtd refuses
1375
- > loudly rather than silently treating the rest as idle. Run `gtd abandon` to
1376
- > discard it and start over (or finish the process on the pre-upgrade workflow
1377
- > version first).
1378
-
1379
- > **Upgrading a `workflow:` from the old two-flow (`.gtd/TODO.md` vs.
1380
- > `.gtd/REQUIREMENTS.md`) shape?** The bundled template collapsed that fork into
1381
- > one flow: `idle` now has a single outgoing edge — any change at all starts the
1382
- > process, never a fork on which steering file you create — and
1383
- > `plan-gate.check`/`spec-gate.check` merged into one shared `start-gate.check`.
1384
- > The old plan-iteration machine's `plan.planning`/`plan.await-plan` states and
1385
- > its monolithic `build.building` state are gone outright; every concern now
1386
- > goes through the same per-package build queue instead. Renamed:
1387
- > `design.product-author` → `design.triage`, `design.product-answer` →
1388
- > `design.gate.answer`, `design.technical-author` → `architecture.author`,
1389
- > `design.technical-answer` → `architecture.gate.answer`, `design.decompose` →
1390
- > `architecture.decompose` (architecture is now its own sibling machine with its
1391
- > own memory scope, not nested under `design`). The `prose` mode is gone and
1392
- > there is no more free-form _plan_ file — `todoFile` itself came back later
1393
- > with a different job: `idle`'s own mode-less `file:` hint, gtd's sketch pad
1394
- > that no state writes or reads. As with every rename above, an in-flight
1395
- > process resting at one of the old names can no longer be resumed;
1396
- > `gtd abandon` it (or finish it on the pre-upgrade workflow version) before
1397
- > upgrading.
1398
-
1399
- > **Upgrading a `workflow:` that still references `build.addressing`?** That
1400
- > state is REMOVED, not renamed — the implementer's own follow-through on review
1401
- > feedback is gone outright, since an actionable review round is now re-planned
1402
- > from scratch through a new root-level `re-unwind` state (reverting the human's
1403
- > hand-edit) instead of being built upon. A non-actionable round (an approving
1404
- > remark with no code edit) short-circuits straight to `build.squashing` instead
1405
- > of spending a lap on nothing. As with every rename above, an in-flight process
1406
- > resting at `build.addressing` can no longer be resumed after upgrading;
1407
- > `gtd abandon` it (or finish it on the pre-upgrade workflow version) first.
1408
-
1409
- ### Variables
1410
-
1411
- Every template — `script`/`prompt`/`message`/`commit`, a machine's own `model:`,
1412
- and a state's `file:` — sees `it.vars`: a flat `Record<string, string>`
1413
- assembled from four layers, **later wins**:
1414
-
1415
- 1. **The workflow's own `vars:` key** (sibling to `entry:`/`machines:`) — the
1416
- workflow author's declared defaults. The unified template declares
1417
- `vars: { testCommand: "npm test" }`, read by `build.health.check`'s script as
1418
- `<%~ it.vars.testCommand %>`.
1419
- 2. **A top-level `.gtdrc` `vars:` key** (a sibling of `workflow:`, NOT nested
1420
- inside it) — per-repo tuning without redefining the whole workflow.
1421
- 3. **The current process's entry `--var` overrides**, if it was started via
1422
- `gtd --entry <state>` — repeatable `--var <name>=<value>` flags fixed at the
1423
- moment of entry and recorded as `Gtd-Var: <name>=<value>` trailers on the
1424
- process's oldest commit, re-parsed on every turn for as long as that process
1425
- is underway. Each `--var` name must already be declared by layer 1 or 2; an
1426
- undeclared name is a usage error, not a silent no-op.
1427
- 4. **`GTD_<UPPERCASE-name>` environment variables** — highest precedence,
1428
- checked at every invocation, case-insensitively against each name already
1429
- declared by layers 1–3: `GTD_TESTCOMMAND` overrides `testCommand`. The
1430
- environment can only OVERRIDE a name an earlier layer already declared — a
1431
- `GTD_*` var matching no declared name is silently ignored.
1432
-
1433
- Values in layers 1–2 must be YAML scalars (string/number/boolean), coerced to
1434
- strings at load time; an object or array value is a load error. A `--var` value
1435
- (layer 3) is always a single-line string as given on the command line.
1436
-
1437
- ```yaml
1438
- # .gtdrc — overriding the unified template's testCommand
1439
- vars:
1440
- testCommand: npm run test:ci
1441
- ```
1442
-
1443
- ```bash
1444
- # highest precedence — beats both the workflow default and the .gtdrc value above
1445
- GTD_TESTCOMMAND="npm run test -- --bail" gtd next
1446
- ```
1447
-
1448
- #### The voice
1449
-
1450
- gtd ships its own writing voice for the files it generates — the default, not an
1451
- opt-in. It is a specialisation of the "Spartan" output style from
1452
- [alexgreensh/attention-span](https://github.com/alexgreensh/attention-span)
1453
- (AGPL-3.0), written from a reading of that project's version `0.6`: gtd's own
1454
- prose stating the same density discipline, rewritten for deliverables (files
1455
- that run as long as the work needs) rather than chat replies. No upstream text
1456
- ships in gtd's bundle. This is a point-in-time derivation with no refresh
1457
- mechanism — it will silently go stale as upstream moves on, and nothing in gtd
1458
- will notice.
1459
-
1460
- It is two independently-overridable variables, each an ordinary `vars:` entry
1461
- that can be overridden or blanked through the same layers as any other (a
1462
- top-level `.gtdrc` `vars:` key, or the matching `GTD_STYLEBLOCK` /
1463
- `GTD_STYLEFORMATCONTRACT` environment variable):
1464
-
1465
- - **`styleBlock`** — the voice itself, injected at all seven prompt states that
1466
- generate content, not just three: the free-prose ones — the `.gtd/packages/`
1467
- package files (`architecture.decompose`), `.gtd/SPEC_FEEDBACK.md`
1468
- (`packages.item.spec.review`), and `.gtd/COMMIT_MSG.md` (`build.squashing`) —
1469
- plus the four machine-parsed states named in the next bullet. Blanking
1470
- `GTD_STYLEBLOCK` strips the voice from all seven, including the machine-parsed
1471
- ones, not only the free-prose three. In short: why density matters before any
1472
- rule, answer-first with no preamble or restatement, blunt and imperative,
1473
- plain words, bold carries the load, ship the artifact bare, compressing is not
1474
- dropping, one idea per block, flag risk in one blunt line, never narrate the
1475
- work — and never-trim outranks every other rule in the set.
1476
- - **`styleFormatContract`** — the structural override for machine-parsed files:
1477
- the format contract (headings, checkbox rows, marker lines) outranks the
1478
- voice, and a violation refuses the turn. It renders at the top of the prompt,
1479
- ahead of the role sentence and well before any state-specific format-contract
1480
- text — `styleBlock` first, then `styleFormatContract`, at the four prompt
1481
- states whose output a parser reads: the two `qa`-mode steering files
1482
- (`.gtd/REQUIREMENTS.md` at `design.triage`, `.gtd/ARCHITECTURE.md` at
1483
- `architecture.author`) and the `review`-mode one (`.gtd/REVIEW.md` at
1484
- `build.review.reviewing`), plus `.gtd/REQUIREMENTS.md` again at
1485
- `build.review.collecting`, which classifies a review round straight into it.
1486
-
1487
- Three more generated files carry no injected voice, because a script — not an
1488
- agent — writes them: `.gtd/FEEDBACK.md` (verbatim test-suite output plus a HEAD
1489
- stamp — the tool's content, not gtd's prose), `.gtd/NEXT.md` (a bare path, no
1490
- prose to style), and `.gtd/REVIEW_RAW.md` (gtd's own prose, hand-tightened in
1491
- the voice directly in `build.review.deciding`'s script rather than templated in
1492
- through either variable).
1493
-
1494
- ### Lookup and precedence
1495
-
1496
- gtd walks from the current working directory **up to your home directory** (or
1497
- to the filesystem root when cwd is outside home), collecting every `.gtdrc` it
1498
- finds along the way. All found levels are **deep-merged**, with the **innermost
1499
- (cwd) config winning** on conflicts — so a shared `.gtdrc` in a worktree-parent
1500
- directory cascades to every checkout beneath it, while any individual checkout
1501
- can still override with its own `.gtdrc`.
1502
-
1503
- ### Validation and errors
1504
-
1505
- Config-shape problems (unknown keys, wrong types, unreadable file references)
1506
- are collected together; if the shape is clean, the assembled definition is
1507
- additionally run through the engine's own validation. A bad config throws
1508
- **one** error listing every finding, at load time — before anything touches the
1509
- repository — never partially, and never deferred to land time:
1510
-
1511
- ```
1512
- workflow config:
1513
- - state "idle": must declare exactly one of script/prompt/message/commit (found 2)
1514
- - state "idle": "on" target "nowhere" is not a defined state
1515
- ```
1516
-
1517
- Those findings include the **semantic graph checks**: every `on` target and
1518
- `retry.otherwise` must name a defined state, and every state must be
1519
- **reachable** from the initial state. All load failures exit **1** and write to
1520
- **stderr**, never stdout.
1521
-
1522
- Many of these problems never reach gtd at all if your editor validates against
1523
- the [published schema](#schema), which fully types the `workflow:` key. The
1524
- rules JSON Schema cannot express — exactly one content kind, `entry.default`
1525
- resolving to a real state, targets naming defined states, reachability — remain
1526
- the compiler's job at load time.
1527
-
1528
- ## Repository requirements
1529
-
1530
- - **Single writer, linear branch.** A process's history is walked via
1531
- **first-parent** commits only.
1532
- - **Test/build artifacts must be gitignored.** This is **load-bearing**, not a
1533
- style preference: every land decision detects "clean" via
1534
- `git diff --name-status HEAD` (tracked changes) unioned with
1535
- `git ls-files --others --exclude-standard` (untracked files, classified by
1536
- content against the base — one that is already there with the same bytes is
1537
- not a change, and a file that exists on disk is never reported as a deletion,
1538
- however the index sees it), which silently omits anything matched by
1539
- `.gitignore`. If a `script` state's command (or the build it triggers) writes
1540
- output — a `dist/`, a coverage report, a log file — into the working tree, the
1541
- tree never goes clean after a green run, and the check's `"C"` pattern never
1542
- fires. Gitignore every path your scripts write before wiring gtd into a repo.
1543
- - **Repository root invocation.** Every state subcommand must run from the git
1544
- repository root. `--help`/`--version` (and the `help`/`version` subcommands),
1545
- `lsp`, `init`, `visualize`, `check`, and `install` skip this guard entirely
1546
- (`visualize` still reads the `.gtdrc` workflow, but needs no git state; `init`
1547
- may even run outside a repository to seed a shared parent-dir config).
1548
- - **Linked worktrees are independent.** N `git worktree` worktrees of one
1549
- repository (sharing a single `.git`) each run their own gtd process: state is
1550
- derived from that worktree's own HEAD, and the review checkout window's refs
1551
- live in git's per-worktree `refs/worktree/gtd/*` namespace, so a review
1552
- resting in one worktree neither blocks nor rewrites any other.
1553
-
1554
- ## Editor integration
1555
-
1556
- `gtd lsp` starts an LSP server over stdio for `.gtd/` steering files — a symbol
1557
- per `review`-mode chunk that still has an unchecked hunk (an outline of the
1558
- packages left to review) plus check/uncheck actions over those chunks,
1559
- go-to-definition from a `review`-mode hunk line into the file it points at (at
1560
- its `#line` — a hunk's path is a single whitespace-delimited `./`-relative
1561
- token, so a hyphen in a filename stays part of the path, never a note
1562
- separator), symbols over a `qa`-mode file's open questions plus "pick this
1563
- option"/"uncheck this option" code actions on each option — offered anywhere on
1564
- the option's list item, including any wrapped continuation lines, not just its
1565
- own `- [ ]` line — diagnostics for both (live as you edit), and a
1566
- `gtd.openSteeringFile` command that jumps to the current state's steering file —
1567
- including `idle`, whose `.gtd/TODO.md` hint gives the one keybinding an answer
1568
- even before a process has started. The command only names that path — it never
1569
- stat-checks or creates it — so on a repo that has never run gtd, `.gtd/` may not
1570
- exist yet and editors differ on opening a file whose parent directory is missing
1571
- (an empty buffer that creates it on save vs. refusing the path outright); this
1572
- bites only the very first sketch in a fresh repo, since the workflow's own check
1573
- scripts create the state directory on the first `gtd next`/`gtd land`.
1574
-
1575
- It is config-driven via each state's `file:`/`mode:`, and falls back to basename
1576
- dispatch (`REVIEW.md` → `review`) with no config in sight. `qa` and `review` are
1577
- gtd's built-in steering-file FORMATS, each with its own outline/actions/
1578
- go-to-definition and a VALIDATOR gtd itself implements; a mode's `format:` and
1579
- `validate:` are shell commands a workflow (or a project's `.gtdrc`) declares for
1580
- itself, so you bring your own formatter and your own checkers. Overriding one of
1581
- `qa`/`review`'s `validate:` with a shell command does NOT lose its outline/
1582
- actions — those come from the FORMAT (the name), independent of who validates —
1583
- but `gtd lsp` never runs a shell command per keystroke, so live diagnostics
1584
- become one `Information` notice pointing at `gtd validate` instead of the
1585
- built-in findings. Any OTHER mode name — a project's own declared name (e.g.
1586
- `prose`, for a free-form note) — has no built-in format, so it gets no live
1587
- editor support at all: `gtd validate`'s emitted script and the `gtd land` gate
1588
- still format and validate it like any other mode.
1589
-
1590
- ## Development
1591
-
1592
- ```bash
1593
- npm install
1594
- npm run dev # run from source, no build (node dev/run.mjs)
1595
- npm run build # tsdown → dist/gtd.bundle.mjs
1596
- npm test # the whole gate, via turbo — cached and parallel
1597
- npx turbo run test:unit # one task, cached (add --force to bypass)
1598
- npx turbo run test:e2e:live # builds first (turbo dependsOn), then @live
1599
- npm run test:changed # local pre-flight: only unit/@inmem tests git says changed
1600
- npm run test:mutation # StrykerJS mutation testing (manual only, ~10 min)
1601
- npm run typecheck
1602
- npm run lint
1603
- ```
1604
-
1605
- `npm test` is a turbo task graph (`turbo.json`): each check declares its own
1606
- `inputs`, so an unchanged check is skipped, and a check that does run is run in
1607
- parallel with the others. Caveat from the `test:e2e:live` task's `build`
1608
- dependency: a bare `npm run test:e2e:live` skips the build, so use
1609
- `npx turbo run test:e2e:live` to test against a fresh bundle.
1610
-
1611
- A pre-commit hook is installed automatically via the `prepare` script when you
1612
- run `npm install` on a fresh clone — it runs
1613
- [lint-staged](https://github.com/lint-staged/lint-staged) with
1614
- [oxfmt](https://oxc.rs/docs/guide/usage/formatter.html), mirroring the
1615
- `format:check` step enforced in CI.
1616
-
1617
- The decision core is pure and IO-free: the pattern machine's shape (states,
1618
- patterns, retry) is a plain-data `WorkflowDefinition` (`src/PatternMachine.ts`),
1619
- and the same module's `resolveState`/`step` are the pure resolver/interpreter
1620
- over it — so the whole engine is trivially unit-testable in isolation. All
1621
- git/filesystem/template IO is confined to the edge (`src/Edge.ts`), whose
1622
- `currentRest` resolves everything derivable from where the process rests right
1623
- now into a single snapshot, and whose `planStep`/`planEntry` pair separates
1624
- deciding a transition from performing it — so a command's own capture guards run
1625
- between the two. The edge reaches the outside world through two content ports
1626
- (`src/RepoFiles.ts` for working-tree and committed reads, `src/CommandRunner.ts`
1627
- for the one place gtd spawns a subprocess itself), with the `gtd land` capture
1628
- guards (`src/StepGuards.ts`) built on top of them.
1629
-
1630
- `src/testing/` holds the in-memory git/config/filesystem test double every
1631
- `@inmem` scenario and unit test runs against instead of a real repo — it never
1632
- ships (a lint rule and a build-time check both enforce that) and is trustworthy
1633
- only because the same `GitOperations` contract suite runs against a real git
1634
- repo too.
76
+ gtd itself never executes anything — the driver owns running scripts, and every
77
+ `gtd next` call is strictly mutation-free, safe to poll or peek at any time. See
78
+ [Driving the loop](https://github.com/pmelab/gtd/blob/main/docs/driver.md) for
79
+ the full protocol, including the `message`/`capture` gates and the stalled case
80
+ this sketch leaves out.
1635
81
 
1636
- Releases are automatic: push releasable Conventional Commits (`fix:`, `feat:`,
1637
- or breaking changes) to `main` and semantic-release computes the next version,
1638
- builds the bundle, tags it, and publishes.
82
+ See [gtd --help](https://github.com/pmelab/gtd/blob/main/docs/cli.md) for the
83
+ full command/flag reference, and
84
+ [Configuration](https://github.com/pmelab/gtd/blob/main/docs/configuration.md)
85
+ for how to inspect or replace the workflow itself.
1639
86
 
1640
87
  ## License
1641
88