@jaybeeuu/agent-cortex 1.41.1 → 1.43.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 (115) hide show
  1. package/.agents/skills/style-versioning/SKILL.md +73 -2
  2. package/.github/workflows/ci.yml +52 -32
  3. package/AGENTS.md +23 -2
  4. package/CHANGELOG.md +189 -0
  5. package/README.md +125 -73
  6. package/agents/README.md +17 -4
  7. package/agents/ralph-plan/agent.md +7 -3
  8. package/agents/ralph-plan.agent.md +7 -3
  9. package/bin/agent-cortex.mjs +48 -30
  10. package/bin/installers/pi.mjs +885 -237
  11. package/claude-extras/scripts/statusline-command.sh +0 -0
  12. package/docs/claude-hooks.md +5 -4
  13. package/docs/commit-signing.md +231 -0
  14. package/docs/ideas/ban-content-assertion-tests.md +3 -1
  15. package/docs/ideas/dedicated-review-tests-skill.md +71 -0
  16. package/docs/ideas/enable-signed-commit-enforcement-changesets-bot-commits-must-be-signed.md +10 -1
  17. package/docs/ideas/extension-manifests.md +5 -0
  18. package/docs/ideas/unify-the-ticket-and-task-decomposition-workflows.md +71 -0
  19. package/docs/research/disable-model-invocation.md +103 -0
  20. package/docs/research/skill-design-research.md +2 -2
  21. package/docs/skills/skill-anatomy.md +5 -1
  22. package/docs/technical-direction/harness-config.md +25 -1
  23. package/docs/technical-direction/migration-execution-labels.md +17 -9
  24. package/extensions/agent-modes/discover.test.ts +19 -0
  25. package/extensions/agent-modes/discover.ts +25 -3
  26. package/extensions/session-start/README.md +38 -0
  27. package/extensions/session-start/index.test.ts +122 -0
  28. package/extensions/session-start/index.ts +27 -0
  29. package/extensions/session-start/package.json +19 -0
  30. package/extensions/session-start/tsconfig.json +12 -0
  31. package/extensions/subagent/README.md +1 -1
  32. package/extensions/subagent/agents.test.ts +176 -0
  33. package/extensions/subagent/agents.ts +102 -11
  34. package/extensions/subagent/index.ts +2 -1
  35. package/extensions/subagent/package.json +1 -1
  36. package/lib/cli.mjs +35 -9
  37. package/package.json +10 -6
  38. package/pi/settings.json +1 -7
  39. package/plugin.json +1 -1
  40. package/pnpm-workspace.yaml +6 -0
  41. package/scripts/check-changeset.mjs +42 -0
  42. package/scripts/install-instructions.sh +0 -0
  43. package/scripts/lib/release-gates.mjs +61 -0
  44. package/scripts/lib/verify-worker-tree.mjs +107 -0
  45. package/scripts/resolve-publish-command.mjs +17 -0
  46. package/scripts/sync-plugin-version.sh +0 -0
  47. package/skills/engineering/grill-with-docs/SKILL.md +3 -2
  48. package/skills/engineering/improve-codebase-architecture/REFERENCE.md +5 -0
  49. package/skills/engineering/improve-codebase-architecture/SKILL.md +2 -1
  50. package/skills/planning/create-task/SKILL.md +8 -3
  51. package/skills/planning/create-task/scripts/create-chores.ts +4 -1
  52. package/skills/planning/prd-to-tasks/REFERENCE.md +2 -2
  53. package/skills/planning/prd-to-tasks/SKILL.md +9 -4
  54. package/skills/planning/request-refactor-plan/FORMAT.md +5 -0
  55. package/skills/planning/request-refactor-plan/SKILL.md +3 -2
  56. package/skills/planning/spec-to-tickets/REFERENCE.md +82 -0
  57. package/skills/planning/spec-to-tickets/SKILL.md +143 -0
  58. package/skills/planning/write-a-prd/FORMAT.md +6 -0
  59. package/skills/planning/write-a-prd/SKILL.md +9 -6
  60. package/skills/planning/write-a-ticket/EXAMPLES.md +133 -0
  61. package/skills/planning/write-a-ticket/SKILL.md +77 -59
  62. package/skills/productivity/bd-tool/SKILL.md +27 -2
  63. package/skills/productivity/grill-me/SKILL.md +11 -0
  64. package/skills/review/review-security/scripts/install-gitleaks.sh +0 -0
  65. package/skills/workflow/git-workflow/SKILL.md +35 -1
  66. package/skills/workflow/plan/SKILL.md +20 -8
  67. package/skills/workflow/ralph/REFERENCE.md +20 -2
  68. package/skills/workflow/ralph/SKILL.md +4 -1
  69. package/skills/workflow/run-pipeline-stage/SKILL.md +17 -5
  70. package/skills/workflow/run-pipeline-stage/playbooks/code.md +2 -0
  71. package/skills/workflow/run-pipeline-stage/playbooks/document.md +3 -0
  72. package/skills/workflow/run-pipeline-stage/playbooks/fix.md +2 -0
  73. package/skills/workflow/run-pipeline-stage/prompts/stage-runner.md +11 -0
  74. package/skills/workflow/using-agent-skills/SKILL.md +1 -0
  75. package/test/cli.test.mjs +26 -29
  76. package/test/create-chores.test.mjs +12 -0
  77. package/test/fake-bd.test.mjs +72 -0
  78. package/test/helpers/fake-bd.mjs +26 -6
  79. package/test/helpers/fake-pi.mjs +132 -0
  80. package/test/pi-installer.test.mjs +345 -286
  81. package/test/pi-register.test.mjs +342 -0
  82. package/test/pi-sweep.test.mjs +619 -0
  83. package/test/release-gates.test.mjs +190 -0
  84. package/test/verify-worker-tree.test.mjs +120 -0
  85. package/token-map.README.md +7 -6
  86. package/token-map.json +6 -5
  87. package/extensions/agent-guardrails/node_modules/.bin/pi +0 -21
  88. package/extensions/agent-guardrails/node_modules/.bin/tsc +0 -21
  89. package/extensions/agent-guardrails/node_modules/.bin/tsserver +0 -21
  90. package/extensions/agent-guardrails/node_modules/.bin/tsx +0 -21
  91. package/extensions/agent-modes/node_modules/.bin/pi +0 -21
  92. package/extensions/agent-modes/node_modules/.bin/tsc +0 -21
  93. package/extensions/agent-modes/node_modules/.bin/tsserver +0 -21
  94. package/extensions/agent-modes/node_modules/.bin/tsx +0 -21
  95. package/extensions/session-start.ts +0 -44
  96. package/extensions/skill-stats/node_modules/.bin/pi +0 -21
  97. package/extensions/skill-stats/node_modules/.bin/tsc +0 -21
  98. package/extensions/skill-stats/node_modules/.bin/tsserver +0 -21
  99. package/extensions/skill-stats/node_modules/.bin/tsx +0 -21
  100. package/extensions/subagent/node_modules/.bin/pi +0 -21
  101. package/extensions/subagent/node_modules/.bin/pi-ai +0 -21
  102. package/extensions/subagent/node_modules/.bin/tsc +0 -21
  103. package/extensions/subagent/node_modules/.bin/tsserver +0 -21
  104. package/extensions/subagent/node_modules/.bin/tsx +0 -21
  105. package/lib/pi-packages.mjs +0 -169
  106. package/skills/planning/create-task/scripts/node_modules/.bin/tsc +0 -21
  107. package/skills/planning/create-task/scripts/node_modules/.bin/tsserver +0 -21
  108. package/skills/planning/create-task/scripts/node_modules/.bin/tsx +0 -21
  109. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsc +0 -21
  110. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsserver +0 -21
  111. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsx +0 -21
  112. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsc +0 -21
  113. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsserver +0 -21
  114. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsx +0 -21
  115. package/test/pi-packages.test.mjs +0 -295
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: write-a-ticket
3
- description: Write a well-structured ticket for an external issue tracker (e.g. Jira) that an engineer can act on without follow-up questions. Use when asked to "write a ticket", "file this in Jira", or "create a work item" — not for creating implementation tasks in a ralph/bd loop.
3
+ description: Write a clear, reviewable ticket for an external issue tracker (Jira, Linear, GitLab, GitHub Issues) that an engineer can act on without follow-up questions. Use when asked to "write a ticket", "file this in Jira", or "create a work item" — not for beads in a ralph/bd loop.
4
4
  argument-hint: "The work to ticket: goal, epic/initiative, constraints, or paste a draft"
