anvil-dev-framework 0.1.6

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 (190) hide show
  1. package/README.md +719 -0
  2. package/VERSION +1 -0
  3. package/docs/ANVIL-REPO-IMPLEMENTATION-PLAN.md +441 -0
  4. package/docs/FIRST-SKILL-TUTORIAL.md +408 -0
  5. package/docs/INSTALLATION-RETRO-NOTES.md +458 -0
  6. package/docs/INSTALLATION.md +984 -0
  7. package/docs/anvil-hud.md +469 -0
  8. package/docs/anvil-init.md +255 -0
  9. package/docs/anvil-state.md +210 -0
  10. package/docs/boris-cherny-ralph-wiggum-insights.md +608 -0
  11. package/docs/command-reference.md +2022 -0
  12. package/docs/hooks-tts.md +368 -0
  13. package/docs/implementation-guide.md +810 -0
  14. package/docs/linear-github-integration.md +247 -0
  15. package/docs/local-issues.md +677 -0
  16. package/docs/patterns/README.md +419 -0
  17. package/docs/planning-responsibilities.md +139 -0
  18. package/docs/session-workflow.md +573 -0
  19. package/docs/simplification-plan-template.md +297 -0
  20. package/docs/simplification-principles.md +129 -0
  21. package/docs/specifications/CCS-RALPH-INTEGRATION-DESIGN.md +633 -0
  22. package/docs/specifications/CCS-RESEARCH-REPORT.md +169 -0
  23. package/docs/specifications/PLAN-ANV-verification-ralph-wiggum.md +403 -0
  24. package/docs/specifications/PLAN-parallel-tracks-anvil-memory-ccs.md +494 -0
  25. package/docs/specifications/SPEC-ANV-VRW/component-01-verify.md +208 -0
  26. package/docs/specifications/SPEC-ANV-VRW/component-02-stop-gate.md +226 -0
  27. package/docs/specifications/SPEC-ANV-VRW/component-03-posttooluse.md +209 -0
  28. package/docs/specifications/SPEC-ANV-VRW/component-04-ralph-wiggum.md +604 -0
  29. package/docs/specifications/SPEC-ANV-VRW/component-05-atomic-actions.md +311 -0
  30. package/docs/specifications/SPEC-ANV-VRW/component-06-verify-subagent.md +264 -0
  31. package/docs/specifications/SPEC-ANV-VRW/component-07-claude-md.md +363 -0
  32. package/docs/specifications/SPEC-ANV-VRW/index.md +182 -0
  33. package/docs/specifications/SPEC-ANV-anvil-memory.md +573 -0
  34. package/docs/specifications/SPEC-ANV-context-checkpoints.md +781 -0
  35. package/docs/specifications/SPEC-ANV-verification-ralph-wiggum.md +789 -0
  36. package/docs/sync.md +122 -0
  37. package/global/CLAUDE.md +140 -0
  38. package/global/agents/verify-app.md +164 -0
  39. package/global/commands/anvil-settings.md +527 -0
  40. package/global/commands/anvil-sync.md +121 -0
  41. package/global/commands/change.md +197 -0
  42. package/global/commands/clarify.md +252 -0
  43. package/global/commands/cleanup.md +292 -0
  44. package/global/commands/commit-push-pr.md +207 -0
  45. package/global/commands/decay-review.md +127 -0
  46. package/global/commands/discover.md +158 -0
  47. package/global/commands/doc-coverage.md +122 -0
  48. package/global/commands/evidence.md +307 -0
  49. package/global/commands/explore.md +121 -0
  50. package/global/commands/force-exit.md +135 -0
  51. package/global/commands/handoff.md +191 -0
  52. package/global/commands/healthcheck.md +302 -0
  53. package/global/commands/hud.md +84 -0
  54. package/global/commands/insights.md +319 -0
  55. package/global/commands/linear-setup.md +184 -0
  56. package/global/commands/lint-fix.md +198 -0
  57. package/global/commands/orient.md +510 -0
  58. package/global/commands/plan.md +228 -0
  59. package/global/commands/ralph.md +346 -0
  60. package/global/commands/ready.md +182 -0
  61. package/global/commands/release.md +305 -0
  62. package/global/commands/retro.md +96 -0
  63. package/global/commands/shard.md +166 -0
  64. package/global/commands/spec.md +227 -0
  65. package/global/commands/sprint.md +184 -0
  66. package/global/commands/tasks.md +228 -0
  67. package/global/commands/test-and-commit.md +151 -0
  68. package/global/commands/validate.md +132 -0
  69. package/global/commands/verify.md +251 -0
  70. package/global/commands/weekly-review.md +156 -0
  71. package/global/hooks/__pycache__/ralph_context_monitor.cpython-314.pyc +0 -0
  72. package/global/hooks/__pycache__/statusline_agent_sync.cpython-314.pyc +0 -0
  73. package/global/hooks/anvil_memory_observe.ts +322 -0
  74. package/global/hooks/anvil_memory_session.ts +166 -0
  75. package/global/hooks/anvil_memory_stop.ts +187 -0
  76. package/global/hooks/parse_transcript.py +116 -0
  77. package/global/hooks/post_merge_cleanup.sh +132 -0
  78. package/global/hooks/post_tool_format.sh +215 -0
  79. package/global/hooks/ralph_context_monitor.py +240 -0
  80. package/global/hooks/ralph_stop.sh +502 -0
  81. package/global/hooks/statusline.sh +1110 -0
  82. package/global/hooks/statusline_agent_sync.py +224 -0
  83. package/global/hooks/stop_gate.sh +250 -0
  84. package/global/lib/.claude/anvil-state.json +21 -0
  85. package/global/lib/__pycache__/agent_registry.cpython-314.pyc +0 -0
  86. package/global/lib/__pycache__/claim_service.cpython-314.pyc +0 -0
  87. package/global/lib/__pycache__/coderabbit_service.cpython-314.pyc +0 -0
  88. package/global/lib/__pycache__/config_service.cpython-314.pyc +0 -0
  89. package/global/lib/__pycache__/coordination_service.cpython-314.pyc +0 -0
  90. package/global/lib/__pycache__/doc_coverage_service.cpython-314.pyc +0 -0
  91. package/global/lib/__pycache__/gate_logger.cpython-314.pyc +0 -0
  92. package/global/lib/__pycache__/github_service.cpython-314.pyc +0 -0
  93. package/global/lib/__pycache__/hygiene_service.cpython-314.pyc +0 -0
  94. package/global/lib/__pycache__/issue_models.cpython-314.pyc +0 -0
  95. package/global/lib/__pycache__/issue_provider.cpython-314.pyc +0 -0
  96. package/global/lib/__pycache__/linear_data_service.cpython-314.pyc +0 -0
  97. package/global/lib/__pycache__/linear_provider.cpython-314.pyc +0 -0
  98. package/global/lib/__pycache__/local_provider.cpython-314.pyc +0 -0
  99. package/global/lib/__pycache__/quality_service.cpython-314.pyc +0 -0
  100. package/global/lib/__pycache__/ralph_state.cpython-314.pyc +0 -0
  101. package/global/lib/__pycache__/state_manager.cpython-314.pyc +0 -0
  102. package/global/lib/__pycache__/transcript_parser.cpython-314.pyc +0 -0
  103. package/global/lib/__pycache__/verification_runner.cpython-314.pyc +0 -0
  104. package/global/lib/__pycache__/verify_iteration.cpython-314.pyc +0 -0
  105. package/global/lib/__pycache__/verify_subagent.cpython-314.pyc +0 -0
  106. package/global/lib/agent_registry.py +995 -0
  107. package/global/lib/anvil-state.sh +435 -0
  108. package/global/lib/claim_service.py +515 -0
  109. package/global/lib/coderabbit_service.py +314 -0
  110. package/global/lib/config_service.py +423 -0
  111. package/global/lib/coordination_service.py +331 -0
  112. package/global/lib/doc_coverage_service.py +1305 -0
  113. package/global/lib/gate_logger.py +316 -0
  114. package/global/lib/github_service.py +310 -0
  115. package/global/lib/handoff_generator.py +775 -0
  116. package/global/lib/hygiene_service.py +712 -0
  117. package/global/lib/issue_models.py +257 -0
  118. package/global/lib/issue_provider.py +339 -0
  119. package/global/lib/linear_data_service.py +210 -0
  120. package/global/lib/linear_provider.py +987 -0
  121. package/global/lib/linear_provider.py.backup +671 -0
  122. package/global/lib/local_provider.py +486 -0
  123. package/global/lib/orient_fast.py +457 -0
  124. package/global/lib/quality_service.py +470 -0
  125. package/global/lib/ralph_prompt_generator.py +563 -0
  126. package/global/lib/ralph_state.py +1202 -0
  127. package/global/lib/state_manager.py +417 -0
  128. package/global/lib/transcript_parser.py +597 -0
  129. package/global/lib/verification_runner.py +557 -0
  130. package/global/lib/verify_iteration.py +490 -0
  131. package/global/lib/verify_subagent.py +250 -0
  132. package/global/skills/README.md +155 -0
  133. package/global/skills/quality-gates/SKILL.md +252 -0
  134. package/global/skills/skill-template/SKILL.md +109 -0
  135. package/global/skills/testing-strategies/SKILL.md +337 -0
  136. package/global/templates/CHANGE-template.md +105 -0
  137. package/global/templates/HANDOFF-template.md +63 -0
  138. package/global/templates/PLAN-template.md +111 -0
  139. package/global/templates/SPEC-template.md +93 -0
  140. package/global/templates/ralph/PROMPT.md.template +89 -0
  141. package/global/templates/ralph/fix_plan.md.template +31 -0
  142. package/global/templates/ralph/progress.txt.template +23 -0
  143. package/global/tests/__pycache__/test_doc_coverage.cpython-314.pyc +0 -0
  144. package/global/tests/test_doc_coverage.py +520 -0
  145. package/global/tests/test_issue_models.py +299 -0
  146. package/global/tests/test_local_provider.py +323 -0
  147. package/global/tools/README.md +178 -0
  148. package/global/tools/__pycache__/anvil-hud.cpython-314.pyc +0 -0
  149. package/global/tools/anvil-hud.py +3622 -0
  150. package/global/tools/anvil-hud.py.bak +3318 -0
  151. package/global/tools/anvil-issue.py +432 -0
  152. package/global/tools/anvil-memory/CLAUDE.md +49 -0
  153. package/global/tools/anvil-memory/README.md +42 -0
  154. package/global/tools/anvil-memory/bun.lock +25 -0
  155. package/global/tools/anvil-memory/bunfig.toml +9 -0
  156. package/global/tools/anvil-memory/package.json +23 -0
  157. package/global/tools/anvil-memory/src/__tests__/ccs/context-monitor.test.ts +535 -0
  158. package/global/tools/anvil-memory/src/__tests__/ccs/edge-cases.test.ts +645 -0
  159. package/global/tools/anvil-memory/src/__tests__/ccs/fixtures.ts +363 -0
  160. package/global/tools/anvil-memory/src/__tests__/ccs/index.ts +8 -0
  161. package/global/tools/anvil-memory/src/__tests__/ccs/integration.test.ts +417 -0
  162. package/global/tools/anvil-memory/src/__tests__/ccs/prompt-generator.test.ts +571 -0
  163. package/global/tools/anvil-memory/src/__tests__/ccs/ralph-stop.test.ts +440 -0
  164. package/global/tools/anvil-memory/src/__tests__/ccs/test-utils.ts +252 -0
  165. package/global/tools/anvil-memory/src/__tests__/commands.test.ts +657 -0
  166. package/global/tools/anvil-memory/src/__tests__/db.test.ts +641 -0
  167. package/global/tools/anvil-memory/src/__tests__/hooks.test.ts +272 -0
  168. package/global/tools/anvil-memory/src/__tests__/performance.test.ts +427 -0
  169. package/global/tools/anvil-memory/src/__tests__/test-utils.ts +113 -0
  170. package/global/tools/anvil-memory/src/commands/checkpoint.ts +197 -0
  171. package/global/tools/anvil-memory/src/commands/get.ts +115 -0
  172. package/global/tools/anvil-memory/src/commands/init.ts +94 -0
  173. package/global/tools/anvil-memory/src/commands/observe.ts +163 -0
  174. package/global/tools/anvil-memory/src/commands/search.ts +112 -0
  175. package/global/tools/anvil-memory/src/db.ts +638 -0
  176. package/global/tools/anvil-memory/src/index.ts +205 -0
  177. package/global/tools/anvil-memory/src/types.ts +122 -0
  178. package/global/tools/anvil-memory/tsconfig.json +29 -0
  179. package/global/tools/ralph-loop.sh +359 -0
  180. package/package.json +45 -0
  181. package/scripts/anvil +822 -0
  182. package/scripts/extract_patterns.py +222 -0
  183. package/scripts/init-project.sh +541 -0
  184. package/scripts/install.sh +229 -0
  185. package/scripts/postinstall.js +41 -0
  186. package/scripts/rollback.sh +188 -0
  187. package/scripts/sync.sh +623 -0
  188. package/scripts/test-statusline.sh +248 -0
  189. package/scripts/update_claude_md.py +224 -0
  190. package/scripts/verify.sh +255 -0
