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,124 @@
1
+ ---
2
+ name: git-commit
3
+ description: 'Execute git commit with conventional commit message analysis, intelligent staging, and message generation. Use when user asks to commit changes, create a git commit, or mentions "/commit". Supports: (1) Auto-detecting type and scope from changes, (2) Generating conventional commit messages from diff, (3) Interactive commit with optional type/scope/description overrides, (4) Intelligent file staging for logical grouping'
4
+ license: MIT
5
+ allowed-tools: Bash
6
+ ---
7
+
8
+ # Git Commit with Conventional Commits
9
+
10
+ ## Overview
11
+
12
+ Create standardized, semantic git commits using the Conventional Commits specification. Analyze the actual diff to determine appropriate type, scope, and message.
13
+
14
+ ## Conventional Commit Format
15
+
16
+ ```text
17
+ <type>[optional scope]: <description>
18
+
19
+ [optional body]
20
+
21
+ [optional footer(s)]
22
+ ```
23
+
24
+ ## Commit Types
25
+
26
+ | Type | Purpose |
27
+ | ---------- | ------------------------------ |
28
+ | `feat` | New feature |
29
+ | `fix` | Bug fix |
30
+ | `docs` | Documentation only |
31
+ | `style` | Formatting/style (no logic) |
32
+ | `refactor` | Code refactor (no feature/fix) |
33
+ | `perf` | Performance improvement |
34
+ | `test` | Add/update tests |
35
+ | `build` | Build system/dependencies |
36
+ | `ci` | CI/config changes |
37
+ | `chore` | Maintenance/misc |
38
+ | `revert` | Revert commit |
39
+
40
+ ## Breaking Changes
41
+
42
+ ```text
43
+ # Exclamation mark after type/scope
44
+ feat!: remove deprecated endpoint
45
+
46
+ # BREAKING CHANGE footer
47
+ feat: allow config to extend other configs
48
+
49
+ BREAKING CHANGE: `extends` key behavior changed
50
+ ```
51
+
52
+ ## Workflow
53
+
54
+ ### 1. Analyze Diff
55
+
56
+ ```bash
57
+ # If files are staged, use staged diff
58
+ git diff --staged
59
+
60
+ # If nothing staged, use working tree diff
61
+ git diff
62
+
63
+ # Also check status
64
+ git status --porcelain
65
+ ```
66
+
67
+ ### 2. Stage Files (if needed)
68
+
69
+ If nothing is staged or you want to group changes differently:
70
+
71
+ ```bash
72
+ # Stage specific files
73
+ git add path/to/file1 path/to/file2
74
+
75
+ # Stage by pattern
76
+ git add *.test.*
77
+ git add src/components/*
78
+
79
+ # Interactive staging
80
+ git add -p
81
+ ```
82
+
83
+ **Never commit secrets** (.env, credentials.json, private keys).
84
+
85
+ ### 3. Generate Commit Message
86
+
87
+ Analyze the diff to determine:
88
+
89
+ - **Type**: What kind of change is this?
90
+ - **Scope**: What area/module is affected?
91
+ - **Description**: One-line summary of what changed (present tense, imperative mood, <72 chars)
92
+
93
+ ### 4. Execute Commit
94
+
95
+ ```bash
96
+ # Single line
97
+ git commit -m "<type>[scope]: <description>"
98
+
99
+ # Multi-line with body/footer
100
+ git commit -m "$(cat <<'EOF'
101
+ <type>[scope]: <description>
102
+
103
+ <optional body>
104
+
105
+ <optional footer>
106
+ EOF
107
+ )"
108
+ ```
109
+
110
+ ## Best Practices
111
+
112
+ - One logical change per commit
113
+ - Present tense: "add" not "added"
114
+ - Imperative mood: "fix bug" not "fixes bug"
115
+ - Reference issues: `Closes #123`, `Refs #456`
116
+ - Keep description under 72 characters
117
+
118
+ ## Git Safety Protocol
119
+
120
+ - NEVER update git config
121
+ - NEVER run destructive commands (--force, hard reset) without explicit request
122
+ - NEVER skip hooks (--no-verify) unless user asks
123
+ - NEVER force push to main/master
124
+ - If commit fails due to hooks, fix and create NEW commit (don't amend)
@@ -0,0 +1,462 @@
1
+ ---
2
+ name: git-workflow-agents
3
+ description: Implement GitHub issues using isolated Git worktrees to prevent conflicts when multiple AI agents work in parallel. Use when implementing issues, creating feature branches, or when the user mentions worktrees, parallel work, or agent implementation workflow.
4
+ ---
5
+
6
+ # Git Workflow for Agents
7
+
8
+ This skill guides AI agents through implementing GitHub issues in **isolated worktrees** to prevent source tree conflicts during parallel work.
9
+
10
+ ## Why Worktrees?
11
+
12
+ Git worktrees provide independent working directories while sharing the same `.git` repository, preventing:
13
+
14
+ - File conflicts between agents
15
+ - Branch collisions
16
+ - Build interference
17
+ - Test pollution
18
+ - Context confusion
19
+
20
+ ## Quick Start: Implementing an Issue
21
+
22
+ ### Phase 1: Session Initialization
23
+
24
+ #### Step 1: Claim the Issue
25
+
26
+ ```bash
27
+ # Preferred: gh CLI
28
+ gh issue edit 42 --repo <owner>/<repo> --add-assignee @me
29
+ ```
30
+
31
+ The `github` MCP server (in [.mcp.json](../../../.mcp.json)) is a fallback for when `gh` auth or network fails. Project board operations (priorities, fields, statuses) **must** still use `gh project` / `gh api graphql` — the MCP server doesn't support ProjectV2.
32
+
33
+ #### Step 2: Create Worktree and Branch
34
+
35
+ **CRITICAL**: Create branch and worktree together using `-b` flag:
36
+
37
+ ```bash
38
+ # Navigate to main repo
39
+ cd <repo-root> # e.g. /Users/<you>/git/<project>
40
+
41
+ # Update main branch
42
+ git fetch origin
43
+ git checkout main
44
+ git pull origin main
45
+
46
+ # Create worktree AND branch together (required)
47
+ git worktree add ../worktrees/issue-<number>-<slug> -b agent/<issue>-<slug>
48
+
49
+ # Example:
50
+ git worktree add ../worktrees/issue-42-tenant-validation -b agent/42-tenant-validation
51
+ ```
52
+
53
+ **Common Mistake to Avoid:**
54
+
55
+ ```bash
56
+ # ❌ WRONG - Don't create branch first
57
+ git checkout -b agent/42-tenant-validation
58
+ git worktree add ../worktrees/issue-42-tenant-validation agent/42-tenant-validation
59
+
60
+ # ✅ CORRECT - Use -b flag
61
+ git worktree add ../worktrees/issue-42-tenant-validation -b agent/42-tenant-validation
62
+ ```
63
+
64
+ #### Step 3: Initialize Environment
65
+
66
+ ```bash
67
+ # Navigate to worktree
68
+ cd ../worktrees/issue-42-tenant-validation
69
+
70
+ # Copy environment config from the main checkout
71
+ cp ../../<project>/.env.local .env.local
72
+
73
+ # Install dependencies (isolated) — use the project's package/dependency manager
74
+ <install-deps-command>
75
+
76
+ # Verify setup
77
+ <build-command>
78
+ ```
79
+
80
+ #### Step 4: Confirm Isolation
81
+
82
+ ```bash
83
+ # Verify branch
84
+ git branch --show-current
85
+ # Should output: agent/42-tenant-validation
86
+
87
+ # Verify worktrees
88
+ git worktree list
89
+ # Should show both main repo and your worktree
90
+ ```
91
+
92
+ ### Phase 2: Implementation
93
+
94
+ **Work entirely in your worktree**. Standard development cycle:
95
+
96
+ **Make Changes:**
97
+
98
+ - Edit files using Write/StrReplace tools
99
+ - Run tests: `<test-command>`
100
+ - Build: `<build-command>`
101
+ - Lint: `<lint-command>`
102
+
103
+ **CRITICAL Pre-Push Verification:**
104
+
105
+ Before pushing, ALWAYS verify (see root CLAUDE.md § Pre-push gate and the `pre-push` skill):
106
+
107
+ ```bash
108
+ <build-command> # Must pass
109
+ <lint-command> # Must pass
110
+ <test-command> # Must pass (if applicable)
111
+ ```
112
+
113
+ **Commit Strategy:**
114
+
115
+ ```bash
116
+ # Commit frequently to checkpoint work
117
+ git add -A
118
+ git commit -m "feat(scope): implement core change (#42)"
119
+
120
+ # Continue working, commit again
121
+ git commit -m "test(scope): add edge case tests (#42)"
122
+
123
+ # Continue, commit docs
124
+ git commit -m "docs(scope): update docs (#42)"
125
+
126
+ # NOW verify everything and push all commits together
127
+ <build-command>; <lint-command> # Verify first
128
+ git push # Pushes all commits - triggers CI ONCE
129
+ ```
130
+
131
+ **When to Batch Commits (Preferred):**
132
+
133
+ - Related feature work across multiple commits
134
+ - Implementation + tests + docs
135
+ - Sequential fixes for same issue
136
+
137
+ **When to Push Immediately:**
138
+
139
+ - Critical security fixes
140
+ - Breaking production issues
141
+ - Changes others are waiting on
142
+
143
+ **Stay Current with Main:**
144
+
145
+ ```bash
146
+ # Rebase regularly to avoid drift
147
+ git fetch origin main
148
+ git rebase origin/main
149
+
150
+ # Resolve conflicts if any
151
+ # Then: git rebase --continue
152
+ ```
153
+
154
+ ### Phase 3: Completion
155
+
156
+ #### Step 1: Final Validation
157
+
158
+ Before pushing, verify everything:
159
+
160
+ ```bash
161
+ # Required checks
162
+ <build-command> # No build/compile errors
163
+ <lint-command> # No linting errors
164
+ <test-command> # All tests pass
165
+
166
+ # For changes that require codegen (schema/data layer, generated clients, etc.)
167
+ <codegen-command> # Regenerate any generated artifacts
168
+ <build-command> # Verify dependent packages still build
169
+ ```
170
+
171
+ **If any check fails:**
172
+
173
+ - ❌ DO NOT PUSH
174
+ - Fix issues locally
175
+ - Re-run checks until all pass
176
+ - Then push
177
+
178
+ #### Step 2: Push Branch
179
+
180
+ ```bash
181
+ git push -u origin agent/42-tenant-validation
182
+ ```
183
+
184
+ #### Step 3: Create Pull Request
185
+
186
+ Use tmp/ folder for PR body (NEVER use HEREDOC):
187
+
188
+ ```bash
189
+ # 1. Create PR body using Write tool in tmp/pr-body-42.md
190
+ # Include:
191
+ # - Summary of changes
192
+ # - Closes #42
193
+ # - Testing checklist
194
+
195
+ # 2. Create PR
196
+ gh pr create \
197
+ --base main \
198
+ --head agent/42-tenant-validation \
199
+ --title "fix(scope): short description" \
200
+ --body-file tmp/pr-body-42.md
201
+ ```
202
+
203
+ #### Step 4: Auto-Close Issue
204
+
205
+ If PR body includes `Closes #42`, GitHub auto-closes the issue when PR merges.
206
+
207
+ ### Phase 4: Cleanup (After PR Merge)
208
+
209
+ Empty the worktree directory before `git worktree remove`, or it may fail with "Directory not empty" (common on Windows with leftover node_modules, dist).
210
+
211
+ ```bash
212
+ # Navigate to main repo
213
+ cd <repo-root> # e.g. /Users/<you>/git/<project>
214
+
215
+ # Empty worktree directory first (avoids "Directory not empty" on Windows; harmless on mac)
216
+ rm -rf ../worktrees/issue-42-tenant-validation/*
217
+
218
+ # Remove worktree
219
+ git worktree remove ../worktrees/issue-42-tenant-validation
220
+
221
+ # Force remove if uncommitted changes or if empty failed
222
+ git worktree remove --force ../worktrees/issue-42-tenant-validation
223
+
224
+ # Delete local branch (optional)
225
+ git branch -d agent/42-tenant-validation
226
+
227
+ # Delete remote branch if not auto-deleted
228
+ git push origin --delete agent/42-tenant-validation
229
+ ```
230
+
231
+ ## Critical Rules
232
+
233
+ ### 1. Use tmp/ Folder for Complex Content
234
+
235
+ **NEVER use HEREDOC or pipes** for commit messages, PR bodies, or issue content:
236
+
237
+ ```bash
238
+ # ✅ GOOD - Use tmp/ folder
239
+ # 1. Write content to tmp/commit-msg-42.txt using Write tool
240
+ # 2. Then commit:
241
+ git commit --file tmp/commit-msg-42.txt
242
+
243
+ # ✅ GOOD - PR body
244
+ # 1. Write to tmp/pr-body-42.md using Write tool
245
+ # 2. Then create PR:
246
+ gh pr create --title "fix: description" --body-file tmp/pr-body-42.md
247
+
248
+ # ❌ BAD - HEREDOC or pipes
249
+ git commit -m "$(cat <<'EOF'
250
+ Long message
251
+ EOF
252
+ )"
253
+ ```
254
+
255
+ ### 2. Verify Before Pushing
256
+
257
+ From root CLAUDE.md § Pre-push gate:
258
+
259
+ - Run the project's build, lint, and test commands locally
260
+ - Fix all issues before pushing
261
+ - Don't use CI as your linter
262
+ - Saves GitHub Actions minutes (finite resource)
263
+
264
+ ### 3. Batch Commits Before Pushing
265
+
266
+ - Group related changes (feature + tests + docs)
267
+ - Push once for multiple commits
268
+ - Don't push individual lint fixes
269
+
270
+ ### 4. IaC-First for Infrastructure
271
+
272
+ If the project provisions infrastructure, all infrastructure changes MUST go through
273
+ infrastructure-as-code (Terraform, Bicep, CloudFormation, Pulumi, etc.) rather than manual
274
+ console edits. Validate the IaC locally before committing, using the project's chosen tool. See
275
+ the project's infrastructure CLAUDE.md / stack fragment for the exact commands.
276
+
277
+ ### 5. Tool preference order
278
+
279
+ See root CLAUDE.md § Tool preference order:
280
+
281
+ - Use `gh` CLI first (issues, PRs, Actions, Projects, GraphQL, `--format json`).
282
+ - The `github` MCP server (in `.mcp.json`) is a fallback for when `gh` auth/network fails.
283
+ - ProjectV2 (project boards) **always** use `gh project` / `gh api graphql` — MCP does not support them.
284
+
285
+ ## Directory Structure
286
+
287
+ ```text
288
+ <repo-root>/ # e.g. /Users/<you>/git/
289
+ ├── <project>/ # Main repository (trunk)
290
+ │ ├── .git/ # Shared git data
291
+ │ ├── src/
292
+ │ ├── infrastructure/
293
+ │ └── ...
294
+
295
+ └── worktrees/ # Parallel agent workspaces
296
+ ├── issue-42-tenant-validation/
297
+ │ ├── src/
298
+ │ ├── <deps-dir>/ # Isolated dependencies (node_modules, .venv, target, …)
299
+ │ └── .env.local # Copied from main
300
+
301
+ └── issue-57-add-export-api/
302
+ └── ...
303
+ ```
304
+
305
+ ## Handling Complications
306
+
307
+ ### Database Migrations
308
+
309
+ **Problem**: Multiple agents running migrations simultaneously can corrupt a shared DB.
310
+
311
+ **Solutions:**
312
+
313
+ 1. Coordinate - only one agent runs migrations at a time
314
+ 2. Separate databases per worktree (override the DB connection string in `.env.local`)
315
+ 3. Use an isolated dev database per worktree
316
+
317
+ ### Merge Conflicts
318
+
319
+ **Solutions:**
320
+
321
+ 1. Rebase early and often: `git rebase origin/main`
322
+ 2. Keep PRs small and focused
323
+ 3. Standard git conflict resolution in your worktree
324
+
325
+ **If rebase stops on a commit already merged to main** (you'll see "skipped previously applied commit" in the output — this is expected for stacked branches), skip it and continue:
326
+
327
+ ```bash
328
+ git rebase --skip
329
+ ```
330
+
331
+ **After successful rebase, always force-push:**
332
+
333
+ ```bash
334
+ git push --force-with-lease origin agent/<branch>
335
+ ```
336
+
337
+ Never use `git push --force` — `--force-with-lease` is safer (fails if someone else pushed).
338
+
339
+ ### Stacked Branches
340
+
341
+ When a group of issues must build on each other (e.g. Phase 1 depends on Phase 0), create each worktree based on the previous branch rather than main:
342
+
343
+ ```bash
344
+ # B depends on A
345
+ git worktree add ../worktrees/issue-<B>-slug agent/<A>-slug -b agent/<B>-slug
346
+ ```
347
+
348
+ **Merge order matters** — merge PRs in dependency order: A → B → C. After each merge:
349
+
350
+ 1. `git fetch origin` in the next worktree
351
+ 2. `git rebase origin/main` — git skips commits now on main automatically
352
+ 3. If it stops on an already-merged commit: `git rebase --skip`
353
+ 4. Verify: `git log --oneline origin/main..HEAD` — should show only your new work
354
+ 5. `git push --force-with-lease`
355
+
356
+ ### Cleanup After All PRs Merged
357
+
358
+ ```bash
359
+ # Bring local main current (rebase, not merge, to stay linear)
360
+ cd /path/to/main/repo
361
+ git fetch origin
362
+ git rebase origin/main
363
+
364
+ # Empty each worktree dir first, then remove (avoids "Directory not empty" on Windows)
365
+ for wt in issue-42-foo issue-43-bar; do
366
+ # PowerShell: rm -rf "../worktrees/$wt/*"
367
+ git worktree remove ../worktrees/$wt --force
368
+ done
369
+ git worktree prune
370
+
371
+ # Delete all local agent branches at once
372
+ git branch | grep "agent/" | xargs git branch -D
373
+ ```
374
+
375
+ ### Shared Cloud Resources
376
+
377
+ **Solutions:**
378
+
379
+ 1. All dev worktrees share dev-environment resources
380
+ 2. Namespace isolation: use issue-number prefixes in queue/topic/bucket names
381
+ 3. Use local emulators where available (local DB, local queue, local cache)
382
+
383
+ ## Session Lifecycle Checklist
384
+
385
+ **Starting Work:**
386
+
387
+ - [ ] Issue assigned to me
388
+ - [ ] Branch created: `agent/<issue>-<slug>`
389
+ - [ ] Worktree created with `-b` flag
390
+ - [ ] `.env.local` copied from main
391
+ - [ ] Dependencies installed
392
+ - [ ] Build passes
393
+ - [ ] Working in worktree, not main repo
394
+
395
+ **During Implementation:**
396
+
397
+ - [ ] All edits in my worktree
398
+ - [ ] Commits reference issue: `(#42)`
399
+ - [ ] Using tmp/ folder for complex content
400
+ - [ ] Rebasing on `origin/main` regularly
401
+ - [ ] Tests pass after significant changes
402
+ - [ ] Following IaC-first for infrastructure
403
+ - [ ] Running build/lint locally before pushing
404
+ - [ ] Batching related commits together
405
+
406
+ **Completing Work:**
407
+
408
+ - [ ] Final build passes
409
+ - [ ] Final tests pass
410
+ - [ ] Type/static checks pass (if applicable)
411
+ - [ ] Lint passes
412
+ - [ ] All verification BEFORE pushing
413
+ - [ ] Commits batched logically
414
+ - [ ] Branch pushed to origin
415
+ - [ ] PR created with tmp/ body
416
+ - [ ] PR includes `Closes #<issue>`
417
+
418
+ **After Merge:**
419
+
420
+ - [ ] Worktree removed
421
+ - [ ] Local branch deleted
422
+ - [ ] Remote branch deleted (if needed)
423
+ - [ ] tmp/ files cleaned up
424
+
425
+ ## Additional Resources
426
+
427
+ For detailed information on:
428
+
429
+ - Database migration strategies
430
+ - Service-specific workflows
431
+ - Helper scripts
432
+ - Troubleshooting scenarios
433
+
434
+ See [reference.md](reference.md)
435
+
436
+ ## Integration with Issue Tracking
437
+
438
+ This workflow integrates with root [CLAUDE.md](../../../CLAUDE.md) § Filing issues:
439
+
440
+ | Phase | Issue Tracking | Git Workflow |
441
+ | -------------- | ----------------------- | ------------------------------- |
442
+ | Discovery | User reports issue | — |
443
+ | Investigation | AI investigates | — |
444
+ | Issue Creation | AI creates GitHub issue | — |
445
+ | Implementation | — | AI creates worktree, implements |
446
+ | Completion | AI closes issue | AI creates PR, cleans up |
447
+
448
+ **Handoff**: Once issue exists with clear solution, this workflow takes over.
449
+
450
+ ## Remember
451
+
452
+ **Key Principles:**
453
+
454
+ - One issue, one branch, one worktree
455
+ - Use tmp/ folder for complex content
456
+ - Prefer `gh` CLI (`github` MCP is a fallback only)
457
+ - Follow IaC-first principle
458
+ - **Always verify locally before pushing**
459
+ - **Batch commits before pushing**
460
+ - Clean up promptly after merge
461
+
462
+ **This workflow enables parallel agent work without conflicts.**