engsys 1.0.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 (173) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +202 -0
  3. package/core/agents/aaron.md +152 -0
  4. package/core/agents/bert.md +115 -0
  5. package/core/agents/isabelle.md +136 -0
  6. package/core/agents/jody.md +150 -0
  7. package/core/agents/leith.md +111 -0
  8. package/core/agents/marcelo.md +282 -0
  9. package/core/agents/melvin.md +101 -0
  10. package/core/agents/nyx.md +152 -0
  11. package/core/agents/otto.md +168 -0
  12. package/core/agents/patricia.md +283 -0
  13. package/core/commands/design-audit-local.md +155 -0
  14. package/core/commands/design-audit.md +235 -0
  15. package/core/commands/design-critique.md +96 -0
  16. package/core/commands/file-issue.md +22 -0
  17. package/core/commands/generate-project.md +45 -0
  18. package/core/commands/implement-issue.md +37 -0
  19. package/core/commands/implement-project.md +40 -0
  20. package/core/commands/naturalize.md +61 -0
  21. package/core/commands/pre-push.md +29 -0
  22. package/core/commands/prep-review-collect.md +130 -0
  23. package/core/commands/prep-review-finalize.md +121 -0
  24. package/core/commands/prep-review-publish.md +113 -0
  25. package/core/commands/prep-review.md +65 -0
  26. package/core/commands/project-closeout.md +25 -0
  27. package/core/skills/agentic-eval/SKILL.md +195 -0
  28. package/core/skills/chrome-devtools/SKILL.md +97 -0
  29. package/core/skills/code-review/SKILL.md +26 -0
  30. package/core/skills/gh-cli/SKILL.md +2202 -0
  31. package/core/skills/git-commit/SKILL.md +124 -0
  32. package/core/skills/git-workflow-agents/SKILL.md +462 -0
  33. package/core/skills/git-workflow-agents/reference.md +220 -0
  34. package/core/skills/github-actions/SKILL.md +190 -0
  35. package/core/skills/github-issues/SKILL.md +154 -0
  36. package/core/skills/llm-structured-outputs/SKILL.md +323 -0
  37. package/core/skills/llm-structured-outputs/references/provider-details.md +392 -0
  38. package/core/skills/pre-push/SKILL.md +115 -0
  39. package/core/skills/refactor/SKILL.md +645 -0
  40. package/core/skills/web-design-reviewer/SKILL.md +371 -0
  41. package/core/skills/webapp-testing/SKILL.md +127 -0
  42. package/core/skills/webapp-testing/test-helper.js +56 -0
  43. package/core/templates/CLAUDE.md.tmpl +98 -0
  44. package/core/templates/adr-template.md +67 -0
  45. package/core/templates/gh-issue-templates/bug.md +39 -0
  46. package/core/templates/gh-issue-templates/content.md +42 -0
  47. package/core/templates/gh-issue-templates/enhancement.md +36 -0
  48. package/core/templates/gh-issue-templates/feature.md +39 -0
  49. package/core/templates/gh-issue-templates/infrastructure.md +41 -0
  50. package/core/templates/post-edit-reminders.sh.tmpl +19 -0
  51. package/core/templates/settings.json.tmpl +90 -0
  52. package/core/templates/settings.local.json.tmpl +3 -0
  53. package/core/workflows/agent-implementation-workflow.md +346 -0
  54. package/core/workflows/generate-project.md +258 -0
  55. package/core/workflows/implement-project-workflow.md +190 -0
  56. package/core/workflows/issue-tracking.md +89 -0
  57. package/core/workflows/project-closeout-ceremony.md +77 -0
  58. package/core/workflows/review-workflow.md +266 -0
  59. package/engsys.config.example.yaml +46 -0
  60. package/install +202 -0
  61. package/lessons-library/README.md +80 -0
  62. package/lessons-library/async-callbacks-verify-liveness.md +15 -0
  63. package/lessons-library/change-isnt-done-until-every-surface-updated.md +15 -0
  64. package/lessons-library/claim-then-act-for-irreversible-ops.md +16 -0
  65. package/lessons-library/co-commit-entangled-work.md +15 -0
  66. package/lessons-library/dependabot-triage-playbook.md +17 -0
  67. package/lessons-library/deploy-by-digest-and-verify-the-running-revision.md +15 -0
  68. package/lessons-library/enforce-your-guarantee-at-your-boundary.md +16 -0
  69. package/lessons-library/gate-changes-on-measurement-not-vibes.md +15 -0
  70. package/lessons-library/iac-first-no-console-changes.md +15 -0
  71. package/lessons-library/independent-objective-review-gate.md +15 -0
  72. package/lessons-library/keep-an-immutable-source-of-truth.md +15 -0
  73. package/lessons-library/long-agent-runs-checkpoint-not-poll.md +15 -0
  74. package/lessons-library/model-identity-with-stable-ids-and-provenance.md +15 -0
  75. package/lessons-library/operator-choices-are-first-class.md +15 -0
  76. package/lessons-library/prefer-tool-enforced-structured-output.md +15 -0
  77. package/lessons-library/prove-causation-before-acting.md +15 -0
  78. package/lessons-library/re-read-state-before-acting.md +14 -0
  79. package/lessons-library/read-layer-tolerates-unbackfilled-rows.md +15 -0
  80. package/lessons-library/shell-safety-pipefail-and-validate-before-teardown.md +14 -0
  81. package/lessons-library/shift-correctness-left-and-distrust-false-greens.md +15 -0
  82. package/lessons-library/stray-control-bytes-hide-changes.md +14 -0
  83. package/lessons-library/tests-can-assert-the-bug.md +15 -0
  84. package/lessons-library/verify-ground-truth-not-reports.md +15 -0
  85. package/lessons-library/worktrees-need-bootstrap-from-origin-main.md +15 -0
  86. package/lib/commands.js +356 -0
  87. package/lib/generate-team-avatars.mjs +251 -0
  88. package/lib/manifest.js +155 -0
  89. package/lib/render.js +135 -0
  90. package/lib/selftest.js +90 -0
  91. package/lib/util.js +89 -0
  92. package/lib/yaml.js +156 -0
  93. package/optional-agents/gary.md +86 -0
  94. package/optional-agents/jos.md +136 -0
  95. package/optional-agents/sandy.md +101 -0
  96. package/optional-agents/steve.md +161 -0
  97. package/package.json +43 -0
  98. package/stacks/cloud/aws/claude.fragment.md +17 -0
  99. package/stacks/cloud/aws/settings.fragment.json +39 -0
  100. package/stacks/cloud/aws/skills/aws-deployment-preflight/SKILL.md +165 -0
  101. package/stacks/cloud/aws/skills/cloud-architecture-aws/SKILL.md +265 -0
  102. package/stacks/cloud/azure/claude.fragment.md +17 -0
  103. package/stacks/cloud/azure/settings.fragment.json +45 -0
  104. package/stacks/cloud/azure/skills/azure-deployment-preflight/SKILL.md +175 -0
  105. package/stacks/cloud/azure/skills/cloud-architecture-azure/SKILL.md +211 -0
  106. package/stacks/cloud/cloudflare/claude.fragment.md +21 -0
  107. package/stacks/cloud/cloudflare/settings.fragment.json +31 -0
  108. package/stacks/cloud/cloudflare/skills/cloud-architecture-cloudflare/SKILL.md +294 -0
  109. package/stacks/cloud/cloudflare/skills/cloudflare-deployment-preflight/SKILL.md +175 -0
  110. package/stacks/cloud/gcp/claude.fragment.md +17 -0
  111. package/stacks/cloud/gcp/settings.fragment.json +40 -0
  112. package/stacks/cloud/gcp/skills/cloud-architecture-gcp/SKILL.md +208 -0
  113. package/stacks/cloud/gcp/skills/gcp-deployment-preflight/SKILL.md +137 -0
  114. package/stacks/db/mongo/skills/mongo-conventions/SKILL.md +96 -0
  115. package/stacks/db/prisma/claude.fragment.md +49 -0
  116. package/stacks/db/prisma/skills/docker-database-package-copy/SKILL.md +44 -0
  117. package/stacks/db/prisma/skills/prisma-conventions/SKILL.md +37 -0
  118. package/stacks/domain/mobile-growth/skills/apple-ads/SKILL.md +184 -0
  119. package/stacks/domain/mobile-growth/skills/apple-ads/references/benchmark-notes.md +47 -0
  120. package/stacks/domain/mobile-growth/skills/apple-ads/references/official-links.md +53 -0
  121. package/stacks/domain/mobile-growth/skills/google-play-growth/SKILL.md +197 -0
  122. package/stacks/domain/mobile-growth/skills/google-play-growth/references/benchmark-notes.md +47 -0
  123. package/stacks/domain/mobile-growth/skills/google-play-growth/references/official-links.md +45 -0
  124. package/stacks/iac/bicep/claude.fragment.md +14 -0
  125. package/stacks/iac/bicep/settings.fragment.json +20 -0
  126. package/stacks/iac/bicep/skills/iac-bicep/SKILL.md +113 -0
  127. package/stacks/iac/cdk/claude.fragment.md +14 -0
  128. package/stacks/iac/cdk/settings.fragment.json +23 -0
  129. package/stacks/iac/cdk/skills/iac-cdk/SKILL.md +104 -0
  130. package/stacks/iac/terraform/claude.fragment.md +13 -0
  131. package/stacks/iac/terraform/settings.fragment.json +25 -0
  132. package/stacks/iac/terraform/skills/iac-terraform/SKILL.md +93 -0
  133. package/stacks/iac/terraform/skills/terraform-conventions/SKILL.md +87 -0
  134. package/stacks/lang/kotlin/skills/android-testing/SKILL.md +263 -0
  135. package/stacks/lang/kotlin/skills/jetpack-compose/SKILL.md +264 -0
  136. package/stacks/lang/kotlin/skills/kotlin-coroutines/SKILL.md +329 -0
  137. package/stacks/lang/python/skills/python-conventions/SKILL.md +61 -0
  138. package/stacks/lang/shell/skills/shell-scripting/SKILL.md +110 -0
  139. package/stacks/lang/swift/skills/swift-concurrency/SKILL.md +423 -0
  140. package/stacks/lang/swift/skills/swift-concurrency/references/approachable-concurrency.md +80 -0
  141. package/stacks/lang/swift/skills/swift-concurrency/references/concurrency-patterns.md +233 -0
  142. package/stacks/lang/swift/skills/swift-concurrency/references/swiftui-concurrency.md +187 -0
  143. package/stacks/lang/swift/skills/swift-concurrency/references/synchronization-primitives.md +341 -0
  144. package/stacks/lang/swift/skills/swift-testing/SKILL.md +497 -0
  145. package/stacks/lang/swift/skills/swift-testing/references/testing-advanced.md +106 -0
  146. package/stacks/lang/swift/skills/swift-testing/references/testing-patterns.md +504 -0
  147. package/stacks/lang/swift/skills/swiftdata/SKILL.md +334 -0
  148. package/stacks/lang/swift/skills/swiftdata/references/core-data-coexistence.md +504 -0
  149. package/stacks/lang/swift/skills/swiftdata/references/swiftdata-advanced.md +975 -0
  150. package/stacks/lang/swift/skills/swiftdata/references/swiftdata-queries.md +675 -0
  151. package/stacks/lang/swift/skills/swiftui-patterns/SKILL.md +371 -0
  152. package/stacks/lang/swift/skills/swiftui-patterns/references/architecture-patterns.md +486 -0
  153. package/stacks/lang/swift/skills/swiftui-patterns/references/deprecated-migration.md +1097 -0
  154. package/stacks/lang/swift/skills/swiftui-patterns/references/design-polish.md +780 -0
  155. package/stacks/lang/swift/skills/swiftui-patterns/references/platform-and-sharing.md +696 -0
  156. package/stacks/lang/typescript/skills/typescript-conventions/SKILL.md +91 -0
  157. package/stacks/platform/android/claude.fragment.md +40 -0
  158. package/stacks/platform/android/hooks/pre-push-gradle.sh +70 -0
  159. package/stacks/platform/android/settings.fragment.json +13 -0
  160. package/stacks/platform/android/skills/android-build-conventions/SKILL.md +247 -0
  161. package/stacks/platform/ios/claude.fragment.md +24 -0
  162. package/stacks/platform/ios/hooks/pre-push-xcodebuild.sh +82 -0
  163. package/stacks/platform/ios/settings.fragment.json +21 -0
  164. package/stacks/platform/ios/skills/xcodebuildmcp-simulator-logs/SKILL.md +76 -0
  165. package/stacks/platform/web/skills/frontend-testing/SKILL.md +246 -0
  166. package/stacks/platform/web/skills/react-conventions/SKILL.md +261 -0
  167. package/stacks/platform/web/skills/web-platform-conventions/SKILL.md +55 -0
  168. package/stacks/tooling/issue-tracker-github/claude.fragment.md +10 -0
  169. package/stacks/tooling/issue-tracker-github/settings.fragment.json +24 -0
  170. package/stacks/tooling/issue-tracker-github/skills/issue-tracker-github/SKILL.md +278 -0
  171. package/stacks/tooling/issue-tracker-linear/claude.fragment.md +17 -0
  172. package/stacks/tooling/issue-tracker-linear/settings.fragment.json +9 -0
  173. package/stacks/tooling/issue-tracker-linear/skills/issue-tracker-linear/SKILL.md +183 -0