@@ -0,0 +1,984 @@
1
+ # Anvil Installation Plan
2
+
3
+ > Complete guide to installing the Anvil Development Framework for Claude Code.
4
+
5
+ ---
6
+
7
+ ## Executive Summary
8
+
9
+ **What is Anvil?**
10
+ A context engineering framework that transforms Claude Code from a reactive assistant into a proactive development partner through structured workflows, quality gates, and skill-based specialization.
11
+
12
+ **Key Insight**: Production AI coding systems (Devin, Factory, Cursor) converge on a single generalist agent with on-demand skills — not multi-agent orchestration. Anvil implements this pattern.
13
+
14
+ **Installation Time**: 6-8 hours total
15
+ **Prerequisites**: Claude Code, Linear account, Node.js 18+
16
+
17
+ ---
18
+
19
+ ## Background: Research Foundation
20
+
21
+ This framework synthesizes patterns from 15+ production systems:
22
+
23
+ ### Source Systems Analyzed
24
+
25
+ | System | Key Extraction | Stars |
26
+ |--------|---------------|-------|
27
+ | Factory Droid | 6 structural guardrails | Production |
28
+ | Beads | Task memory & ready work | 2.1k |
29
+ | BMAD Method | 19-agent architecture → skill patterns | 3.7k |
30
+ | SpecKit | 4-phase spec workflow | GitHub Official |
31
+ | Claude-Mem | Session persistence | - |
32
+ | Prompt Coach | Agent analytics | - |
33
+ | Cursor | Rules for AI | Production |
34
+ | Devin | Autonomous workflow | Production |
35
+
36
+ ### Convergent Patterns (Present in 3+ Systems)
37
+
38
+ 1. **Environment Validation Before Changes** — Never code on dirty state
39
+ 2. **Read Before Write** — Explore existing code before implementing
40
+ 3. **Spec-First Development** — Document before code
41
+ 4. **Evidence-Based Quality Gates** — Prove tests pass, don't just claim
42
+ 5. **Session Continuity** — Handoffs preserve context across sessions
43
+ 6. **Ready Work Calculation** — Know what's unblocked before starting
44
+ 7. **Discovered Work Capture** — File new issues immediately, don't forget
45
+ 8. **Convention Following** — Match existing patterns, not preferences
46
+ 9. **Memory Decay Management** — Archive old work, keep context lean
47
+
48
+ ### Architecture Decision: Single Agent + Skills
49
+
50
+ **Why NOT multi-agent:**
51
+ - Coordination overhead exceeds benefits for solo/small teams
52
+ - Context fragmentation across agents
53
+ - Debugging complexity
54
+ - Production systems abandoned multi-agent
55
+
56
+ **Why single agent + skills:**
57
+ - Full context in one agent
58
+ - Skills loaded on-demand (efficient)
59
+ - Simpler debugging
60
+ - Matches production patterns (Cursor, Devin)
61
+
62
+ ### Understanding Coordination Types
63
+
64
+ **What We Removed: Role-Based Agents**
65
+
66
+ Traditional multi-agent systems assign roles: Backend Agent handles database/API, Frontend Agent handles UI/components, etc.
67
+
68
+ Problems with this approach:
69
+ - Overhead deciding "is this backend or frontend?"
70
+ - Artificial boundaries between modules
71
+ - Complexity without proportional value for solo developers
72
+
73
+ **Anvil approach**: Single generalist agent with domain skills loaded on-demand.
74
+
75
+ **What We Kept: Parallel Instance Coordination**
76
+
77
+ When running multiple Claude Code terminals simultaneously, you need:
78
+ - Know what each terminal is working on
79
+ - Prevent two terminals editing the same file
80
+ - Share new API contracts before implementation
81
+ - Record what each session accomplished
82
+
83
+ **This is NOT about agent roles — it's about multiple instances.**
84
+
85
+ Use `.claude/coordination.md` when running multiple terminals:
86
+
87
+ ```markdown
88
+ ## Active Sessions
89
+ | Session ID | Started | Working On | Status |
90
+
91
+ ## Current Work
92
+ | Session ID | Files/Areas | Issue |
93
+
94
+ ## Interface Contracts
95
+ [New APIs posted here before implementation]
96
+
97
+ ## Session Log
98
+ [Append-only activity record]
99
+ ```
100
+
101
+ **When to use coordination.md:**
102
+ - Multiple Claude Code terminals open
103
+ - Pair programming with AI
104
+ - Parallel feature development
105
+
106
+ **When NOT needed:**
107
+ - Single terminal workflow
108
+ - Sequential work sessions
109
+
110
+ ---
111
+
112
+ ## What Anvil Provides
113
+
114
+ ### Pre-Built Components
115
+
116
+ | Category | Count | Purpose |
117
+ |----------|-------|---------|
118
+ | Commands | 14 | Workflow orchestration (/orient, /spec, /plan, etc.) |
119
+ | Templates | 4 | Structured documents (SPEC, PLAN, CHANGE, HANDOFF) |
120
+ | Hooks | 5 | Session lifecycle automation |
121
+ | Quality Gates | 4 | CodeRabbit, Pre-commit, Semgrep, CI |
122
+ | Convention Examples | 5 | Component, hook, API, service, test patterns |
123
+ | Skill Template | 1 | Structure for creating project-specific skills |
124
+
125
+ ### What You Create
126
+
127
+ | Category | Purpose |
128
+ |----------|---------|
129
+ | Skills | Convert your specialized agents into on-demand skills |
130
+ | product.md | Your project's mission, roadmap, success metrics |
131
+ | constitution.md | Non-negotiable principles for your project |
132
+ | Convention examples | Your project's actual patterns |
133
+
134
+ ---
135
+
136
+ ## Installation Paths
137
+
138
+ Choose your path based on your starting point:
139
+
140
+ ### Path A: Fresh Install (No Existing AI Setup)
141
+
142
+ | Phase | Focus | Duration |
143
+ |-------|-------|----------|
144
+ | 0 | Prerequisites & Backup | 30 min |
145
+ | 1 | Global Installation | 30 min |
146
+ | 2 | Project Installation | 1 hour |
147
+ | 3A | Create Your First Skill | 1 hour |
148
+ | 4 | Quality Gates Setup | 1 hour |
149
+ | 5 | Validation & Testing | 30 min |
150
+
151
+ **Total: ~4 hours**
152
+
153
+ ### Path B: Migration (From Multi-Agent System)
154
+
155
+ | Phase | Focus | Duration |
156
+ |-------|-------|----------|
157
+ | 0 | Prerequisites & Backup | 30 min |
158
+ | 1 | Global Installation | 30 min |
159
+ | 2 | Project Installation | 1 hour |
160
+ | 3B | Agent → Skill Conversion | 2-3 hours |
161
+ | 4 | Quality Gates Setup | 1 hour |
162
+ | 5 | Validation & Testing | 1 hour |
163
+
164
+ **Total: 6-8 hours**
165
+
166
+ > **Note**: Phases 0, 1, 2, 4, and 5 are identical for both paths. Only Phase 3 differs.
167
+
168
+ ---
169
+
170
+ ## Phase 0: Backup & Prerequisites
171
+
172
+ ### 0.1 Create Backup
173
+
174
+ ```bash
175
+ BACKUP_DATE=$(date +%Y%m%d_%H%M%S)
176
+ BACKUP_DIR=~/.claude-backups/$BACKUP_DATE
177
+
178
+ mkdir -p $BACKUP_DIR
179
+ cp -r ~/.claude/ $BACKUP_DIR/global-claude/
180
+ cp -r /path/to/your/project/.claude/ $BACKUP_DIR/project-claude/
181
+
182
+ echo "Backup created at: $BACKUP_DIR"
183
+ ```
184
+
185
+ ### 0.2 Verify Prerequisites
186
+
187
+ **Required:**
188
+ ```bash
189
+ # Check Claude Code
190
+ claude --version # Should work
191
+
192
+ # Check Node.js
193
+ node --version # Should be 18+
194
+
195
+ # Check Git
196
+ git --version # Should work
197
+ ```
198
+
199
+ **Quality Gate Tools:**
200
+ ```bash
201
+ # Install if not present
202
+ brew install semgrep trivy gitleaks pre-commit
203
+
204
+ # Verify
205
+ semgrep --version
206
+ trivy --version
207
+ gitleaks version
208
+ pre-commit --version
209
+ ```
210
+
211
+ ### 0.3 Verify Linear Connection
212
+
213
+ **Discover your team name first** (required for commands):
214
+
215
+ ```bash
216
+ # Using Linear CLI (if installed)
217
+ python3 ~/.claude/skills/linear-skill/scripts/linear.py list-teams
218
+
219
+ # Or via Linear MCP (in Claude.ai)
220
+ # Use Linear:list_teams tool
221
+ ```
222
+
223
+ Note your team name (e.g., "MyTeam") — you'll need it for `/tasks` and `/discover` commands.
224
+
225
+ **Verify connection:**
226
+
227
+ For Claude Desktop (MCP):
228
+ - Settings → Connections → Linear should be connected
229
+ - Test: Ask Claude "List my Linear issues"
230
+
231
+ For Claude Code (CLI):
232
+ ```bash
233
+ # Verify API key is set
234
+ echo $LINEAR_API_KEY # Should show key
235
+
236
+ # Test connection
237
+ python3 ~/.claude/skills/linear-skill/scripts/linear.py whoami
238
+ ```
239
+
240
+ ### 0.4 Phase 0 Checklist
241
+
242
+ - [ ] Backup created at `~/.claude-backups/[DATE]/`
243
+ - [ ] Node.js 18+ installed
244
+ - [ ] Semgrep installed
245
+ - [ ] Trivy installed
246
+ - [ ] Gitleaks installed
247
+ - [ ] Pre-commit installed
248
+ - [ ] Linear connection verified
249
+
250
+ ---
251
+
252
+ ## Phase 1: Global Installation
253
+
254
+ Install Anvil components that apply to ALL your projects.
255
+
256
+ ### 1.1 Create Directory Structure
257
+
258
+ ```bash
259
+ # Ensure directories exist
260
+ mkdir -p ~/.claude/{commands,templates,skills,standards,handoffs/archive,analytics}
261
+ ```
262
+
263
+ ### 1.2 Install Commands
264
+
265
+ ```bash
266
+ # From Anvil repo
267
+ ANVIL_REPO=/path/to/anvil-dev-framework
268
+
269
+ # Copy commands (won't overwrite existing)
270
+ cp -n $ANVIL_REPO/global/commands/*.md ~/.claude/commands/
271
+ ```
272
+
273
+ **Commands Installed:**
274
+ | Command | Purpose |
275
+ |---------|---------|
276
+ | `/orient` | Session startup orientation |
277
+ | `/ready` | Calculate unblocked work |
278
+ | `/handoff` | Generate session continuity doc |
279
+ | `/explore` | Discovery before implementation |
280
+ | `/spec` | Generate formal specification |
281
+ | `/plan` | Create implementation plan |
282
+ | `/tasks` | Create Linear issues from plan |
283
+ | `/change` | Brownfield change proposal |
284
+ | `/discover` | File discovered work immediately |
285
+ | `/validate` | Environment validation checkpoint |
286
+ | `/evidence` | Capture quality gate proof |
287
+ | `/shard` | Break large specs into pieces |
288
+ | `/decay-review` | Archive old work |
289
+ | `/weekly-review` | Generate analytics report |
290
+
291
+ ### 1.3 Install Templates
292
+
293
+ ```bash
294
+ cp -n $ANVIL_REPO/global/templates/*.md ~/.claude/templates/
295
+ ```
296
+
297
+ **Templates Installed:**
298
+ - `SPEC-template.md` — Feature specification
299
+ - `PLAN-template.md` — Implementation plan
300
+ - `CHANGE-template.md` — Brownfield change proposal
301
+ - `HANDOFF-template.md` — Session continuity
302
+
303
+ ### 1.4 Install Skills Structure
304
+
305
+ ```bash
306
+ cp -n $ANVIL_REPO/global/skills/README.md ~/.claude/skills/
307
+ cp -rn $ANVIL_REPO/global/skills/skill-template ~/.claude/skills/
308
+ ```
309
+
310
+ ### 1.5 Phase 1 Checklist
311
+
312
+ - [ ] Commands copied to `~/.claude/commands/`
313
+ - [ ] Templates copied to `~/.claude/templates/`
314
+ - [ ] Skills README and template in place
315
+ - [ ] Verify: `ls ~/.claude/commands/*.md | wc -l` shows 14+ commands
316
+
317
+ ---
318
+
319
+ ## Phase 2: Project Installation
320
+
321
+ Install Anvil components specific to your project.
322
+
323
+ ### 2.1 Create Project Directory Structure
324
+
325
+ ```bash
326
+ cd /path/to/your/project
327
+
328
+ mkdir -p .claude/{specs/current,specs/archive,changes,handoffs,examples,skills}
329
+ ```
330
+
331
+ ### 2.2 Install Hooks
332
+
333
+ **If your project already has `.claude/hooks/`:**
334
+ 1. Compare existing hooks with Anvil's defaults
335
+ 2. Keep whichever is more complete
336
+ 3. Anvil hooks are minimal starting points — your custom hooks likely have more functionality
337
+ 4. Merge specific features you want from Anvil into your existing hooks
338
+
339
+ **If no existing hooks:**
340
+ ```bash
341
+ cp -r $ANVIL_REPO/project/hooks/* .claude/hooks/
342
+ chmod +x .claude/hooks/*.py
343
+ ```
344
+
345
+ **TTS (Text-to-Speech) Setup:**
346
+
347
+ Anvil hooks include audio notifications via TTS. On Apple Silicon Macs, install espeak for best quality:
348
+
349
+ ```bash
350
+ brew install espeak
351
+ ```
352
+
353
+ This enables MLX Audio with Kokoro (~300ms latency, natural voice). See [docs/hooks-tts.md](hooks-tts.md) for full TTS configuration options.
354
+
355
+ ### 2.3 Configure Hooks
356
+
357
+ Edit `.claude/settings.local.json`:
358
+
359
+ ```json
360
+ {
361
+ "hooks": {
362
+ "session_start": [".claude/hooks/session_start.py --load-context"],
363
+ "stop": [".claude/hooks/stop.py"],
364
+ "pre_compact": [".claude/hooks/pre_compact.py --backup"],
365
+ "post_tool_use": [".claude/hooks/post_tool_use.py"],
366
+ "subagent_stop": [".claude/hooks/subagent_stop.py"]
367
+ }
368
+ }
369
+ ```
370
+
371
+ ### 2.4 Install Convention Examples
372
+
373
+ ```bash
374
+ cp $ANVIL_REPO/project/examples/*.tsx .claude/examples/
375
+ cp $ANVIL_REPO/project/examples/*.ts .claude/examples/
376
+ ```
377
+
378
+ Then **customize** these to match YOUR project's actual patterns.
379
+
380
+ ### 2.5 Create product.md
381
+
382
+ Create `.claude/product.md`:
383
+
384
+ ```markdown
385
+ # [Your Project Name]
386
+
387
+ ## Mission
388
+ [One sentence describing what this project does and why it matters]
389
+
390
+ ## Core Value Propositions
391
+ 1. [Value 1]
392
+ 2. [Value 2]
393
+ 3. [Value 3]
394
+
395
+ ## Target Users
396
+ - **Primary**: [Who]
397
+ - **Secondary**: [Who]
398
+
399
+ ## Tech Stack
400
+ | Layer | Technology | Rationale |
401
+ |-------|------------|-----------|
402
+ | Frontend | [e.g., Next.js 14] | [Why] |
403
+ | Backend | [e.g., Supabase] | [Why] |
404
+ | Styling | [e.g., Tailwind + shadcn] | [Why] |
405
+
406
+ ## Current Roadmap
407
+ ### Now (This Sprint)
408
+ - [ ] [Current focus]
409
+
410
+ ### Next (Next Sprint)
411
+ - [ ] [Upcoming work]
412
+
413
+ ### Later (Backlog)
414
+ - [ ] [Future considerations]
415
+
416
+ ## Success Metrics
417
+ | Metric | Current | Target |
418
+ |--------|---------|--------|
419
+ | [Metric 1] | [Value] | [Goal] |
420
+
421
+ ## Non-Goals
422
+ - [What this project explicitly does NOT do]
423
+ ```
424
+
425
+ ### 2.6 Create constitution.md
426
+
427
+ Create `.claude/constitution.md`:
428
+
429
+ ```markdown
430
+ # [Project] Constitution
431
+
432
+ > Non-negotiable principles. If Claude's actions would violate these, STOP.
433
+
434
+ ## Security Principles
435
+
436
+ 1. **Never commit secrets** — API keys, passwords, tokens must use environment variables
437
+ 2. **Always authenticate** — Protected routes must verify session
438
+ 3. **Always authorize** — Check permissions before operations
439
+ 4. **Sanitize input** — Never trust user input
440
+ 5. **Use parameterized queries** — No string concatenation in SQL
441
+
442
+ ## Code Quality Principles
443
+
444
+ 1. **Type everything** — No `any`, no implicit types
445
+ 2. **Handle all errors** — No silent failures
446
+ 3. **Test critical paths** — Auth, payments, data mutations
447
+ 4. **No console.log in production** — Use proper logging
448
+ 5. **Keep functions focused** — Single responsibility
449
+
450
+ ## Architecture Principles
451
+
452
+ 1. **Don't duplicate** — Extract shared code
453
+ 2. **Match conventions** — Follow existing patterns
454
+ 3. **Minimize dependencies** — Prefer standard library
455
+ 4. **Document decisions** — Explain non-obvious choices
456
+
457
+ ## Process Principles
458
+
459
+ 1. **Validate before coding** — Run /validate first
460
+ 2. **Spec before building** — Complex features need specs
461
+ 3. **Evidence before PRs** — Prove quality gates pass
462
+ 4. **File discovered work** — Don't forget, file it immediately
463
+ 5. **Handoff before stopping** — Preserve context for next session
464
+ ```
465
+
466
+ ### 2.7 Phase 2 Checklist
467
+
468
+ - [ ] Directory structure created
469
+ - [ ] Hooks installed and configured
470
+ - [ ] Convention examples installed
471
+ - [ ] product.md created with YOUR project details
472
+ - [ ] constitution.md created with YOUR principles
473
+ - [ ] settings.local.json configured for hooks
474
+
475
+ ---
476
+
477
+ ## Phase 3A: Create Your First Skill (Fresh Install)
478
+
479
+ > **Skip to Phase 3B** if you're migrating from a multi-agent system.
480
+
481
+ Skills are domain knowledge loaded on-demand. For a fresh install, start with one skill to understand the pattern.
482
+
483
+ ### 3A.1 Understand Skill Structure
484
+
485
+ ```
486
+ .claude/skills/
487
+ └── my-skill/
488
+ ├── SKILL.md # Overview, triggers, when to use
489
+ ├── conventions.md # Patterns and standards
490
+ ├── references/ # Reference documentation
491
+ └── examples/ # Code examples
492
+ ```
493
+
494
+ ### 3A.2 Create a Simple Skill
495
+
496
+ Create `.claude/skills/testing-patterns/SKILL.md`:
497
+
498
+ ```markdown
499
+ ---
500
+ name: Testing Patterns
501
+ description: Vitest + React Testing Library patterns for this project
502
+ triggers:
503
+ - test
504
+ - spec
505
+ - vitest
506
+ - testing library
507
+ version: 1.0.0
508
+ ---
509
+
510
+ # Testing Patterns
511
+
512
+ ## When to Use
513
+ Load this skill when writing or reviewing tests.
514
+
515
+ ## Test Structure
516
+ [Your project's test conventions]
517
+
518
+ ## Mocking Patterns
519
+ [How you handle mocks]
520
+
521
+ ## Common Assertions
522
+ [Frequently used assertions]
523
+
524
+ ## Checklist
525
+ - [ ] Tests isolated (no shared state)
526
+ - [ ] Descriptive test names
527
+ - [ ] Edge cases covered
528
+ - [ ] Mocks cleaned up
529
+ ```
530
+
531
+ ### 3A.3 Test Skill Loading
532
+
533
+ Ask Claude: "Help me write tests for my user authentication flow"
534
+
535
+ Verify it references your testing-patterns skill.
536
+
537
+ ### 3A.4 Phase 3A Checklist
538
+
539
+ - [ ] First skill created
540
+ - [ ] Skill loads when triggered
541
+ - [ ] Understand pattern for future skills
542
+
543
+ ---
544
+
545
+ ## Phase 3B: Agent → Skill Conversion (Migration)
546
+
547
+ > **Skip to Phase 4** if you did Phase 3A (fresh install).
548
+
549
+ Convert your specialized agents into on-demand skills.
550
+
551
+ ### 3B.1 Why Convert?
552
+
553
+ | Agents (Old) | Skills (New) |
554
+ |--------------|--------------|
555
+ | Always in context | Loaded on-demand |
556
+ | Fixed prompts | Flexible activation |
557
+ | Coordination overhead | Direct execution |
558
+ | Context fragmentation | Full context available |
559
+
560
+ ### 3B.2 Conversion Process
561
+
562
+ For each agent (Backend, Frontend, Core, Infra, etc.):
563
+
564
+ **Step 1: Identify Core Knowledge**
565
+ - What domain expertise does this agent have?
566
+ - What patterns/conventions does it enforce?
567
+ - What decisions does it make?
568
+
569
+ **Step 2: Extract into Skill**
570
+
571
+ Create `.claude/skills/[domain]-patterns/SKILL.md`:
572
+
573
+ ```markdown
574
+ ---
575
+ name: [Domain] Patterns
576
+ description: [What this skill provides]
577
+ triggers:
578
+ - [keyword1]
579
+ - [keyword2]
580
+ version: 1.0.0
581
+ ---
582
+
583
+ # [Domain] Patterns
584
+
585
+ ## When to Use
586
+ [When Claude should load this skill]
587
+
588
+ ## Key Concepts
589
+ [Domain knowledge extracted from agent]
590
+
591
+ ## Patterns
592
+ [Specific patterns the agent enforced]
593
+
594
+ ## Decision Framework
595
+ [How to make decisions in this domain]
596
+
597
+ ## Anti-Patterns
598
+ [What the agent avoided]
599
+
600
+ ## Checklist
601
+ [Verification steps from agent]
602
+ ```
603
+
604
+ **Step 3: Move Reference Files**
605
+
606
+ If your agent referenced specific files, move them to the skill:
607
+
608
+ ```
609
+ .claude/skills/backend-patterns/
610
+ ├── SKILL.md
611
+ ├── examples/
612
+ │ ├── api-route.ts
613
+ │ └── service.ts
614
+ └── references/
615
+ └── security-checklist.md
616
+ ```
617
+
618
+ ### 3B.3 Example: Backend Agent → Skill
619
+
620
+ **Before (Agent):**
621
+ ```markdown
622
+ # Backend Agent
623
+ You are a senior backend engineer...
624
+ Always check authentication...
625
+ Use parameterized queries...
626
+ ```
627
+
628
+ **After (Skill):**
629
+ ```markdown
630
+ ---
631
+ name: Backend Security Patterns
632
+ triggers: [api, route, database, auth, security]
633
+ ---
634
+
635
+ # Backend Security Patterns
636
+
637
+ ## Authentication Patterns
638
+ - Verify session at route entry
639
+ - Use httpOnly cookies
640
+ - Implement CSRF protection
641
+
642
+ ## Database Patterns
643
+ - Parameterized queries only
644
+ - Row Level Security enabled
645
+ - Connection pooling
646
+
647
+ ## API Design
648
+ - RESTful conventions
649
+ - Consistent error responses
650
+ - Rate limiting on sensitive endpoints
651
+
652
+ ## Checklist
653
+ - [ ] Auth check at route entry
654
+ - [ ] Input validation complete
655
+ - [ ] Error handling in place
656
+ - [ ] Audit logging for mutations
657
+ ```
658
+
659
+ ### 3B.4 Conversion Checklist
660
+
661
+ - [ ] Backend agent → backend-patterns skill
662
+ - [ ] Frontend agent → frontend-patterns skill
663
+ - [ ] Core agent → utility-patterns skill
664
+ - [ ] Infra agent → devops-patterns skill
665
+ - [ ] Original agents archived (not deleted)
666
+ - [ ] Skills tested with sample queries
667
+
668
+ ---
669
+
670
+ ## Phase 4: Quality Gates Setup
671
+
672
+ ### 4.1 Install CodeRabbit
673
+
674
+ Create `.coderabbit.yaml` in project root:
675
+
676
+ ```bash
677
+ cp $ANVIL_REPO/quality-gates/.coderabbit.yaml .
678
+ ```
679
+
680
+ Customize path instructions for your project structure.
681
+
682
+ ### 4.2 Install Pre-commit
683
+
684
+ Create `.pre-commit-config.yaml`:
685
+
686
+ ```bash
687
+ cp $ANVIL_REPO/quality-gates/.pre-commit-config.yaml .
688
+ pre-commit install
689
+ ```
690
+
691
+ > **Note on JSON Check**: The `check-json` pre-commit hook will fail on TypeScript config files (tsconfig.json) because they use JSONC (JSON with Comments). This is expected. The Anvil config excludes these files:
692
+ > ```yaml
693
+ > - id: check-json
694
+ > exclude: '(tsconfig.*\.json$|COPY_.*\.json$)'
695
+ > ```
696
+
697
+ ### 4.3 Install Semgrep Rules
698
+
699
+ ```bash
700
+ mkdir -p .semgrep/rules
701
+ cp $ANVIL_REPO/quality-gates/.semgrep/rules/*.yaml .semgrep/rules/
702
+ ```
703
+
704
+ ### 4.4 Install CI Pipeline
705
+
706
+ ```bash
707
+ mkdir -p .github/workflows
708
+ cp $ANVIL_REPO/quality-gates/.github/workflows/ci.yaml .github/workflows/
709
+ ```
710
+
711
+ Customize for your project's test commands.
712
+
713
+ ### 4.5 Phase 4 Checklist
714
+
715
+ - [ ] CodeRabbit configured
716
+ - [ ] Pre-commit hooks installed
717
+ - [ ] Semgrep rules in place
718
+ - [ ] CI pipeline configured
719
+ - [ ] Test: `pre-commit run --all-files`
720
+
721
+ ---
722
+
723
+ ## Phase 5: Validation & Testing
724
+
725
+ ### 5.0 Quick Validation
726
+
727
+ Run these commands to verify installation:
728
+
729
+ ```bash
730
+ # Global commands (should be 14+)
731
+ ls ~/.claude/commands/*.md | wc -l
732
+
733
+ # Templates (should be 4)
734
+ ls ~/.claude/templates/*-template.md | wc -l
735
+
736
+ # Project structure
737
+ ls .claude/{specs,changes,handoffs,examples,skills}
738
+
739
+ # Quality gates
740
+ pre-commit run --all-files
741
+
742
+ # Linear CLI
743
+ python3 ~/.claude/skills/linear-skill/scripts/linear.py whoami
744
+ ```
745
+
746
+ If any fail, check the relevant phase above.
747
+
748
+ ### 5.1 Test Session Workflow
749
+
750
+ 1. Start new Claude Code session
751
+ 2. Run `/orient` — Should show git state, ready work
752
+ 3. Pick a task from ready work
753
+ 4. Run `/validate` — Should pass all checks
754
+ 5. Run `/explore` — Should analyze related code
755
+ 6. Create small change
756
+ 7. Run `/evidence` — Should capture quality proof
757
+ 8. Run `/handoff` — Should generate continuity doc
758
+
759
+ ### 5.2 Test Skill Loading
760
+
761
+ 1. Ask Claude about a backend security question
762
+ 2. Verify it references backend-patterns skill
763
+ 3. Ask about frontend component structure
764
+ 4. Verify it references frontend-patterns skill
765
+
766
+ ### 5.3 Test Quality Gates
767
+
768
+ ```bash
769
+ # Pre-commit
770
+ pre-commit run --all-files
771
+
772
+ # Semgrep
773
+ semgrep --config .semgrep/rules/
774
+
775
+ # Full CI (if GitHub Actions)
776
+ # Push to branch and verify pipeline runs
777
+ ```
778
+
779
+ ### 5.4 Validate Linear Integration
780
+
781
+ 1. Run `/tasks` on a simple plan
782
+ 2. Verify issues created with correct:
783
+ - Labels
784
+ - Priority
785
+ - Dependencies (blocked-by)
786
+ - Description format
787
+
788
+ ### 5.5 Phase 5 Checklist
789
+
790
+ - [ ] /orient works correctly
791
+ - [ ] /validate passes
792
+ - [ ] /explore reads files properly
793
+ - [ ] /evidence captures output
794
+ - [ ] /handoff generates document
795
+ - [ ] Skills load on relevant queries
796
+ - [ ] Pre-commit hooks work
797
+ - [ ] Linear integration works
798
+
799
+ ---
800
+
801
+ ## Post-Installation: Daily Workflow
802
+
803
+ ### Session Start
804
+ ```
805
+ /orient
806
+ ```
807
+ → See git state, ready work, handoff context
808
+
809
+ ### Before Any Code
810
+ ```
811
+ /validate
812
+ ```
813
+ → Ensure clean environment
814
+
815
+ ### New Feature
816
+ ```
817
+ /explore → /spec → /plan → /tasks → implement → /evidence
818
+ ```
819
+
820
+ ### Brownfield Change
821
+ ```
822
+ /explore → /change → /plan → /tasks → implement → /evidence
823
+ ```
824
+
825
+ ### Discovered Work
826
+ ```
827
+ /discover "Brief description of what was found"
828
+ ```
829
+ → Creates Linear issue, continue original task
830
+
831
+ ### Session End
832
+ ```
833
+ /handoff
834
+ ```
835
+ → Preserves context for next session
836
+
837
+ ### Weekly Maintenance
838
+ ```
839
+ /weekly-review
840
+ /decay-review
841
+ ```
842
+ → Analytics and archive cleanup
843
+
844
+ ---
845
+
846
+ ## Troubleshooting
847
+
848
+ ### Commands Not Found
849
+ Verify commands are in `~/.claude/commands/`:
850
+ ```bash
851
+ ls ~/.claude/commands/*.md
852
+ ```
853
+
854
+ ### Hooks Not Running
855
+ Check `.claude/settings.local.json` syntax and paths.
856
+
857
+ ### Skills Not Loading
858
+ Verify skill triggers match your queries. Add more trigger keywords.
859
+
860
+ ### Linear Issues Not Creating
861
+ Check Linear MCP connection or API key. Test with simple query first.
862
+
863
+ ### Pre-commit Failing
864
+ Run `pre-commit run --all-files` to see specific failures.
865
+
866
+ ---
867
+
868
+ ## File Structure Reference
869
+
870
+ ### Global (~/.claude/)
871
+ ```
872
+ ~/.claude/
873
+ ├── commands/ # 14 Anvil commands
874
+ │ ├── orient.md
875
+ │ ├── ready.md
876
+ │ ├── handoff.md
877
+ │ ├── explore.md
878
+ │ ├── spec.md
879
+ │ ├── plan.md
880
+ │ ├── tasks.md
881
+ │ ├── change.md
882
+ │ ├── discover.md
883
+ │ ├── validate.md
884
+ │ ├── evidence.md
885
+ │ ├── shard.md
886
+ │ ├── decay-review.md
887
+ │ └── weekly-review.md
888
+ ├── templates/ # 4 document templates
889
+ │ ├── SPEC-template.md
890
+ │ ├── PLAN-template.md
891
+ │ ├── CHANGE-template.md
892
+ │ └── HANDOFF-template.md
893
+ ├── skills/
894
+ │ ├── README.md
895
+ │ └── skill-template/
896
+ └── handoffs/
897
+ └── archive/
898
+ ```
899
+
900
+ ### Project (.claude/)
901
+ ```
902
+ .claude/
903
+ ├── product.md # Mission, roadmap, metrics
904
+ ├── constitution.md # Non-negotiable principles
905
+ ├── settings.local.json # Hook configuration
906
+ ├── hooks/ # Session lifecycle
907
+ │ ├── session_start.py
908
+ │ ├── stop.py
909
+ │ ├── pre_compact.py
910
+ │ ├── post_tool_use.py
911
+ │ └── subagent_stop.py
912
+ ├── skills/ # Project-specific skills
913
+ │ ├── backend-patterns/
914
+ │ ├── frontend-patterns/
915
+ │ └── ...
916
+ ├── examples/ # Convention files
917
+ │ ├── component-template.tsx
918
+ │ ├── hook-template.ts
919
+ │ └── ...
920
+ ├── specs/
921
+ │ ├── current/ # Active specs
922
+ │ └── archive/ # Completed specs
923
+ ├── changes/ # Change proposals
924
+ └── handoffs/ # Session handoffs
925
+ ```
926
+
927
+ ### Project Root
928
+ ```
929
+ project/
930
+ ├── .coderabbit.yaml # CodeRabbit config
931
+ ├── .pre-commit-config.yaml
932
+ ├── .semgrep/
933
+ │ └── rules/
934
+ └── .github/
935
+ └── workflows/
936
+ └── ci.yaml
937
+ ```
938
+
939
+ ---
940
+
941
+ ## Success Criteria
942
+
943
+ After installation, you should be able to:
944
+
945
+ 1. ✅ Start sessions with full context via `/orient`
946
+ 2. ✅ Validate environment before changes via `/validate`
947
+ 3. ✅ Follow spec-driven workflow for new features
948
+ 4. ✅ Capture discovered work without losing focus
949
+ 5. ✅ Preserve context across sessions via `/handoff`
950
+ 6. ✅ Load domain skills on-demand
951
+ 7. ✅ Pass quality gates before PR creation
952
+ 8. ✅ Track work in Linear with proper structure
953
+
954
+ ---
955
+
956
+ ## Appendix: Pattern Reference
957
+
958
+ ### Droid Patterns (Factory)
959
+ 1. Environment validation before changes
960
+ 2. Read before write
961
+ 3. Living task management
962
+ 4. Evidence-based PR gates
963
+ 5. Convention following
964
+ 6. Multi-stage verification
965
+
966
+ ### Beads Patterns
967
+ 1. Ready work calculation
968
+ 2. Discovered-from linking
969
+ 3. Session handoffs
970
+ 4. Memory decay
971
+ 5. Quick orientation
972
+
973
+ ### Spec-Driven Patterns (BMAD/SpecKit)
974
+ 1. Explore → Spec → Plan → Tasks
975
+ 2. Document sharding for large specs
976
+ 3. Phase gates between stages
977
+ 4. Gherkin acceptance criteria
978
+ 5. Brownfield change proposals
979
+
980
+ ### Memory Patterns
981
+ 1. 5-layer memory hierarchy
982
+ 2. Handoff continuity
983
+ 3. Decay management
984
+ 4. Context-aware loading