5
5
  ---
6
6
 
@@ -9,104 +9,122 @@ argument-hint: "The work to ticket: goal, epic/initiative, constraints, or paste
9
9
  ## When to use
10
10
 
11
11
  - Asked to "write a ticket", "file this in Jira", or "create a work item".
12
- - Drafting an actionable work item for a human engineering audience in an external issue tracker (Jira, Linear, GitHub Issues).
13
- - Checking an existing ticket for clarity before it goes to the team.
12
+ - Drafting an actionable work item for a human engineering audience in an external tracker.
13
+ - Reviewing an existing ticket for clarity before it goes to the team.
14
14
 
15
15
  ## When NOT to use
16
16
 
17
- - Creating implementation tasks for the ralph/bd loop — those are beads executed by agents, not tickets read by engineers.
18
- - Writing a requirements document for a feature that is not yet actionable — run `write-a-prd` first and link the PRD from the ticket.
17
+ - Breaking a whole PRD/RFC/spec into many tickets — use `spec-to-tickets`, which calls this skill per ticket.
18
+ - Creating implementation tasks for the ralph/bd loop — those are beads executed by agents; use `prd-to-tasks` or `create-task`.
19
+ - Writing a requirements document for work that is not yet actionable — run `write-a-prd` first.
19
20
 
20
21
  ## Workflow
21
22
 
22
- 1. **Gather context.** Confirm the goal of the work, the epic/RFC/initiative it belongs to (if any), known constraints or decisions, and relevant code locations, schemas, or prior art. Outcome: you can state the ticket's purpose in one sentence. If you cannot, ask before writing.
23
+ 1. **Gather context.** Confirm the goal, the parent ticket or epic, the spec it follows, the decisions already made, and the entry point in the code. Outcome: you can state what this ticket does in one sentence. If you cannot, ask before writing.
23
24
 
24
- 2. **Draft the ticket.** Work through the template below. Every section has a purpose — write it only if it earns its place, and never omit a required section without recording why.
25
+ 2. **Settle open questions.** Resolve every question with the human while drafting. When a question cannot be resolved now, split a blocking spike ticket and depend on it, or ask the human to find the answer. A question may stay in the body only when the human explicitly agrees to leave it open — record it under `Open questions` with the owner of the answer. Ship no question the human has not agreed to.
26
+
27
+ 3. **Draft the body** from the template below, then check it against the format rules and the verification checklist.
28
+
29
+ 4. **Hand over the draft.** Present the body for review and get the human's agreement before it is created or filed. The draft is the review artefact — nothing reaches the tracker unseen.
25
30
 