@@ -0,0 +1,346 @@
1
+ # Agent Implementation Workflow
2
+
3
+ Implement tracker issues using Git worktrees for isolation. The default unit is a **phase PR**: all issues in one project phase become individual commits in one branch, one worktree, one PR.
4
+
5
+ If a project has no phases, implement all selected issues in one PR. If there is only one issue, the PR naturally contains one issue. Do not split into one PR per issue unless the human explicitly asks.
6
+
7
+ Work-item operations (claim, fetch state, record findings, link/close) go through the project's installed **issue-tracker skill** (`.claude/skills/issue-tracker-*/`) via its contract operations (`get-issue`, `update-issue`, `comment-issue`, `link-pr`). The skill maps them onto the active backend; the GitHub `gh` commands shown below are what it runs on a GitHub project. PR creation (`gh pr create`), CI, and worktree/git mechanics stay on GitHub regardless of tracker.
8
+
9
+ ## Start Command Authorization
10
+
11
+ When a human says `Start on Project <number>`, `Start on issue <number>`, `Implement Project <number>`, or equivalent implementation wording while pointing at this workflow, treat that as explicit authorization to complete the normal agent implementation cycle:
12
+
13
+ - scope the batch
14
+ - create the worktree and branch
15
+ - edit files
16
+ - create the issue-scoped implementation commits
17
+ - run validation
18
+ - run the local code review and resolve findings
19
+ - push the agent branch
20
+ - open the PR and record the review findings
21
+
22
+ Do not pause after validation solely to ask whether commits, push, or PR creation are allowed. This workflow is the authorization for those routine implementation steps.
23
+
24
+ Still require a separate explicit human instruction before merging PRs, pushing to `main`, force-pushing anything except the active agent branch with `--force-with-lease` during documented rebase recovery, or running destructive cleanup outside the completed/merged workflow.
25
+
26
+ ---
27
+
28
+ ## Phase 0: Scope the Batch
29
+
30
+ Before creating the worktree:
31
+
32
+ - Review `docs/agent-lessons/` so recent mistakes and tool lessons are fresh in context.
33
+ - Fetch the current issue/project state from the tracker via the skill's `get-issue` / `query-board` operations, not stale local notes.
34
+ - Identify the implementation batch:
35
+ - phased project: one phase = one PR
36
+ - unphased project: all selected issues = one PR
37
+ - single issue: one issue = one PR
38
+ - Assign every issue in the batch to yourself via the skill's `update-issue` operation.
39
+ - Build a commit plan: each issue gets its own implementation commit referencing that issue number.
40
+
41
+ ```bash
42
+ # GitHub realization of update-issue (claim):
43
+ gh issue edit <number> --add-assignee "@me"
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Phase 1: Setup
49
+
50
+ ```bash
51
+ # From the main repo root, ensure main is current
52
+ git fetch origin && git checkout main && git pull --ff-only origin main
53
+
54
+ # If pull --ff-only fails (local main diverged from origin/main due to squash merges),
55
+ # reset local main before creating the worktree:
56
+ # git reset --hard origin/main
57
+ # OR create the worktree directly from origin/main (safest):
58
+ # git worktree add ../worktrees/<slug> -b agent/<slug> origin/main
59
+
60
+ # Create the worktree AND branch in one command (-b flag is CRITICAL)
61
+ git worktree add ../worktrees/<phase-or-project-slug> -b agent/<phase-or-project-slug> origin/main
62
+
63
+ cd ../worktrees/<phase-or-project-slug>
64
+ # install deps + run any codegen the project requires (see CLAUDE.md)
65
+ ```
66
+
67
+ Use a branch slug that describes the batch, not just the first issue. Examples:
68
+
69
+ - `agent/project-11-phase-2-enrichment`
70
+ - `agent/settings-billing-metrics`
71
+ - `agent/957-tenant-switching` for a single-issue PR
72
+
73
+ > **Project bootstrap:** a fresh worktree has no installed dependencies and may need codegen (client generation, schema build, etc.). Run the project's bootstrap (`CLAUDE.md` § setup) inside the worktree before building.
74
+
75
+ ---
76
+
77
+ ## Phase 2: Implement
78
+
79
+ - Edit files inside the worktree only.
80
+ - Complete one issue at a time and commit it before moving to the next issue.
81
+ - Each implementation commit must reference the issue it satisfies: `feat(<scope>): add invite endpoint (#131)`.
82
+ - **File-overlap exception:** when two issues legitimately touch the same source files (same controller, DTO, service), forcing a split creates a broken intermediate commit. Co-commit those issues instead and cite all issue numbers in the subject: `feat(<scope>): PATCH /auth/me + PATCH /auth/me/default-tenant (#1565, #1566)`. The PR body's `Closes #` lines still auto-close all issues on merge.
83
+ - Keep review-fix commits (from the local review or later human review) as follow-ups after the issue commits.
84
+ - Use the `tmp/` folder for commit messages and PR bodies — **never HEREDOC**.
85
+
86
+ ```bash
87
+ # Write the commit message to a file, then commit
88
+ git commit -F tmp/commit-msg-<issue-number>.txt
89
+ ```
90
+
91
+ ---
92
+
93
+ ## Phase 3: Verify + Review Before Push
94
+
95
+ When all issue commits are complete, validate locally **and run the local code review** before pushing or opening the PR. Go in clean: a clean local review means the first CI run is also the last.
96
+
97
+ ```bash
98
+ git fetch origin # local main is often stale in a worktree
99
+ <the project's pre-push gate / precheck> # build, lint, format, unit tests, path-gated gates
100
+ <a local code review against origin/main> # built-in /code-review skill, or the project's CLI reviewer
101
+ ```
102
+
103
+ If any gate fails, fix locally and re-run. The project's pre-push gate (and the local pre-push hook, if it has one) is the contract; see `/pre-push`.
104
+
105
+ For the review: fix **Critical** and **Warning** findings, **Info** at discretion, then re-run once to confirm clean. Cap the loop at ~2 passes — don't grind. Keep the findings — you'll post them on the PR in Phase 4.
106
+
107
+ ---
108
+
109
+ ## Phase 4: Push + Create PR (draft-first)
110
+
111
+ After local verification passes, push once and create the PR as **draft**.
112
+
113
+ ```bash
114
+ git push -u origin agent/<phase-or-project-slug>
115
+ ```
116
+
117
+ Write the PR body to `tmp/` first:
118
+
119
+ ```bash
120
+ # 1. Write the PR body using the Write tool -> tmp/pr-body-<phase-or-project-slug>.md
121
+ # Include: summary, issue list, Closes keywords, test plan
122
+
123
+ # 2. Create the PR as DRAFT (defers any expensive ready-for-review CI matrix)
124
+ gh pr create \
125
+ --base main \
126
+ --draft \
127
+ --title "<type>(<scope>): <batch description>" \
128
+ --body-file tmp/pr-body-<phase-or-project-slug>.md \
129
+ --label "<labels>"
130
+
131
+ # 3. Clean up the tmp file
132
+ rm tmp/pr-body-<phase-or-project-slug>.md
133
+ ```
134
+
135
+ If the project gates expensive CI (E2E / a11y / flake matrices) behind the ready-for-review transition, draft-first defers it until you flip the PR ready.
136
+
137
+ Link/close the work items per the skill's `link-pr` operation. On GitHub that means one closing keyword per issue in the PR body — GitHub only closes the first issue when multiple are comma-separated on one line (`Closes #1, #2, #3` closes only `#1`):
138
+
139
+ ```markdown
140
+ Closes #1
141
+ Closes #2
142
+ Closes #3
143
+ ```
144
+
145
+ **Record the review findings on the work item.** After the PR is created, post the Phase 3 review findings via the skill's `comment-issue` operation, as one comment that contains a stable marker (e.g. `<!-- local-review-findings -->`). This is the durable record the [closeout ceremony](project-closeout-ceremony.md) mines for recurring mistake families. Write the body to `tmp/` first; on GitHub the skill posts it on the PR:
146
+
147
+ ```bash
148
+ gh pr comment <pr-number> --body-file tmp/review-findings-<pr>.md
149
+ ```
150
+
151
+ ```markdown
152
+ <!-- local-review-findings -->
153
+
154
+ **Local code review** (pre-push) — <N> findings
155
+
156
+ - **[Critical]** <title> — fixed in <sha>
157
+ - **[Warning]** <title> — fixed in <sha>
158
+ - **[Warning]** <title> — not changed: <reason>
159
+ - **[Info]** <title> — deferred (see #<issue>)
160
+ ```
161
+
162
+ If the review surfaced zero findings, still post the comment with "0 findings" so closeout has a complete corpus.
163
+
164
+ ---
165
+
166
+ ## Phase 5: Mark Ready for Review
167
+
168
+ The PR is draft and already locally reviewed (Phase 3). Once the local review is resolved, the pre-push gate is green, and the cheap draft CI passes, mark the PR ready:
169
+
170
+ ```bash
171
+ gh pr ready <pr-number>
172
+ ```
173
+
174
+ If the project's full CI matrix fires on the `ready_for_review` transition, be confident before flipping it — don't mark ready with unresolved Critical/Warning findings or a red gate; that's what draft is for.
175
+
176
+ If a finding exposes a product or architecture decision rather than a clear fix, **stop and ask the human** instead of guessing.
177
+
178
+ ---
179
+
180
+ ## Phase 6: Reflect + Update Agent Memory
181
+
182
+ After final review-response commits are made, reflect before handing the PR to the human.
183
+
184
+ Ask:
185
+
186
+ - Did I struggle to call the right tools?
187
+ - Did I miss a critical rule, project doc, issue detail, service boundary, or architecture context?
188
+ - Did tests, CI, the local review, or the human catch something I should have caught earlier?
189
+ - What went wrong that future me can avoid?
190
+
191
+ Actions:
192
+
193
+ - Create or update LLM-optimized notes in `docs/agent-lessons/`.
194
+ - Update the relevant agent profile (`.claude/agents/*.md`) if role behavior should change.
195
+ - Create or update rules, prompt docs, or other instructions when the lesson should be automatically applied.
196
+ - If the lesson generalizes beyond this project, open a PR back to the engsys `lessons-library/`.
197
+ - Commit these learning/instruction changes as a final PR commit.
198
+
199
+ Write lessons for machine retrieval, not human reading: short headings, trigger phrases, failure mode, correct behavior, commands/files to check, and links to authoritative docs.
200
+
201
+ ---
202
+
203
+ ## Phase 7: Human Review + Merge
204
+
205
+ After the local review findings are handled and learning updates are committed:
206
+
207
+ - Push the final branch.
208
+ - Ensure the PR body and test plan are current.
209
+ - Wait for all required CI workflows to pass.
210
+ - Human in the loop performs the final review.
211
+ - Human squash-merges the PR when satisfied.
212
+
213
+ Agents do not merge their own implementation PRs unless the human explicitly asks.
214
+
215
+ ---
216
+
217
+ ## Phase 8: Cleanup After Merge
218
+
219
+ After the PR is squash-merged:
220
+
221
+ ```bash
222
+ # From the main repo root
223
+ git checkout main
224
+ git pull --ff-only origin main
225
+
226
+ # Empty the worktree directory first if needed (node_modules/dist/build artifacts can block removal)
227
+ git worktree remove ../worktrees/<phase-or-project-slug> --force
228
+ git branch -d agent/<phase-or-project-slug>
229
+ git worktree prune
230
+ ```
231
+
232
+ If the branch was already deleted remotely by the tracker, local branch deletion is still required. If `git branch -d` refuses because a squash merge changed commit IDs, verify the PR is merged, then use `git branch -D agent/<phase-or-project-slug>`.
233
+
234
+ ---
235
+
236
+ ## Stacked Branches
237
+
238
+ Prefer one phase PR from `main`. Use stacked branches only when one batch must build on unreleased work from another branch.
239
+
240
+ ```bash
241
+ git worktree add ../worktrees/<child-slug> agent/<parent-slug> -b agent/<child-slug>
242
+ ```
243
+
244
+ This creates a dependency: the parent PR must merge before the child PR can merge cleanly.
245
+
246
+ After the parent PR merges:
247
+
248
+ ```bash
249
+ cd ../worktrees/<child-slug>
250
+ git fetch origin
251
+ git rebase origin/main
252
+ ```
253
+
254
+ Git may skip commits that are now on main. If it stops on a duplicate already-merged commit, skip it:
255
+
256
+ ```bash
257
+ git rebase --skip
258
+ ```
259
+
260
+ After a clean rebase:
261
+
262
+ ```bash
263
+ git log --oneline origin/main..HEAD
264
+ git push --force-with-lease origin agent/<child-slug>
265
+ ```
266
+
267
+ ---
268
+
269
+ ## Rules
270
+
271
+ | Rule | Detail |
272
+ | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
273
+ | **Batch by phase** | One phase/project batch = one branch, one worktree, one PR |
274
+ | **Commit by issue** | Each issue gets its own implementation commit with a `#issue` reference. **File-overlap exception** (Phase 2): co-commit issues that touch the same files, cite all issue numbers in the subject. The PR body's `Closes #` lines still auto-close every issue on merge. |
275
+ | **Validate before PR** | Run the project's pre-push gate / precheck (build, lint, tests, plus path-gated checks for E2E, migrations, IaC, containers). The local pre-push hook runs it automatically if the project has one. See `/pre-push`. |
276
+ | **Draft-first PR** | Always `gh pr create --draft`. Mark **Ready for review** (`gh pr ready`) only after the local review is resolved and the gate is green — that triggers any expensive ready-for-review CI matrix. |
277
+ | **Local review** | Run a local code review **before push** (Phase 3); fix Critical + Warning, re-run clean (~2 passes max). After opening the PR, post findings onto the work item (skill `comment-issue`) as one marked comment for closeout to mine. |
278
+ | **Reflect before handoff** | Update `docs/agent-lessons/`, the agent profile, and rules/instructions when the PR reveals a reusable lesson; PR generalizable lessons back to the engsys lessons-library. |
279
+ | **tmp/ always** | Commit messages, PR bodies, issue bodies — never HEREDOC or pipe |
280
+ | **No commit pause** | A start/implement command for this workflow authorizes routine commits, branch push, PR creation, and local-review fixes |
281
+
282
+ ---
283
+
284
+ ## Completion Checklist
285
+
286
+ ```text
287
+ [ ] docs/agent-lessons/ reviewed before starting
288
+ [ ] Batch scope selected: phase, unphased project, or single issue
289
+ [ ] Worktree and branch created for the batch (from origin/main, -b flag)
290
+ [ ] Every issue assigned to the implementer
291
+ [ ] Each issue has its own implementation commit referencing #N (or a single co-commit citing all overlapping issue numbers per the file-overlap exception)
292
+ [ ] Pre-push gate passes (build, lint, tests, and path-gated gates)
293
+ [ ] Local review run; Critical + Warning findings resolved, re-run clean
294
+ [ ] Branch pushed to origin
295
+ [ ] PR created as DRAFT, work items linked/closed per link-pr (GitHub: one Closes line per issue)
296
+ [ ] Review findings posted onto the work item via comment-issue, as a marked comment (or "0 findings")
297
+ [ ] PR marked Ready for review (gh pr ready <n>)
298
+ [ ] Reflection completed and learning/profile/rule updates committed if needed
299
+ [ ] CI green and PR ready for human review
300
+ [ ] Human squash-merged the PR
301
+ [ ] main checked out and pulled
302
+ [ ] Worktree removed, local branch deleted, worktrees pruned
303
+ ```
304
+
305
+ ---
306
+
307
+ ## Troubleshooting
308
+
309
+ **Worktree creation fails** — You probably created the branch first. Delete it and use the `-b` flag:
310
+
311
+ ```bash
312
+ git branch -d agent/<phase-or-project-slug>
313
+ git worktree add ../worktrees/<phase-or-project-slug> -b agent/<phase-or-project-slug> origin/main
314
+ ```
315
+
316
+ **Worktree remove fails — "Directory not empty"** — Empty the worktree directory before `git worktree remove` (e.g. leftover `node_modules`, `dist`, build output). From the repo root:
317
+
318
+ ```bash
319
+ rm -rf ../worktrees/<phase-or-project-slug>/*
320
+ git worktree remove ../worktrees/<phase-or-project-slug> --force
321
+ git worktree prune
322
+ ```
323
+
324
+ **Build errors about generated code** — Codegen wasn't run. Re-run the project's codegen step inside the worktree.
325
+
326
+ **Merge conflicts** — Rebase on main:
327
+
328
+ ```bash
329
+ git fetch origin && git rebase origin/main
330
+ ```
331
+
332
+ If the rebase stops on a commit that was already merged to main, skip it:
333
+
334
+ ```bash
335
+ git rebase --skip
336
+ ```
337
+
338
+ Never `git rebase --abort` just because of "already applied" warnings; that is expected when rebasing stacked branches.
339
+
340
+ **Local main diverged from origin/main** — Fix with rebase, not merge:
341
+
342
+ ```bash
343
+ git fetch origin && git rebase origin/main
344
+ ```
345
+
346
+ **Batch feels too large** — Stop and ask the human before splitting. The default remains one PR per phase or unphased project, not one PR per issue.
@@ -0,0 +1,258 @@
1
+ # Generate Project Workflow
2
+
3
+ Use this workflow when the operator asks to generate a feature design, spec, plan, or project from a goal. Output is a reviewed draft spec in `docs/specs/`, an organized tracker project, phased issues, and updated agent learning where useful.
4
+
5
+ Invocation examples:
6
+
7
+ ```text
8
+ /generate-project <goal> [attachments...]
9
+ generate project: <goal>
10
+ build a feature spec/plan for <goal>
11
+ ```
12
+
13
+ ---
14
+
15
+ ## Operating Rules
16
+
17
+ - Explore first. Do not ask generic questions until you have read relevant code, docs, existing issues/projects, and attachments.
18
+ - Batch clarifying questions. Ask once, wait for answers, then proceed.
19
+ - Use subagents for perspective, not delegation drift. The parent agent owns the spec and reconciles conflicts.
20
+ - Make the spec the shared source of truth. Every subagent enriches `docs/specs/<slug>.md` directly or returns structured content for the parent to merge.
21
+ - Tracker project + issue writes go through the project's installed **issue-tracker skill** (`.claude/skills/issue-tracker-*/`) and its contract operations (`create-issue`, `create-board`, `add-to-board`, `set-board-field`, `query-board`). The skill maps them onto the active backend; on GitHub it uses `gh` (ProjectV2 MCP tools are unsupported there, so the skill drives `gh project` / `gh api graphql`).
22
+ - Write issue bodies to `tmp/` and create them via the skill's `create-issue` operation (GitHub: `gh issue create --body-file`). Never HEREDOC issue bodies — the tmp/-file discipline is universal.
23
+ - Issue-body invariants (every one of these has been a sanity-check finding at least once):
24
+ - Every body carries one context line: `Part of [<project name> — project <N>](<board url>) · spec: docs/specs/<slug>.md`. Section citations ("spec §2.2") are unresolvable without it.
25
+ - No placeholder cross-references (`#BUNDLE`, `#SERIALIZER`, ALL-CAPS tokens). Create issues in dependency order or backfill numbers after creation, then **grep all bodies for placeholders** before declaring done. Bare `#<small-number>` shorthand for non-issue concepts (e.g. "punch item 12") autolinks to the wrong issue — write "punch item 12" or use the real issue #.
26
+ - Counts in acceptance criteria must be **call sites, not grep lines** (imports inflate grep counts) — state the exact grep that reproduces the number inside the issue.
27
+ - One implementation PR per phase means a phase must be one-PR-sized; split infra (which may trigger a deploy workflow) from app code into separate phases.
28
+ - Optimize final specs, lessons, rules, and agent instructions for future LLM retrieval.
29
+
30
+ ---
31
+
32
+ ## Phase 0: Intake
33
+
34
+ The operator provides:
35
+
36
+ - The goal or product outcome.
37
+ - Relevant attachments: screenshots, docs, links, logs, issue lists, customer notes, designs, or code pointers.
38
+ - Optional constraints: deadline, scope, target user, tier, services, non-goals, project naming.
39
+
40
+ Record initial assumptions in the draft spec later, but do not freeze them before exploration.
41
+
42
+ ---
43
+
44
+ ## Phase 1: Explore Context
45
+
46
+ Build informed questions from evidence.
47
+
48
+ Read:
49
+
50
+ - `docs/agent-lessons/` (and the engsys lessons-library if linked)
51
+ - `docs/architecture/` relevant pages
52
+ - project rules / `CLAUDE.md`
53
+ - `.claude/agents/{leith,melvin,nyx,marcelo,jody}.md`
54
+ - Existing specs in `docs/specs/`
55
+ - Related source files, routes, services, schemas, UI components, tests, seed scripts
56
+ - Provided attachments and linked resources
57
+ - Existing tracker issues/projects if the goal references them
58
+
59
+ Capture: user/persona affected, current behavior, data model & API surface touched, service boundaries, security/auth/tenant implications, test surfaces and existing coverage, and unknowns that materially change product, architecture, security, testing, or plan shape.
60
+
61
+ Do not over-explore. Stop when questions are specific and answerable.
62
+
63
+ ---
64
+
65
+ ## Phase 2: Ask Clarifying Questions
66
+
67
+ Ask the operator one batched set of clarifying questions. Prefer structured options when possible.
68
+
69
+ Quality bar: no questions answerable from repo/docs; no more than 5–8 unless genuinely ambiguous; each question explains the decision it unlocks; include recommended defaults when useful.
70
+
71
+ Good categories: target users and primary job-to-be-done; must-have vs deferred; data visibility and tenant boundaries; integration/source-of-truth choices; rollout/entitlement/tier constraints; success metrics; design constraints from attachments.
72
+
73
+ After the operator answers, update assumptions and proceed. If answers conflict with repo reality, call that out and choose the safer interpretation.
74
+
75
+ ---
76
+
77
+ ## Phase 3: Start Draft Spec
78
+
79
+ Create `docs/specs/<feature-slug>.md`:
80
+
81
+ ```markdown
82
+ # <Feature / Project Name>
83
+
84
+ Status: Draft
85
+ Owner: <operator or team>
86
+ Generated: <date>
87
+
88
+ ## Goal
89
+
90
+ ## Context
91
+
92
+ ## Operator Inputs
93
+
94
+ ## Assumptions
95
+
96
+ ## Non-Goals
97
+
98
+ ## Open Questions
99
+
100
+ ## Product and UX Specification
101
+
102
+ ## Architecture Specification
103
+
104
+ ## Security and Privacy Specification
105
+
106
+ ## Testing Strategy
107
+
108
+ ## Phased Project Plan
109
+
110
+ ## Tracker Project and Issues
111
+
112
+ ## Implementation Notes
113
+
114
+ ## Review Checklist
115
+ ```
116
+
117
+ Frame the goal and context before launching subagents so each receives the same baseline.
118
+
119
+ ---
120
+
121
+ ## Phase 4: Design Loop
122
+
123
+ Launch Leith and Melvin in parallel when possible, then Nyx, then reconcile, then Marcelo, then Jody. Pass each subagent the goal, answered clarifications, an attachments summary, the spec path, and the exact requested output.
124
+
125
+ Subagents do not automatically know parent context. Include enough detail in every prompt for autonomous work.
126
+
127
+ ### 4A: Leith — Product/UX
128
+
129
+ Enrich the spec with: product problem and target persona; user stories and jobs-to-be-done; happy path, sad paths, empty/loading/error states; information architecture and navigation entry points; UI behavior, copy intent, accessibility expectations; acceptance criteria from a user perspective; product tradeoffs and recommended scope boundaries. Returns structured markdown for `Product and UX Specification`.
130
+
131
+ ### 4B: Melvin — Architecture
132
+
133
+ Enrich the spec with: whole-app architecture impact; affected services, modules, APIs, schemas, queues, jobs, integrations; data ownership and consistency model; latency, scale, cost, observability, failure modes; migration/backfill/rollout strategy; implementation invariants and constraints; architecture acceptance criteria. Returns structured markdown for `Architecture Specification`.
134
+
135
+ ### 4C: Nyx — Security
136
+
137
+ Given the merged Leith+Melvin draft, enrich with: threat model and trust boundaries; tenant isolation risks; authn/authz requirements; abuse cases and attacker stories; input validation and output encoding; secrets, logging, audit, PII, data retention; security tests and required mitigations; must-fix design changes vs acceptable follow-ups. Returns `Security and Privacy Specification` and a list of required changes.
138
+
139
+ ### 4D: Reconcile Nyx Findings
140
+
141
+ If Nyx identifies required changes: send product/interaction findings back to Leith, architecture/platform findings back to Melvin; ask for revised spec patches (not new standalone opinions); merge revisions; keep unresolved disagreements in `Open Questions` with a recommended decision. **Do not proceed to testing strategy while security-required product or architecture changes are unresolved.**
142
+
143
+ ### 4E: Marcelo — Testing Strategy
144
+
145
+ Given the reconciled sections, enrich with: testability assessment; unit/integration/E2E/contract/security/performance/accessibility test strategy; input validation matrix for every accepted input; regression impact; seed data/fixtures/factories/local dev data needs; CI quality gates; manual verification paths; test ownership and issue recommendations. Returns `Testing Strategy` and test work items for Jody.
146
+
147
+ ### 4F: Jody — Planning and Project Creation
148
+
149
+ Given the full reconciled spec, ask Jody to: convert it into a phased project plan; define phases that map to future implementation PR batches; create ordered, labeled tracker issues (with dependencies, acceptance criteria, owner persona, labels, test obligations) via the issue-tracker skill's `create-issue` operation; create the tracker board with the skill's `create-board` operation; add issues to the board (`add-to-board`) and set Phase/Priority/Owner/Status fields with `set-board-field` (on GitHub these run `gh project` / `gh api graphql`); enrich the spec with project number, issue list, phase order, dependencies, and implementation handoff notes.
150
+
151
+ Jody's output must be concrete enough that Isabelle can implement each phase using [agent-implementation-workflow.md](agent-implementation-workflow.md).
152
+
153
+ ---
154
+
155
+ ## Phase 5: Tracker Project Mechanics
156
+
157
+ All project and issue writes go through the issue-tracker skill's contract operations — `create-board`, `create-issue`, `add-to-board`, `set-board-field`, `query-board`. The skill (`.claude/skills/issue-tracker-*/`) carries the backend specifics; the GitHub commands below are what that skill runs on a GitHub project.
158
+
159
+ On GitHub, check auth and project scope first:
160
+
161
+ ```bash
162
+ gh auth status
163
+ gh auth refresh -h github.com --scopes project # if project scope is missing
164
+ ```
165
+
166
+ Create the board (`create-board`) and issues (`create-issue` — issue bodies in `tmp/`, GitHub `gh issue create --body-file`), then add each issue to the board (`add-to-board` — GitHub `gh project item-add`). `<OWNER>` is the project owner (user or org).
167
+
168
+ ### 5.1 Required custom fields (MANDATORY — not optional)
169
+
170
+ Every project created by this workflow **must** carry a `Phase` single-select field. Without it `/implement-project` cannot batch issues into phase-PRs and the plan reverts to a flat "Todo" status that `/implement-issue` has to walk one issue at a time. Skipping this creates weeks of avoidable retrofit work — do not.
171
+
172
+ **Required fields:**
173
+
174
+ | Field | Type | Options |
175
+ | ---------- | ------------- | ------------------------------------------------------------------------------------------------ |
176
+ | `Phase` | Single select | `P0: <name>`, `P1: <name>`, `P2: <name>`, … (one per implementation PR; name describes the batch) |
177
+ | `Priority` | Single select | `P0` (must ship), `P1` (should ship), `P2` (nice to have), `P3` (deferred) |
178
+ | `Owner` | Single select | the project's agent personas (e.g. `Isabelle`, `Aaron`, `Otto`, `Bert`, `Melvin`, `Nyx`, `Marcelo`, `Leith`, `Jody`) |
179
+
180
+ `Status` (created by the tracker by default — `Todo`, `In Progress`, `Done`) is reused as-is; do not duplicate.
181
+
182
+ **Phase naming rule:** `P<n>: <short batch name>`. The `P<n>` prefix is what `/implement-project` reads to order phases; the short name is for humans. Use `P-1: <name>` for "must happen before P0" prework. Skip-level numbering (`P1.5`) is allowed when a phase is inserted late.
183
+
184
+ ### 5.2 Create the custom fields
185
+
186
+ The Phase/Priority/Owner fields are part of the `create-board` operation. On GitHub the skill creates each field — prefer `gh project field-create`, fall back to GraphQL:
187
+
188
+ ```bash
189
+ gh project field-create <PROJECT_NUMBER> --owner <OWNER> \
190
+ --name "Phase" --data-type SINGLE_SELECT \
191
+ --single-select-options "P0: <name>,P1: <name>,P2: <name>"
192
+ # repeat for Priority and Owner
193
+ ```
194
+
195
+ GraphQL fallback when `gh project field-create` is unavailable: `createProjectV2Field` mutation with `dataType: SINGLE_SELECT` and `singleSelectOptions` (each option needs a `name` and a `color` — valid: `GRAY`, `BLUE`, `GREEN`, `YELLOW`, `ORANGE`, `RED`, `PURPLE`, `PINK`).
196
+
197
+ ### 5.3 Set field values on every issue
198
+
199
+ Set each item's Phase/Priority/Owner via the skill's `set-board-field` operation. On GitHub: look up field IDs + option IDs once, then `gh project item-edit --id <ITEM> --field-id <FIELD> --project-id <PROJECT> --single-select-option-id <OPTION>` (GraphQL `updateProjectV2ItemFieldValue` is the scripting fallback).
200
+
201
+ **Verification before declaring Phase 5 complete:** every project item must have a non-null `Phase` AND `Owner` value (the "no empty Phase" rule is part of the contract). Re-query items via `query-board` and assert no item's `Phase` is null; if any are, set them and re-verify. The verification output must be empty.
202
+
203
+ ---
204
+
205
+ ## Phase 6: Sanity Check
206
+
207
+ Run a fresh general-purpose or planning subagent with **no prior design-loop context**. Give it the final spec path, project number, issue numbers, and the rule: one phase = one implementation PR; each issue = one commit.
208
+
209
+ Ask it to verify: the spec goal maps to phases and issues; every acceptance criterion has an issue; every security requirement has an issue or explicit AC; every testing requirement has an issue or AC; dependencies are ordered correctly; phase boundaries are implementation-friendly; labels and owners match conventions; no duplicate/missing/vague issues; no hidden work outside the project; **the project has `Phase`, `Priority`, `Owner` fields populated for every item** (re-query via the skill's `query-board` — if any item is missing a `Phase`, the sanity check fails and Jody must fix it before handoff).
210
+
211
+ Merge sanity-check fixes into the spec. If issues must change, update the tracker immediately.
212
+
213
+ ---
214
+
215
+ ## Phase 7: Reflect and Update Memory
216
+
217
+ Before reporting back, reflect: did tool choice slow the workflow? Did subagents lack context because prompts were too thin? Did board creation require steps the issue-tracker skill should document (e.g. undocumented `gh`/GraphQL steps on GitHub)? Did any agent disagree in a way future agents should anticipate? Did attachments need a better parsing pattern? Did the spec miss a section until late?
218
+
219
+ Actions: create/update `docs/agent-lessons/` (PR generalizable lessons back to the engsys lessons-library); update relevant `.claude/agents/*.md` if a role should change; update rules / prompt docs if a behavior should become automatic. Keep memory concise and LLM-optimized: trigger, failure mode, correct behavior, commands/files.
220
+
221
+ ---
222
+
223
+ ## Phase 8: Report Back
224
+
225
+ Final response to the operator must include: spec path; tracker project link/number; issue list grouped by phase; subagents used and what each contributed; sanity-check result; learning/rule/profile updates made; open questions or decisions needing operator review; explicit request for operator review of the spec/plan before implementation starts. Keep the report short — the spec and project are the durable artifacts.
226
+
227
+ ---
228
+
229
+ ## Spec Quality Checklist
230
+
231
+ ```text
232
+ [ ] Goal and context grounded in repo/docs/attachments
233
+ [ ] Clarifying questions asked in one batch and answered
234
+ [ ] Draft spec created in docs/specs/
235
+ [ ] Leith enriched product/UX
236
+ [ ] Melvin enriched architecture
237
+ [ ] Nyx enriched security/privacy
238
+ [ ] Leith/Melvin revised after Nyx findings if needed
239
+ [ ] Marcelo enriched testing strategy
240
+ [ ] Jody created the phased plan
241
+ [ ] Tracker board created via the issue-tracker skill (create-board)
242
+ [ ] Issues created via the skill (create-issue) with tmp/ body files
243
+ [ ] Issues added to project and organized by phase (add-to-board / set-board-field)
244
+ [ ] Phase / Priority / Owner single-select fields created (5.1, 5.2)
245
+ [ ] Every project item has a non-null Phase value (5.3) — verified via re-query
246
+ [ ] Fresh sanity-check subagent reviewed spec/project/issues
247
+ [ ] Spec updated after sanity check
248
+ [ ] Agent lessons/rules/profiles updated if the workflow revealed reusable lessons
249
+ [ ] Operator received a concise report and review request
250
+ ```
251
+
252
+ ---
253
+
254
+ ## Handoff to Implementation
255
+
256
+ After the operator approves the spec/plan, implementation follows [agent-implementation-workflow.md](agent-implementation-workflow.md) for a single phase or single issue, or [implement-project-workflow.md](implement-project-workflow.md) for an entire project walked phase-by-phase.
257
+
258
+ Implementation rule: one project phase becomes one PR; every issue in that phase becomes one implementation commit; local review and reflection are required before human handoff. `/implement-project <num>` reads the `Phase` field this workflow created — projects without a populated `Phase` field cannot be auto-implemented and must be retrofitted first (see § 5.1–5.3).