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,810 @@
1
+ # Anvil Implementation Guide
2
+
3
+ > Complete step-by-step guide to implementing the Anvil Development Framework.
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [Overview](#1-overview)
10
+ 2. [Prerequisites](#2-prerequisites)
11
+ 3. [Phase 0: Preparation](#3-phase-0-preparation)
12
+ 4. [Phase 1: Foundation Layer](#4-phase-1-foundation-layer)
13
+ 5. [Phase 2: Memory & Continuity](#5-phase-2-memory--continuity)
14
+ 6. [Phase 3: Spec-Driven Workflow](#6-phase-3-spec-driven-workflow)
15
+ 7. [Phase 4: Quality Gates](#7-phase-4-quality-gates)
16
+ 8. [Phase 5: Feedback Loops](#8-phase-5-feedback-loops)
17
+ 9. [Phase 6: Optimization](#9-phase-6-optimization)
18
+ 10. [Troubleshooting](#10-troubleshooting)
19
+
20
+ ---
21
+
22
+ ## 1. Overview
23
+
24
+ ### Implementation Timeline
25
+
26
+ | Phase | Focus | Duration | Effort |
27
+ |-------|-------|----------|--------|
28
+ | 0 | Preparation | 1 day | 2-3 hours |
29
+ | 1 | Foundation | 1 week | 8-10 hours |
30
+ | 2 | Memory & Continuity | 1 week | 6-8 hours |
31
+ | 3 | Spec-Driven Workflow | 1 week | 10-12 hours |
32
+ | 4 | Quality Gates | 1 week | 4-6 hours |
33
+ | 5 | Feedback Loops | 1 week | 4-6 hours |
34
+ | 6 | Optimization | Ongoing | 2-3 hours/week |
35
+
36
+ **Total Initial Investment**: 35-45 hours over 6 weeks
37
+
38
+ ### Guiding Principles
39
+
40
+ 1. **Incremental Value**: Each phase delivers standalone value
41
+ 2. **Backward Compatible**: Existing workflows continue working
42
+ 3. **Measurable Progress**: Clear success criteria per phase
43
+ 4. **Reversible Changes**: Can roll back any phase
44
+ 5. **Documentation-First**: Write docs/templates, then implement
45
+
46
+ ---
47
+
48
+ ## 2. Prerequisites
49
+
50
+ ### Required Tools
51
+
52
+ | Tool | Purpose | Installation |
53
+ |------|---------|--------------|
54
+ | Claude Code | AI coding assistant | Anthropic subscription |
55
+ | Node.js 18+ | Runtime | `brew install node` |
56
+ | Git | Version control | Pre-installed on macOS |
57
+ | Linear | Task management | linear.app account |
58
+
59
+ ### Quality Gate Tools
60
+
61
+ | Tool | Purpose | Installation |
62
+ |------|---------|--------------|
63
+ | Semgrep | SAST scanning | `brew install semgrep` |
64
+ | Trivy | Vulnerability scanning | `brew install trivy` |
65
+ | Gitleaks | Secrets detection | `brew install gitleaks` |
66
+ | Pre-commit | Git hooks | `brew install pre-commit` |
67
+
68
+ ### Optional Tools
69
+
70
+ | Tool | Purpose | Cost |
71
+ |------|---------|------|
72
+ | CodeRabbit | AI code review | $25/mo |
73
+ | Claude-Mem | Session memory | Free (plugin) |
74
+ | Prompt Coach | Analytics | Free (skill) |
75
+
76
+ ---
77
+
78
+ ## 3. Phase 0: Preparation
79
+
80
+ **Objective**: Create safe environment, install prerequisites, create backup.
81
+
82
+ ### 3.1 Backup Existing Configuration
83
+
84
+ ```bash
85
+ BACKUP_DATE=$(date +%Y%m%d_%H%M%S)
86
+ BACKUP_DIR=~/.claude-backups/$BACKUP_DATE
87
+
88
+ mkdir -p $BACKUP_DIR
89
+ cp -r ~/.claude/ $BACKUP_DIR/global-claude/
90
+ cp -r /path/to/project/.claude/ $BACKUP_DIR/project-claude/
91
+
92
+ echo "Backup created at: $BACKUP_DIR"
93
+ ```
94
+
95
+ ### 3.2 Install Prerequisites
96
+
97
+ ```bash
98
+ # Quality gate tools
99
+ brew install semgrep trivy gitleaks pre-commit
100
+
101
+ # Verify installations
102
+ semgrep --version
103
+ trivy --version
104
+ gitleaks version
105
+ pre-commit --version
106
+ ```
107
+
108
+ ### 3.3 Create Implementation Branch
109
+
110
+ ```bash
111
+ cd /path/to/your/project
112
+ git stash # if needed
113
+ git checkout -b feature/anvil-implementation
114
+ git push -u origin feature/anvil-implementation
115
+ ```
116
+
117
+ ### 3.4 Verify Linear Connection
118
+
119
+ For Claude Desktop (MCP):
120
+ - Check Claude settings for Linear MCP connection
121
+ - Test: "List my Linear issues"
122
+
123
+ For Claude Code (CLI skill):
124
+ - Ensure `LINEAR_API_KEY` is set in `~/.zshenv`
125
+ - Test: `python3 .claude/skills/linear-skill/scripts/linear.py whoami`
126
+
127
+ ### 3.5 Phase 0 Checklist
128
+
129
+ - [ ] Backup created at `~/.claude-backups/[DATE]/`
130
+ - [ ] Semgrep installed and working
131
+ - [ ] Trivy installed and working
132
+ - [ ] Gitleaks installed and working
133
+ - [ ] Pre-commit installed and working
134
+ - [ ] Implementation branch created
135
+ - [ ] Linear connection verified
136
+
137
+ ---
138
+
139
+ ## 4. Phase 1: Foundation Layer
140
+
141
+ **Objective**: Establish directory structure, core documentation, and basic commands.
142
+
143
+ ### 4.1 Global Directory Structure
144
+
145
+ Create in `~/.claude/`:
146
+
147
+ ```bash
148
+ mkdir -p ~/.claude/{standards,templates,commands,skills,handoffs,analytics}
149
+ ```
150
+
151
+ Final structure:
152
+ ```
153
+ ~/.claude/
154
+ ├── CLAUDE.md # Personal defaults
155
+ ├── standards/ # Universal coding standards
156
+ ├── templates/ # Reusable spec templates
157
+ ├── commands/ # Global slash commands
158
+ ├── skills/ # Claude Code skills
159
+ ├── handoffs/ # Session handoff archive
160
+ │ └── archive/
161
+ └── analytics/ # Metrics and reports
162
+ ```
163
+
164
+ ### 4.2 Project Directory Structure
165
+
166
+ Create in your project's `.claude/`:
167
+
168
+ ```bash
169
+ mkdir -p .claude/{specs/{current,archive},changes,handoffs,examples}
170
+ ```
171
+
172
+ Final structure:
173
+ ```
174
+ .claude/
175
+ ├── CLAUDE.md # Project context
176
+ ├── constitution.md # Non-negotiable principles
177
+ ├── product.md # Mission & roadmap
178
+ ├── specs/
179
+ │ ├── current/ # Active specs
180
+ │ └── archive/ # Completed specs
181
+ ├── changes/ # Brownfield proposals
182
+ ├── handoffs/ # Project handoffs
183
+ ├── examples/ # Convention examples
184
+ └── commands/ # Project commands
185
+ ```
186
+
187
+ ### 4.3 Core Documentation Files
188
+
189
+ #### 4.3.1 Project CLAUDE.md
190
+
191
+ See `project/CLAUDE.md.template` for the full template. Key sections:
192
+
193
+ - Project Overview
194
+ - Tech Stack
195
+ - Agent Approach (startup, validation, implementation)
196
+ - Slash Commands reference
197
+ - Linear Workflow
198
+ - File Conventions
199
+ - Error Handling Pattern
200
+ - Key Files Reference
201
+
202
+ #### 4.3.2 Constitution
203
+
204
+ See `project/constitution.md.template`. Must include:
205
+
206
+ - Security Principles (5)
207
+ - Code Quality Principles (5)
208
+ - Architecture Principles (4)
209
+ - Process Principles (5)
210
+ - What We Will NOT Do
211
+
212
+ #### 4.3.3 Product Definition
213
+
214
+ See `project/product.md.template`. Must include:
215
+
216
+ - Mission statement
217
+ - Core Value Propositions
218
+ - Target Users
219
+ - Tech Stack Rationale
220
+ - Current Roadmap
221
+ - Success Metrics
222
+
223
+ ### 4.4 Basic Commands
224
+
225
+ #### /validate Command
226
+
227
+ Purpose: Environment validation checkpoint before any code changes.
228
+
229
+ Steps:
230
+ 1. Check git status (must be clean)
231
+ 2. Check branch (must not be main)
232
+ 3. Run `npm ci` (dependencies)
233
+ 4. Run `npm test` (baseline)
234
+ 5. Run `npm run typecheck` (types)
235
+
236
+ If ANY step fails → STOP and report.
237
+
238
+ #### /evidence Command
239
+
240
+ Purpose: Capture quality gate proof before creating PR.
241
+
242
+ Steps:
243
+ 1. Run lint, capture full output
244
+ 2. Run typecheck, capture full output
245
+ 3. Run tests, capture full output
246
+ 4. Run git status, list changed files
247
+
248
+ Include evidence block in PR description.
249
+
250
+ ### 4.5 Convention Examples
251
+
252
+ Create example files in `.claude/examples/`:
253
+
254
+ - `component.tsx` — React component patterns
255
+ - `api-route.ts` — API route patterns
256
+ - `hook.ts` — Custom hook patterns
257
+ - `test.test.ts` — Test patterns
258
+
259
+ ### 4.6 Phase 1 Checklist
260
+
261
+ - [ ] Global directory structure created
262
+ - [ ] Project directory structure created
263
+ - [ ] CLAUDE.md (v5) created
264
+ - [ ] constitution.md created
265
+ - [ ] product.md created
266
+ - [ ] /validate command created
267
+ - [ ] /evidence command created
268
+ - [ ] Convention examples created
269
+ - [ ] All changes committed
270
+
271
+ ---
272
+
273
+ ## 5. Phase 2: Memory & Continuity
274
+
275
+ **Objective**: Install session memory, handoff system, and orientation protocols.
276
+
277
+ ### 5.1 Claude-Mem Installation
278
+
279
+ ```bash
280
+ # If available via Claude Code marketplace
281
+ # OR manual installation:
282
+ cd ~/.claude/tools
283
+ git clone https://github.com/thedotmack/claude-mem.git
284
+ cd claude-mem && npm install && npm run init
285
+ ```
286
+
287
+ ### 5.2 Handoff System
288
+
289
+ #### /handoff Command
290
+
291
+ Purpose: Generate session continuity document.
292
+
293
+ Output structure:
294
+ ```markdown
295
+ ---
296
+ session_date: YYYY-MM-DD
297
+ session_time: HH:MM - HH:MM
298
+ branch: [branch name]
299
+ ---
300
+
301
+ # Session Handoff: [Date]
302
+
303
+ ## Session Summary
304
+ ## Completed This Session
305
+ ## In Progress
306
+ ## Discovered Work Filed
307
+ ## Recommended Next Task
308
+ ## Critical Context for Next Session
309
+ ## Environment State
310
+ ## Files Modified This Session
311
+ ```
312
+
313
+ Save to: `.claude/handoffs/[YYYY-MM-DD]-[topic].md`
314
+
315
+ #### /orient Command
316
+
317
+ Purpose: Session startup orientation.
318
+
319
+ Steps:
320
+ 1. Check for recent handoff (< 48 hours)
321
+ 2. Check git state
322
+ 3. Query Linear for ready work
323
+ 4. Calculate ready work (no blockers)
324
+ 5. Present options, await direction
325
+
326
+ #### /ready Command
327
+
328
+ Purpose: Calculate ready work from Linear.
329
+
330
+ Algorithm:
331
+ 1. Fetch all active issues
332
+ 2. Filter issues where all blockers are Done
333
+ 3. Sort by priority (P0 first), then age (oldest first)
334
+ 4. Present ready work list
335
+
336
+ ### 5.3 Memory Decay Protocol
337
+
338
+ #### /decay-review Command
339
+
340
+ Purpose: Weekly maintenance to archive old work.
341
+
342
+ Steps:
343
+ 1. Find issues: status=Done, completed >30 days ago
344
+ 2. Add archive summary comment
345
+ 3. Archive the issue
346
+ 4. Clean handoff directory (keep last 7)
347
+
348
+ Target metrics:
349
+ - Active issues: < 50
350
+ - Active handoffs: ≤ 7
351
+
352
+ ### 5.4 Phase 2 Checklist
353
+
354
+ - [ ] Claude-Mem installed (optional)
355
+ - [ ] /handoff command created
356
+ - [ ] /orient command created
357
+ - [ ] /ready command created
358
+ - [ ] /decay-review command created
359
+ - [ ] Handoff template tested
360
+ - [ ] Orientation workflow tested
361
+
362
+ ---
363
+
364
+ ## 6. Phase 3: Spec-Driven Workflow
365
+
366
+ **Objective**: Implement phase gates, document sharding, brownfield changes.
367
+
368
+ ### 6.1 Phase Gate Commands
369
+
370
+ #### /explore Command
371
+
372
+ Purpose: Discovery phase before any new feature.
373
+
374
+ Steps:
375
+ 1. Clarify request with user
376
+ 2. Search for existing related code
377
+ 3. Read related files, note patterns
378
+ 4. Check existing specs
379
+ 5. Review architecture constraints
380
+
381
+ Output: Exploration Report with recommendations
382
+
383
+ **Gate**: Wait for user confirmation before /spec
384
+
385
+ #### /spec Command
386
+
387
+ Purpose: Generate formal specification.
388
+
389
+ Output structure:
390
+ ```markdown
391
+ ---
392
+ spec_id: SPEC-YYYYMMDD-XXX
393
+ title: [Title]
394
+ status: draft | review | approved | implemented | archived
395
+ ---
396
+
397
+ # [Feature Title]
398
+
399
+ ## Overview
400
+ ## Requirements (Functional & Non-Functional)
401
+ ## User Scenarios (Gherkin format)
402
+ ## Technical Considerations
403
+ ## Out of Scope
404
+ ## Open Questions
405
+ ```
406
+
407
+ **Gate**: All open questions must be answered, status must be 'approved'
408
+
409
+ #### /plan Command
410
+
411
+ Purpose: Create implementation plan from approved spec.
412
+
413
+ Output structure:
414
+ ```markdown
415
+ ---
416
+ plan_id: PLAN-YYYYMMDD-XXX
417
+ spec_id: [reference]
418
+ estimated_hours: X
419
+ ---
420
+
421
+ ## Approach
422
+ ## Implementation Phases
423
+ ## File Changes
424
+ ## Testing Strategy
425
+ ## Risks and Mitigations
426
+ ## Rollback Plan
427
+ ```
428
+
429
+ **Gate**: Plan must be approved before /tasks
430
+
431
+ #### /tasks Command
432
+
433
+ Purpose: Create Linear issues from approved plan.
434
+
435
+ Rules:
436
+ - Each task completable in 1-4 hours
437
+ - Each task has clear acceptance criteria
438
+ - Each task independently verifiable
439
+ - Set dependencies (blocked by)
440
+
441
+ ### 6.2 Document Sharding
442
+
443
+ #### /shard Command
444
+
445
+ Purpose: Break large specs (>2000 tokens) into atomic pieces.
446
+
447
+ Strategy:
448
+ ```
449
+ .claude/specs/current/
450
+ ├── SPEC-001-user-auth.md # Master spec
451
+ ├── SPEC-001-user-auth/
452
+ │ ├── epic-001-registration.md # Shard 1
453
+ │ ├── epic-002-login.md # Shard 2
454
+ │ └── epic-003-password-reset.md # Shard 3
455
+ ```
456
+
457
+ Benefits:
458
+ - ~80% token savings per task
459
+ - Load only what's needed
460
+
461
+ ### 6.3 Brownfield Change Tracking
462
+
463
+ #### /change Command
464
+
465
+ Purpose: Create change proposal for modifying existing features.
466
+
467
+ Output structure:
468
+ ```markdown
469
+ ---
470
+ change_id: CHANGE-YYYYMMDD-XXX
471
+ affects_specs: [list]
472
+ ---
473
+
474
+ ## Summary
475
+ ## Motivation
476
+ ## Proposed Changes
477
+ - MODIFIED: [requirement]
478
+ - ADDED: [requirement]
479
+ - REMOVED: [requirement]
480
+ ## Impact Analysis
481
+ ## Migration Required
482
+ ## Rollback Plan
483
+ ```
484
+
485
+ ### 6.4 Discovery Pattern
486
+
487
+ #### /discover Command
488
+
489
+ Purpose: File discovered work during implementation.
490
+
491
+ Usage: `/discover [title]`
492
+
493
+ Creates Linear issue with:
494
+ - Parent issue reference
495
+ - Discovery context
496
+ - Recommended priority
497
+ - `discovered` label
498
+
499
+ ### 6.5 Gherkin Scenarios
500
+
501
+ Use GIVEN/WHEN/THEN format for all acceptance criteria:
502
+
503
+ ```gherkin
504
+ #### Scenario: Successful user login
505
+
506
+ **Context**:
507
+ - **GIVEN** a registered user with email "user@example.com"
508
+ - **AND** the user has valid password
509
+
510
+ **Action**:
511
+ - **WHEN** the user submits login form with correct credentials
512
+
513
+ **Outcome**:
514
+ - **THEN** a new session is created
515
+ - **AND** user is redirected to dashboard
516
+ ```
517
+
518
+ ### 6.6 Phase 3 Checklist
519
+
520
+ - [ ] /explore command created
521
+ - [ ] /spec command created
522
+ - [ ] /plan command created
523
+ - [ ] /tasks command created
524
+ - [ ] /shard command created
525
+ - [ ] /change command created
526
+ - [ ] /discover command created
527
+ - [ ] Gherkin scenario template created
528
+ - [ ] Full workflow tested (explore → spec → plan → tasks)
529
+
530
+ ---
531
+
532
+ ## 7. Phase 4: Quality Gates
533
+
534
+ **Objective**: Configure automated quality gates and CI pipeline.
535
+
536
+ ### 7.1 CodeRabbit Configuration
537
+
538
+ Create `.coderabbit.yaml`:
539
+
540
+ ```yaml
541
+ reviews:
542
+ auto_review:
543
+ enabled: true
544
+ drafts: false
545
+ profile: assertive
546
+ path_instructions:
547
+ - path: "src/app/api/**"
548
+ instructions: |
549
+ Review for: input validation, auth checks, error handling,
550
+ rate limiting, response consistency, SQL injection prevention
551
+ - path: "src/components/**"
552
+ instructions: |
553
+ Review for: accessibility, performance, type safety,
554
+ error boundaries, loading/error states
555
+ ```
556
+
557
+ ### 7.2 Semgrep Configuration
558
+
559
+ Create `.semgrep.yaml` and custom rules in `.semgrep/rules/`:
560
+
561
+ Key rules:
562
+ - `api-route-missing-auth` — Detect routes without auth checks
563
+ - `no-console-log` — Remove console.log before production
564
+ - `no-any-type` — Avoid `any` type usage
565
+ - `unhandled-promise` — Detect unhandled promise rejections
566
+ - `hardcoded-secret` — Detect potential secrets
567
+
568
+ ### 7.3 Pre-commit Configuration
569
+
570
+ Create `.pre-commit-config.yaml`:
571
+
572
+ ```yaml
573
+ repos:
574
+ - repo: local
575
+ hooks:
576
+ - id: lint
577
+ name: ESLint
578
+ entry: npm run lint
579
+ language: system
580
+ pass_filenames: false
581
+ - id: typecheck
582
+ name: TypeScript Check
583
+ entry: npm run typecheck
584
+ language: system
585
+ pass_filenames: false
586
+ - repo: https://github.com/gitleaks/gitleaks
587
+ rev: v8.18.0
588
+ hooks:
589
+ - id: gitleaks
590
+ ```
591
+
592
+ Install hooks:
593
+ ```bash
594
+ pre-commit install
595
+ ```
596
+
597
+ ### 7.4 GitHub Actions CI
598
+
599
+ Create `.github/workflows/ci.yaml` with jobs:
600
+ - `lint-and-type` — ESLint + TypeScript
601
+ - `test` — Run tests with coverage
602
+ - `security` — Semgrep + Trivy + Gitleaks
603
+ - `build` — Verify build succeeds
604
+
605
+ ### 7.5 Phase 4 Checklist
606
+
607
+ - [ ] CodeRabbit configuration created
608
+ - [ ] Semgrep configuration and rules created
609
+ - [ ] Pre-commit configuration created
610
+ - [ ] Pre-commit hooks installed
611
+ - [ ] GitHub Actions CI workflow created
612
+ - [ ] All quality gates tested
613
+
614
+ ---
615
+
616
+ ## 8. Phase 5: Feedback Loops
617
+
618
+ **Objective**: Install analytics and establish continuous improvement.
619
+
620
+ ### 8.1 Prompt Coach Installation
621
+
622
+ ```bash
623
+ cd ~/.claude/skills
624
+ git clone https://github.com/hancengiz/claude-code-prompt-coach-skill.git prompt-coach
625
+ ```
626
+
627
+ ### 8.2 Analytics Dashboard
628
+
629
+ Create `~/.claude/analytics/` structure:
630
+ ```
631
+ analytics/
632
+ ├── weekly/ # Weekly reports
633
+ ├── monthly/ # Monthly summaries
634
+ ├── prompts/ # Prompt improvements
635
+ └── metrics.json # Raw metrics
636
+ ```
637
+
638
+ ### 8.3 Weekly Review Process
639
+
640
+ #### /weekly-review Command
641
+
642
+ Steps:
643
+ 1. Run Prompt Coach analysis
644
+ 2. Gather metrics from Linear, GitHub, CodeRabbit
645
+ 3. Generate weekly report
646
+ 4. Apply improvements to CLAUDE.md
647
+ 5. Document learnings
648
+
649
+ ### 8.4 Improvement Documentation
650
+
651
+ Track in `~/.claude/analytics/prompts/improvements.md`:
652
+
653
+ ```markdown
654
+ ### [Date] - [Category]
655
+
656
+ **Before**: [Original prompt pattern]
657
+ **After**: [Improved prompt pattern]
658
+ **Improvement**: [What changed]
659
+ **Impact**: [Measured improvement]
660
+ ```
661
+
662
+ ### 8.5 Phase 5 Checklist
663
+
664
+ - [ ] Prompt Coach installed
665
+ - [ ] Analytics directory structure created
666
+ - [ ] /weekly-review command created
667
+ - [ ] Improvement log started
668
+ - [ ] First weekly review completed
669
+
670
+ ---
671
+
672
+ ## 9. Phase 6: Optimization
673
+
674
+ **Objective**: Measure effectiveness, tune processes, establish maintenance.
675
+
676
+ ### 9.1 Maintenance Schedule
677
+
678
+ **Daily**:
679
+ - /orient at session start
680
+ - /handoff at session end
681
+ - File discovered work immediately
682
+
683
+ **Weekly**:
684
+ - /weekly-review
685
+ - /decay-review
686
+ - Update metrics dashboard
687
+
688
+ **Monthly**:
689
+ - Generate monthly summary
690
+ - Review and update CLAUDE.md
691
+ - Archive old specs/handoffs
692
+
693
+ **Quarterly**:
694
+ - Full framework review
695
+ - Assess new tools/patterns
696
+ - Major documentation revision
697
+
698
+ ### 9.2 Metrics Collection
699
+
700
+ Track:
701
+ - Orientation time (target: <2 min)
702
+ - Ready work accuracy (target: >95%)
703
+ - Phase gate compliance (target: 100%)
704
+ - First-pass PR rate (target: >70%)
705
+ - Clarification rate (target: <15%)
706
+
707
+ ### 9.3 Framework Evolution
708
+
709
+ Document changes in `~/.claude/docs/framework-evolution.md`:
710
+
711
+ 1. Identify improvement
712
+ 2. Document proposal
713
+ 3. Test in isolation
714
+ 4. Roll out or reject
715
+ 5. Update documentation
716
+
717
+ ---
718
+
719
+ ## 10. Troubleshooting
720
+
721
+ ### Common Issues
722
+
723
+ #### Linear API Key Not Working
724
+
725
+ ```bash
726
+ # Check if set
727
+ echo $LINEAR_API_KEY
728
+
729
+ # If not set, add to ~/.zshenv
730
+ echo 'export LINEAR_API_KEY="your_key"' >> ~/.zshenv
731
+ source ~/.zshenv
732
+ ```
733
+
734
+ #### Pre-commit Hooks Failing
735
+
736
+ ```bash
737
+ # Skip hooks temporarily
738
+ git commit --no-verify
739
+
740
+ # Fix hooks
741
+ pre-commit run --all-files
742
+
743
+ # Reinstall
744
+ pre-commit uninstall && pre-commit install
745
+ ```
746
+
747
+ #### Semgrep Rules Not Running
748
+
749
+ ```bash
750
+ # Test rules directly
751
+ semgrep --config .semgrep.yaml src/
752
+
753
+ # Check for syntax errors
754
+ semgrep --validate --config .semgrep.yaml
755
+ ```
756
+
757
+ ### Rollback Procedures
758
+
759
+ #### Full Rollback
760
+
761
+ ```bash
762
+ BACKUP_DIR=~/.claude-backups/[DATE]
763
+
764
+ # Restore global
765
+ rm -rf ~/.claude/
766
+ cp -r $BACKUP_DIR/global-claude ~/.claude/
767
+
768
+ # Restore project
769
+ rm -rf .claude/
770
+ cp -r $BACKUP_DIR/project-claude .claude/
771
+ ```
772
+
773
+ #### Phase-Specific Rollback
774
+
775
+ See individual phase sections for targeted rollback instructions.
776
+
777
+ ---
778
+
779
+ ## Quick Reference
780
+
781
+ ### Essential Commands
782
+
783
+ | Command | Purpose | When |
784
+ |---------|---------|------|
785
+ | `/orient` | Session startup | Start of session |
786
+ | `/ready` | Find work | Before selecting task |
787
+ | `/validate` | Check environment | Before changes |
788
+ | `/explore` | Discovery | Before new feature |
789
+ | `/spec` | Create spec | After exploration |
790
+ | `/plan` | Create plan | After spec approved |
791
+ | `/tasks` | Create issues | After plan approved |
792
+ | `/discover` | File found work | During implementation |
793
+ | `/evidence` | Capture proof | Before PR |
794
+ | `/handoff` | End session | End of session |
795
+
796
+ ### Daily Workflow
797
+
798
+ ```
799
+ /orient → /ready → /validate → [work] → /discover → /evidence → /handoff
800
+ ```
801
+
802
+ ### Phase Gate Flow
803
+
804
+ ```
805
+ /explore → /spec → [approve] → /plan → [approve] → /tasks → [implement]
806
+ ```
807
+
808
+ ---
809
+
810
+ *For additional help, consult the pattern documentation in `docs/patterns/`.*