26
31
  ```markdown
27
32
  ## Context
28
33
 
29
- <1–3 sentences: why this work exists, and which epic/RFC/ADR it belongs to. Link to it — never copy-paste its content.>
34
+ <1–5 sentences of pointers: parent ticket or epic, where the approach lives
35
+ (RFC/ADR section), the decisions already made, and what this depends on.
36
+ Reference these — do not explain them.>
30
37
 
31
38
  ## Description
32
39
 
33
- <What to build or change. Describe the outcome, not the implementation steps, and state scope explicitly — what is in and what is out.>
40
+ <2–4 sentences. What this ticket does and the behaviour it produces — the goal,
41
+ stated as the lead-in to the scope bullets. Leave detail to the sections below.>
34
42
 
35
- ## Acceptance criteria
43
+ ## In scope
36
44
 
37
- - [ ] <Specific, independently verifiable criterion — e.g. "given X, the API returns Y">
38
- - [ ] <...>
45
+ - <a distinct deliverable this ticket owns>
46
+ - <...>
39
47
 
40
- ## Technical notes
48
+ ## Out of scope
41
49
 
42
- <Links to relevant code, agreed schemas, architectural decisions, or upstream constraints. A pointer, not a design document — decisions that need more space belong in an ADR or RFC.>
50
+ - <adjacent work explicitly not included — name the ticket that owns it where known>
43
51
 
44
- ## Testing strategy
52
+ ## Acceptance criteria
45
53
 
46
- <Optional. Only when testing needs are non-obvious or a level was agreed — unit, integration, contract, E2E. Omit when team defaults apply.>
54
+ - [ ] <independently verifiable check>
55
+ - [ ] <...>
47
56
 
48
- ## Monitoring strategy
57
+ ## Testing approach
49
58
 
50
- <Optional. Only when the change adds metrics, alerts, log events, dashboards, or a phased rollout. Omit when there is no meaningful observability footprint.>
59
+ <Optional. Which specs, what they assert, and any setup gotcha. Omit when team
60
+ defaults apply.>
51
61
 
52
- ## Notes
62
+ ## Technical notes
53
63
 
54
- <Optional. Genuinely useful details with no other home. If you reach for this often, restructure the ticket.>
64
+ - **Entry point:** `path/to/file.ts:42` (`symbol`, `symbol`)
65
+ - <a decisive fact: a signature that changes, a library or convention to follow,
66
+ a field injected elsewhere>
67
+
68
+ ## Open questions
69
+
70
+ <Optional, and only when the human has explicitly agreed to leave a question
71
+ open. One bullet per question, each naming who owns the answer. Omit this
72
+ section when there are none.>
55
73
  ```
56
74
 
57
- 3. **Review against the checklist.** Work through the verification checklist below before finalising.
75
+ ### Format rules
76
+
77
+ - **Link, don't copy.** Reference the spec by link or section; never paraphrase it. A reader who needs the rationale opens the source.
78
+ - **Point at the entry, not the inventory.** Technical notes lead with the entry point — 1–3 links to where the work begins — plus only the facts that change how it is done. A full list of touched files means you have written the code in prose.
79
+ - **Scope is the contract.** In scope and Out of scope say what the ticket owns; Technical notes only show where to begin.
80
+ - **Every bullet is a distinct deliverable or check.** Merge any two that restate each other, and cut any that add neither.
81
+ - **Bullets over paragraphs, and no tables in the body** — trackers render tables inconsistently and they are slow to scan.
82
+ - **Budgets are guidance, not limits.** Context ≤ 3 sentences; Description ≤ 4 sentences; In scope ≤ 8 bullets; Out of scope ≤ 6 bullets; Acceptance criteria ≤ 12 items; Technical notes ≤ 6 bullets. Extend a section when the work genuinely needs it — a larger scope, or detail that makes the goal clearer — but treat that as the exception, not the rule. Aim for the smallest body that is still complete.
58
83
 
59
84
  ## Red Flags
60
85
 
61
- - Writing implementation steps into the description — describe the outcome, not the how.
86
+ - Writing the code in prose — listing every file touched, or stepping through the edits.
87
+ - A Description that explains the RFC or the deliberation instead of stating what this ticket does.
62
88
  - Acceptance criteria that cannot be verified: "works correctly", "is tested".
63
- - Copy-pasting context instead of linking to the epic, RFC, or ADR.
64
- - Padding sections with filler to look complete — a short, accurate ticket beats a padded one.
65
- - Omitting a required section without recording why.
89
+ - Padding a section to reach a budget, or exceeding one without the work to justify it.
90
+ - Copy-pasting spec content instead of linking to it.
91
+ - Leaving a question, `TBD`, or "we need to decide" in the body when the human has not agreed to it — an unagreed open question is a blocked implementer.
66
92
 
67
93
  ## Common Rationalizations
68
94
 
69
- | Rationalization | Rebuttal |
70
- |---|---|
71
- | "The engineer will figure it out" | Skilled engineers can — but questions are a blocked ticket. The ticket must stand alone. |
72
- | "More detail is safer" | Detail only helps if it informs the implementer. Every extra sentence is noise to skim. |
73
- | "We will verify acceptance criteria in review" | Unverifiable criteria cannot be checked. Write given/outcome pairs instead. |
74
- | "We will discuss the details in standup" | The ticket is the record. If it cannot stand alone, the discussion is lost. |
95
+ | Rationalization | Rebuttal |
96
+ | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
97
+ | "The engineer will figure it out" | Skilled engineers can — but questions are a blocked ticket. The ticket must stand alone. |
98
+ | "More detail is safer" | Detail helps only if it informs the implementer. Every extra sentence is noise to skim. |
99
+ | "The reviewer should see every file touched" | The reviewer needs the scope and somewhere to start, not an inventory. The implementer finds the rest. |
100
+ | "I'll flag the open question in the ticket" | Only if the human agrees to leave it open. Otherwise resolve it or split a spike — an unagreed question is a blocked implementer. |
75
101
 
76
102
  ## Philosophy / rationale
77
103
 
78
- - **Write for clarity, not coverage.** A ticket is not a specification. One well-chosen sentence beats three that say the same thing.
79
- - **Describe the outcome, not the implementation.** The ticket owns the what and why; the implementer owns the how.
80
- - **A ticket must stand alone.** Link, don't copy — readers who need the full rationale should open the linked document, not a paraphrase.
104
+ - **Write for clarity, not coverage.** Every line carries a fact; a long ticket of facts beats a short one of filler. Aim for the smallest body that is still complete, and extend a section only when the work demands it.
105
+ - **Scope is the contract.** In scope and Out of scope make the boundary reviewable at a glance.
106
+ - **Describe the behaviour, not the implementation.** The ticket owns the what and why; the implementer owns the how.
107
+ - **A ticket must stand alone.** Link, don't copy — readers who need the full rationale open the linked document, not a paraphrase.
81
108
 
82
109
  ## Cross-skill references
83
110
 
84
- | When you need… | Use this skill |
85
- |---|---|
86
- | Tone, structure, and concision for human-facing writing | `style-comms` |
87
- | A requirements document that precedes the ticket | `write-a-prd` |
88
-
89
- ## Examples
90
-
91
- ### Vague vs verifiable acceptance criteria
92
-
93
- | Instead of… | Write… |
94
- |---|---|
95
- | "The export feature works" | "Given exports enabled, selecting 'Export CSV' downloads `<account>-export-<date>.csv`" |
96
- | "Adds tests for the new endpoint" | "POST /v1/orders returns 201 with the created order for valid input and 422 with field errors for schema violations" |
97
-
98
- ### Context that links vs context that copies
111
+ | When you need… | Use this skill |
112
+ | ------------------------------------------------------- | ----------------- |
113
+ | To break a spec into a map of tickets | `spec-to-tickets` |
114
+ | Tone, structure, and concision for human-facing writing | `style-comms` |
115
+ | A requirements document that precedes the ticket | `write-a-prd` |
99
116
 
100
- | Instead of… | Write… |
101
- |---|---|
102
- | Four paragraphs paraphrasing the ADR | "Follows ADR-014 (token refresh). This ticket adds only the retry path — see ADR link." |
117
+ See [EXAMPLES.md](./EXAMPLES.md) for worked before/after rewrites.
103
118
 
104
119
  ## Verification checklist
105
120
 
106
- - [ ] Context explains why the work exists; the reader needs no other tab open
107
- - [ ] Description states the outcome, not implementation steps, and defines scope
108
- - [ ] Acceptance criteria are independently verifiable — no "works correctly" or "is tested"
109
- - [ ] Technical notes link to code or schemas without prescribing the solution
110
- - [ ] Testing/Monitoring/Notes present only when they add non-obvious information
111
- - [ ] Every sentence passes the "does this add information?" test
112
- - [ ] A skilled engineer can start immediately with zero follow-up questions
121
+ - [ ] Context points at the parent, the approach, and the dependencies without explaining them
122
+ - [ ] Description states the goal and behaviour and leads into the scope bullets
123
+ - [ ] In scope and Out of scope are explicit, with every bullet a distinct deliverable
124
+ - [ ] Acceptance criteria are independently verifiable and none restate another
125
+ - [ ] Technical notes lead with the entry point and give only decisive facts
126
+ - [ ] Testing approach and Technical notes appear only when they add non-obvious information
127
+ - [ ] Every section is within its guidance budget, or the extra is justified by the work
128
+ - [ ] Any open question is one the human explicitly agreed to, listed under `Open questions` with an owner
129
+ - [ ] A skilled engineer can start immediately with zero follow-up questions
130
+ - [ ] The human reviewed the drafted body before it was created
@@ -43,13 +43,13 @@ For new tasks with pipeline expansion:
43
43
 
44
44
  ```bash
45
45
  # use the create-task skill, or manually:
46
- bd create "<title>" -d "<description>" -p <0-3>
46
+ bd create "<title>" -d "<description>" -p <0-3> --validate
47
47
  ```
48
48
 
49
49
  For parent-child relationships (create with `--parent`):
50
50
 
51
51
  ```bash
52
- bd create "<title>" --parent <parent-id>
52
+ bd create "<title>" --parent <parent-id> --validate
53
53
  ```
54
54
 
55
55
  For blocking dependencies between beads:
@@ -58,6 +58,31 @@ For blocking dependencies between beads:
58
58
  bd dep add <id> <blocked-by-id> --type blocks
59
59
  ```
60
60
 
61
+ ### Required sections
62
+
63
+ Create substantive beads with `--validate` so a section-less bead is rejected before it is
64
+ recorded. `bd create --validate` requires these sections per type (matching is case-insensitive);
65
+ `bd lint` checks the same contract on existing beads and exits non-zero when any are missing:
66
+
67
+ | Type | Required sections |
68
+ |---|---|
69
+ | `task`, `feature` | `## Acceptance Criteria` |
70
+ | `epic` | `## Success Criteria` |
71
+ | `bug` | `## Steps to Reproduce`, `## Acceptance Criteria` |
72
+ | `chore` | none |
73
+
74
+ Plan what you write: the type's required sections are the target of the planning interview
75
+ (`write-a-prd`, `request-refactor-plan`, `plan`, `grill-me`, …). Do not invent section content —
76
+ surface an assumption and confirm it with the human. Chore beads carry no required sections; their
77
+ description should reference the parent/requirements bead rather than restating criteria.
78
+
79
+ Review after creating — lint the beads you just made and fix any flagged ones:
80
+
81
+ ```bash
82
+ bd lint <new-id>... # scoped to your beads; exits non-zero on missing sections
83
+ bd lint # the whole open backlog (may flag pre-existing beads)
84
+ ```
85
+
61
86
  ## Completing work
62
87
 
63
88
  ```bash
@@ -8,3 +8,14 @@ Interview me relentlessly about every aspect of this plan until we reach a share
8
8
  Ask the questions one at a time.
9
9
 
10
10
  If a question can be answered by exploring the codebase, explore the codebase instead.
11
+
12
+ ## Completion: the bead's required sections
13
+
14
+ When this interview feeds a bead, the bead type's required sections are the target — their
15
+ contract is in the `bd-tool` skill's "Required sections" table (task/feature → `## Acceptance
16
+ Criteria`; epic → `## Success Criteria`; bug → Steps to Reproduce + Acceptance Criteria). The
17
+ interview is complete only when there is enough agreed detail to fill every required section.
18
+
19
+ Never invent section content. If you must infer an answer, state it as an assumption and get the
20
+ human to confirm it before it becomes bead content. Leave unresolved branches open — an open
21
+ question is better than a fabricated answer.
@@ -66,7 +66,41 @@ git pull
66
66
 
67
67
  This avoids avoidable merge conflicts.
68
68
 
69
- ### 5. Worktree lifecycle
69
+ ### 5. Bring a behind branch up to date — merge, don't rebase
70
+
71
+ When the base branch moves and the PR reports `BEHIND` or `CONFLICTING`, update
72
+ the branch before anything else:
73
+
74
+ ```bash
75
+ git fetch origin
76
+ git merge origin/main
77
+ ```
78
+
79
+ **Never rebase a branch that contains a merge commit.** `git rebase` drops merge
80
+ commits and the patches they carry, so rebasing a branch that already merged the
81
+ base silently reverts what that merge resolved — the conflict resolutions, and
82
+ any fix from the base the merge brought in. The result usually looks like a
83
+ regression in your own change. `--rebase-merges` preserves the structure, but
84
+ it re-opens the same conflicts; only worth it when the branch's history is
85
+ itself the deliverable.
86
+
87
+ Rebase only a **linear branch that has not been reviewed yet**. Rewriting
88
+ commits under review discards the review context and invalidates approvals, and
89
+ it requires `git push --force-with-lease` — never `--force`, which overwrites
90
+ work you have not seen.
91
+
92
+ Which one you owe the repository depends on its landing method, not on taste:
93
+
94
+ - **Squash merge**: the branch is collapsed on landing, so its shape never
95
+ reaches the base branch. Merge the base in and move on — rebasing here is
96
+ cosmetic, and the risky kind of cosmetic.
97
+ - **Rebase-and-merge**: a linear branch is mandatory, so rebase *before* the
98
+ first review. Once a merge has landed on the branch, that option is gone.
99
+
100
+ After any update, re-run the checks. A merge that resolved conflicts by hand is
101
+ not verified by the base branch's green CI.
102
+
103
+ ### 6. Worktree lifecycle
70
104
 
71
105
  After the PR is merged or closed, clean up the worktree:
72
106
 
@@ -47,6 +47,10 @@ Establish what needs to be built through investigation and collaborative design.
47
47
  - Technical constraints and trade-offs
48
48
  - How each change will be verified
49
49
 
50
+ The epic's required sections — `## Success Criteria` for the PRD epic — are the interview's target:
51
+ it is complete only when every required section can be filled from agreed answers. Never invent
52
+ section content; surface assumptions and confirm them with the user.
53
+
50
54
  4. Sketch the major modules that will be built or modified. Look for opportunities to extract deep modules — ones that encapsulate significant behaviour behind a simple, testable interface.
51
55
 
52
56
  5. Draft a PRD using the template from `write-a-prd`. Include:
@@ -60,8 +64,9 @@ Establish what needs to be built through investigation and collaborative design.
60
64
  7. Create an epic bead from the approved PRD:
61
65
  ```bash
62
66
  bd create "<Feature Title> — PRD" --type epic \
63
- --description "<rendered PRD as markdown>" --priority p2
67
+ --description "<rendered PRD as markdown>" --priority p2 --validate
64
68
  bd tag <epic-id> workflow:plan
69
+ bd lint <epic-id>
65
70
  ```
66
71
 
67
72
  #### Phase 1 gate
@@ -70,7 +75,7 @@ Establish what needs to be built through investigation and collaborative design.
70
75
  - [ ] Design decisions resolved through interview
71
76
  - [ ] Modules sketched and reviewed with the user
72
77
  - [ ] PRD drafted and approved by the user
73
- - [ ] Epic bead created from approved PRD
78
+ - [ ] Epic bead created from approved PRD and lints clean (`bd lint <epic-id>`)
74
79
 
75
80
  ### Phase 2 — Break into tasks
76
81
 
@@ -82,13 +87,14 @@ Take the approved PRD and produce a set of epics and tasks using tracer-bullet v
82
87
  - **Title**: short descriptive name
83
88
  - **User stories covered**: which PRD stories this phase addresses
84
89
  - **What to build**: end-to-end behaviour description
85
- - **Acceptance criteria**: verifiable outcomes
90
+ - **Success criteria**: verifiable outcomes — the epic's required `## Success Criteria`
86
91
 
87
92
  10. If the work is small enough for a single epic (one phase, a few tasks), skip epics and proceed directly to Phase 3. A single epic with a few tasks dispatches through ralph more efficiently than creating unnecessary epic hierarchy. If the work has multiple distinct phases, create epics:
88
93
  ```bash
89
94
  bd create "<Phase Title>" --type epic \
90
- --description "<epic body with scope, criteria, dependencies>" --priority <same as parent>
95
+ --description "<epic body with scope, success criteria, dependencies>" --priority <same as parent> --validate
91
96
  bd tag <epic-id> workflow:plan
97
+ bd lint <epic-id>
92
98
  bd dep add <epic-id> <parent-epic-id> --type parent-child
93
99
  ```
94
100
 
@@ -146,8 +152,13 @@ Deliver a handoff bead and instructions for running ralph.
146
152
  - **Multiple independent epics**: create a parent meta-epic that groups them:
147
153
  ```bash
148
154
  bd create "<Feature Title> — Implementation" --type epic \
149
- --description "Meta-epic grouping all phases for execution. See child epics for detail." \
150
- --priority <same>
155
+ --description "Meta-epic grouping all phases for execution. See child epics for detail.
156
+
157
+ ## Success Criteria
158
+
159
+ - [ ] All child epics complete and the feature verified end-to-end." \
160
+ --priority <same> --validate
161
+ bd lint <meta-epic>
151
162
  bd dep add <epic-1> <meta-epic> --type parent-child
152
163
  bd dep add <epic-2> <meta-epic> --type parent-child
153
164
  ```
@@ -187,13 +198,14 @@ Deliver a handoff bead and instructions for running ralph.
187
198
  #### Phase 4 gate
188
199
 
189
200
  - [ ] Handoff bead identified and tagged `workflow:ralph`
201
+ - [ ] Every handoff-path bead lints clean (`bd lint`)
190
202
  - [ ] Bead state pushed with `bd dolt push`
191
203
  - [ ] Handoff summary presented with the exact instruction to give an agent
192
204
 
193
205
  ## Phase-gate checklist
194
206
 
195
- - [ ] Phase 1: PRD drafted and approved, epic bead created
196
- - [ ] Phase 2: Task breakdown approved, epics created (if needed)
207
+ - [ ] Phase 1: PRD drafted and approved, epic bead created and validated
208
+ - [ ] Phase 2: Task breakdown approved, epics created (if needed) and validated
197
209
  - [ ] Phase 3: All tasks created, classified, expanded, tree presented
198
210
  - [ ] Phase 4: Handoff bead prepared, state pushed, summary delivered
199
211
 
@@ -19,7 +19,23 @@ Detailed procedures for the ralph orchestration workflow. See [SKILL.md](./SKILL
19
19
  - For `verify`, `review`, `document` stages: `SUMMARY` and `FILES_CHANGED` from the preceding stage's report
20
20
  - Log file path `.agent-cortex/ralph/ralph-<parent-id>.log` — logs are keyed by **parent** bead ID, so every stage chore of a feature appends to the same file
21
21
  7. **Call the {{TOOL:task}} tool** with the filled prompt as `prompt` and the worktree path as `cwd`. Store the returned agentId — you need it for step 8 and for log polling.
22
- 8. **Map** the agent ID to the bead ID in memory for lookup on completion.
22
+
23
+ If this session has no subagent tool, **stop and say so**. Do not substitute a backgrounded CLI run (`pi -p … &`): that launch has no completion signal, so a finished worker and a killed one look identical, which is how stages came to be reported complete over uncommitted trees. Record the bead for the shutdown summary and tell the human the session needs restarting with the subagent extension loaded.
24
+ 8. **Record the base commit** before the worker starts — you verify delivery against it (_Verified Completion_ below):
25
+ ```bash
26
+ git -C .agent-cortex/worktrees/<parent-id> rev-parse HEAD
27
+ ```
28
+ 9. **Map** the agent ID to the bead ID in memory for lookup on completion.
29
+
30
+ ### Verified Completion
31
+
32
+ A worker's `---REPORT---` is a claim about the worktree, not evidence of it. Verify the delivery before advancing the parent:
33
+
34
+ ```bash
35
+ node scripts/lib/verify-worker-tree.mjs --worktree .agent-cortex/worktrees/<parent-id> --base <base>
36
+ ```
37
+
38
+ Exit code 0 means a clean tree with at least one commit ahead of the recorded base. A non-zero exit reports `worktree is dirty` or `no commit ahead of base`, and the stage did **not** deliver whatever its `OUTCOME` line says. Re-dispatch the same chore, or record the failure for the fix chain — never advance the parent, close the chore, or open a feature PR over uncommitted work.
23
39
 
24
40
  ---
25
41
 
@@ -79,7 +95,9 @@ When a verify or review stage fails:
79
95
  ```bash
80
96
  fix_id=$(bd create "[<parent-id>] Fix (round <N>)" --type chore \
81
97
  --priority <same as parent> \
82
- --description "<CHANGES_REQUESTED list or VERIFY_FAILURES list from the triggering REPORT>" -q)
98
+ --description "Requirements: see <parent-id> acceptance criteria (`bd show <parent-id>`).
99
+
100
+ <CHANGES_REQUESTED list or VERIFY_FAILURES list from the triggering REPORT>" -q)
83
101
  bd tag $fix_id stage:fix
84
102
  bd dep add $fix_id <parent-id> --type parent-child # fix-chore is child of parent
85
103
  ```
@@ -49,7 +49,7 @@ On each completion notification (background agent finished, or the poll timer fi
49
49
 
50
50
  1. Poll that parent's log for new lines — `tail -n +<nextLine> .agent-cortex/ralph/ralph-<parent-id>.log` (logs are keyed by parent bead ID, so every stage of a feature shares one file) — and post only new key events (stage transitions, test/lint results), never empty updates.
51
51
  2. Read the completed agent's output with {{TOOL:read_agent}} and parse its `---REPORT---` block for `BEAD_ID`, `STAGE_COMPLETED`, and the outcome.
52
- 3. Close the chore bead: `bd close <bead-id>`.
52
+ 3. **Verify the delivery, then close the chore bead.** Run `node scripts/lib/verify-worker-tree.mjs --worktree .agent-cortex/worktrees/<parent-id> --base <base>` (REFERENCE.md, _Verified Completion_) and close only when it exits 0: `bd close <bead-id>`.
53
53
  4. Advance the parent per the dispatch table:
54
54
 
55
55
  | Stage completed | Condition | Next action |
@@ -82,6 +82,8 @@ On each completion notification (background agent finished, or the poll timer fi
82
82
 
83
83
  - Running as a background or delegated subagent instead of the interactive foreground agent.
84
84
  - Spawning a stage runner via {{TOOL:bash}} or running a stage inline instead of {{TOOL:task}}.
85
+ - Substituting a backgrounded CLI run for a missing subagent tool — stop and report instead; that launch has no completion signal.
86
+ - Advancing a parent on a worker's `OUTCOME: SUCCESS` without verifying the worktree — the report is a claim, not evidence.
85
87
  - Editing bead files directly instead of using `bd` commands.
86
88
  - Auto-merging a PR, or continuing past a feature/epic gate before a human merge.
87
89
 
@@ -114,6 +116,7 @@ On each completion notification (background agent finished, or the poll timer fi
114
116
 
115
117
  - [ ] Init ran once with observable results: `state.json` exists, `bd ready` was parsed, and the first chore beads are claimed.
116
118
  - [ ] Every stage runner was spawned with {{TOOL:task}} from the parent's feature worktree, with the `---REPORT---` instruction in its prompt.
119
+ - [ ] Every stage delivery was confirmed with `scripts/lib/verify-worker-tree.mjs` before the parent advanced, and no stage was dispatched from a session with no subagent tool.
117
120
  - [ ] In-flight count never exceeded 5, and fix loops respect `maxFixRounds` from `pipeline.json`.
118
121
  - [ ] Feature and epic PRs were pushed and reported immediately at their gates, and nothing was auto-merged.
119
122
  - [ ] `bd dolt push` and a final `progress.md` regeneration ran before HITL Pause/Shutdown, and the chat received no empty poll updates.
@@ -36,10 +36,11 @@ workspace="/absolute/path/to/worktree"
36
36
  pnpm --prefix skills/workflow/run-pipeline-stage/scripts exec tsx generate-progress.ts --workspace "$workspace" > "$workspace/.agent-cortex/ralph/progress.md"
37
37
  ```
38
38
 
39
- 7. Dispatch one subagent per stage with the composed prompt — spawn it with {{TOOL:task}} and end the prompt with the REPORT contract below.
40
- 8. Route the REPORT through the Dispatch Rules: advance to the next stage, create a feedback bead, or close the parent.
39
+ 7. Dispatch one subagent per stage with the composed prompt — spawn it with {{TOOL:task}} and end the prompt with the REPORT contract below. A session with no subagent tool cannot dispatch: stop and say so rather than substituting a backgrounded CLI run, which has no completion signal.
40
+ 8. Verify the delivery against the worktree — `node scripts/lib/verify-worker-tree.mjs --worktree <abs-worktree> --base <base>` exits 0 only for a clean tree with a commit ahead of base. A worker whose REPORT claims `OUTCOME: SUCCESS` over a dirty tree has not delivered; re-dispatch it instead of advancing.
41
+ 9. Route the REPORT through the Dispatch Rules: advance to the next stage, create a feedback bead, or close the parent.
41
42
 
42
- Each step leaves observable state — a claimed bead, a `stage:` tag, a regenerated progress doc, and a REPORT that drives the next action.
43
+ Each step leaves observable state — a claimed bead, a `stage:` tag, a regenerated progress doc, a verified commit, and a REPORT that drives the next action.
43
44
 
44
45
  ## Dispatch Rules
45
46
 
@@ -61,12 +62,17 @@ On stage failure, create a chore bead whose description carries the feedback so
61
62
 
62
63
  ```bash
63
64
  new_id=$(bd create "[<parent-id>] <title>" --type chore \
64
- --description "<feedback content from REPORT>" --priority <parent-priority> -q)
65
+ --description "Requirements: see <parent-id> acceptance criteria (`bd show <parent-id>`).
66
+
67
+ <feedback content from REPORT>" --priority <parent-priority> -q)
65
68
  bd tag $new_id stage:<next-stage>
66
69
  bd tag $new_id workflow:ralph
67
70
  bd dep add $new_id <parent-id> --type parent-child
68
71
  ```
69
72
 
73
+ Chore beads carry no required sections, so the feedback description must point at the
74
+ parent/requirements bead (`<parent-id>`) rather than restating its acceptance criteria.
75
+
70
76
  | Triggering outcome | Suggested title | Next stage tag | Description content |
71
77
  |---|---|---|---|
72
78
  | `OUTCOME: BLOCKED` from verify | `Fix: verify failures` | `stage:code` | Full BLOCKING_ISSUES list |
@@ -109,13 +115,18 @@ Every subagent prompt must end with the REPORT instruction:
109
115
  > STAGE_COMPLETED: <code|verify|review|document>
110
116
  > SUMMARY: <2-3 sentence summary of what was done>
111
117
  > FILES_CHANGED: <comma-separated list, or "none">
118
+ > COMMIT: <sha of the stage commit, or "none">
119
+ > PUSHED: <yes|no>
120
+ > PR: <feature PR url, or "none">
112
121
  > OUTCOME: <SUCCESS|BLOCKED>
113
122
  > BLOCKING_ISSUES: ← only if OUTCOME is BLOCKED
114
123
  > - <specific blocking issue>
115
124
  > ---
116
125
  > ```
117
126
 
118
- Subagents report facts — do not ask them to suggest or predict the next step.
127
+ Subagents report facts — do not ask them to suggest or predict the next step. A REPORT claiming
128
+ `OUTCOME: SUCCESS` with `PUSHED: no`, or a `COMMIT` that is not on the branch, records a failed
129
+ stage: the commit is the evidence, the report is the claim.
119
130
 
120
131
  ## Red Flags
121
132
 
@@ -123,6 +134,7 @@ Subagents report facts — do not ask them to suggest or predict the next step.
123
134
  - Composing a subagent prompt without the REPORT contract — the output cannot be routed.
124
135
  - Creating a feedback bead and then dispatching anyway — bypasses the fix-round accounting and parent-child dependency graph.
125
136
  - Skipping the playbook "because the stage is simple" — playbooks carry the per-stage discipline the pipeline relies on.
137
+ - Advancing on `OUTCOME: SUCCESS` without verifying the worktree — the commit is the evidence, the report is the claim.
126
138
  - Leaving bead notes to the end of the stage — a session that dies mid-stage then loses the whole trail.
127
139
 
128
140
  ## Common Rationalizations
@@ -11,7 +11,9 @@
11
11
 
12
12
  ## Stage Outcome
13
13
 
14
+ - Commit and push the stage's work before reporting (see the stage-runner prompt, _Deliver before reporting_).
14
15
  - Set `OUTCOME: SUCCESS` when implementation passes all tests and meets requirements.
15
16
  - Set `OUTCOME: BLOCKED` if tests fail or requirements cannot be met.
16
17
  - If blocked, list issues under `BLOCKING_ISSUES`.
17
18
  - `FILES_CHANGED` lists all modified source/test files.
19
+ - Report `COMMIT`, `PUSHED`, and `PR` (`PR: none` outside the document stage).
@@ -12,7 +12,10 @@
12
12
 
13
13
  ## Stage Outcome
14
14
 
15
+ - Commit and push the docs before reporting (see the stage-runner prompt, _Deliver before reporting_).
16
+ - Open or update the feature PR (`gh pr create --base <base> --head <branch>` when none is open yet).
15
17
  - Set `OUTCOME: SUCCESS` when docs are updated as needed (or none needed).
16
18
  - Set `OUTCOME: BLOCKED` if unable to update or content guidance is unclear.
17
19
  - If blocked, list issues under `BLOCKING_ISSUES`.
18
20
  - `FILES_CHANGED` lists docs touched, or `none` if no doc change is needed.
21
+ - Report `COMMIT`, `PUSHED`, and the feature `PR` URL.
@@ -11,7 +11,9 @@
11
11
 
12
12
  ## Stage Outcome
13
13
 
14
+ - Commit and push the fix before reporting (see the stage-runner prompt, _Deliver before reporting_).
14
15
  - Set `OUTCOME: SUCCESS` when requested changes are successfully applied.
15
16
  - Set `OUTCOME: BLOCKED` if unable to apply changes or guidance is unclear.
16
17
  - If blocked, list issues under `BLOCKING_ISSUES`.
17
18
  - `FILES_CHANGED` lists files updated to address requested changes.
19
+ - Report `COMMIT`, `PUSHED`, and `PR` (`PR: none`).
@@ -26,6 +26,17 @@ Use `--append-notes` — plain `--notes` overwrites the trail. Record start, mil
26
26
  (with rejected options), blocks, and discoveries. One or two lines per entry: a checkpoint trail,
27
27
  not a transcript. The REPORT below remains the authoritative stage outcome.
28
28
 
29
+ ## Deliver before reporting
30
+
31
+ A stage is delivered when its work is committed and pushed — not when the REPORT says so. The
32
+ orchestrator opens the feature PR from this branch, so uncommitted work never reaches review, and a
33
+ dirty worktree counts as a failed stage whatever the outcome line claims.
34
+
35
+ 1. Commit on the current branch: `git add -A && git commit -m "<stage>(<parent-id>): <summary>"`.
36
+ 2. Push the branch: `git push -u origin HEAD`.
37
+ 3. Report `COMMIT`, `PUSHED`, and `PR`. The `document` stage also opens or updates the feature PR
38
+ and reports its URL; every earlier stage reports `PR: none`.
39
+
29
40
  ## Instructions
30
41
  1. Read and follow the playbook file listed above.
31
42
  2. Treat the bead as the source-of-truth specification (not a prompt script).
@@ -23,6 +23,7 @@ Task arrives
23
23
  ├── Have a rough idea? ─────────────────→ record-idea
24
24
  ├── New feature / PRD needed? ──────────→ write-a-prd
25
25
  ├── PRD approved, need tasks? ──────────→ prd-to-tasks
26
+ ├── Spec approved, need tickets? ───────→ spec-to-tickets
26
27
  ├── Need a single task tracked? ────────→ create-task
27
28
  ├── Need to plan a feature end-to-end? ─→ plan
28
29
  ├── Running beads / task execution? ────→ ralph