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,135 @@
1
+ # /force-exit - Bypass Verification Gate
2
+
3
+ > Force exit even when verification fails. Use with caution.
4
+
5
+ ## When to Use
6
+ - Known test flakiness that can't be fixed immediately
7
+ - Urgent context compaction needed
8
+ - External dependency causing false failures
9
+ - Explicitly instructed by user to bypass
10
+
11
+ ## When NOT to Use
12
+ - To skip fixing actual bugs
13
+ - To avoid dealing with lint errors
14
+ - As a regular workflow shortcut
15
+ - When you haven't tried to fix the issues
16
+
17
+ ## Arguments
18
+ - `reason` (required) - Explanation for bypassing verification
19
+
20
+ ## Execution Steps
21
+
22
+ ### Step 1: Confirm Bypass
23
+ Before forcing exit, ensure:
24
+ - You've attempted to fix the issues
25
+ - The failures are understood (not unknown errors)
26
+ - User has explicitly approved the bypass
27
+
28
+ ### Step 2: Log the Bypass
29
+ Record the reason in the gate log:
30
+ ```
31
+ [timestamp] [WARN] Force exit: <reason>
32
+ ```
33
+
34
+ ### Step 3: Set Environment Flag
35
+ ```bash
36
+ export ANVIL_FORCE_EXIT=true
37
+ ```
38
+
39
+ ### Step 4: Allow Exit
40
+ The stop hook will check this flag and allow exit with a warning.
41
+
42
+ ## Usage Examples
43
+
44
+ ### Flaky Test
45
+ ```
46
+ User: /force-exit "Test timeout due to CI slowness, will fix in next session"
47
+
48
+ Claude: ⚠️ Force exit requested
49
+ Reason: Test timeout due to CI slowness, will fix in next session
50
+ Verification gate bypassed.
51
+ ```
52
+
53
+ ### External Dependency
54
+ ```
55
+ User: /force-exit "API endpoint down, integration test failing"
56
+
57
+ Claude: ⚠️ Force exit requested
58
+ Reason: API endpoint down, integration test failing
59
+ Verification gate bypassed.
60
+ ```
61
+
62
+ ### Context Compaction Urgent
63
+ ```
64
+ User: /force-exit "Context at 95%, need to compact before losing work"
65
+
66
+ Claude: ⚠️ Force exit requested
67
+ Reason: Context at 95%, need to compact before losing work
68
+ Verification gate bypassed.
69
+ ```
70
+
71
+ ## Output Format
72
+
73
+ ### Success (Bypass Granted)
74
+ ```
75
+ ⚠️ Force exit granted
76
+
77
+ Reason: [user's reason]
78
+ Bypassing: tests, lint (2 failing checks)
79
+
80
+ WARNING: Exiting with unresolved verification failures.
81
+ Consider creating a ticket to address these issues.
82
+ ```
83
+
84
+ ### Denied (No Reason)
85
+ ```
86
+ ❌ Force exit requires a reason
87
+
88
+ Usage: /force-exit "explanation for bypassing"
89
+
90
+ This helps track why verification was skipped.
91
+ ```
92
+
93
+ ## Safety Mechanisms
94
+
95
+ | Protection | Description |
96
+ |------------|-------------|
97
+ | Reason required | Must explain why bypassing |
98
+ | Logged | All bypasses recorded with timestamp |
99
+ | Warning shown | Clear indication this is non-standard |
100
+ | No auto-bypass | User must explicitly request |
101
+
102
+ ## Anti-Patterns
103
+
104
+ | Don't | Do Instead |
105
+ |-------|------------|
106
+ | ❌ Force exit without trying to fix | ✅ Attempt fixes first |
107
+ | ❌ Use vague reasons ("it's fine") | ✅ Be specific about the issue |
108
+ | ❌ Bypass repeatedly for same issue | ✅ Create a ticket to properly fix |
109
+ | ❌ Force exit to save time | ✅ Fix issues or document why not |
110
+
111
+ ## Logging
112
+
113
+ All force exits are logged to `.claude/logs/stop_gate.log`:
114
+
115
+ ```
116
+ [2026-01-04T14:30:00Z] [WARN] Force exit requested - bypassing verification gate
117
+ [2026-01-04T14:30:00Z] [WARN] Reason: Test timeout due to CI slowness
118
+ [2026-01-04T14:30:00Z] [WARN] Bypassed checks: tests (1 failure)
119
+ ```
120
+
121
+ ## Integration Points
122
+
123
+ | Component | Integration |
124
+ |-----------|-------------|
125
+ | Stop Hook | Checks ANVIL_FORCE_EXIT flag |
126
+ | /verify | Shows what's being bypassed |
127
+ | Gate Logger | Records bypass event |
128
+ | Handoff | Should mention unresolved issues |
129
+
130
+ ## Key Behaviors
131
+
132
+ 1. **Always require a reason** - No silent bypasses
133
+ 2. **Log everything** - Audit trail for bypasses
134
+ 3. **Show warnings** - User should know this is non-standard
135
+ 4. **Single use** - Flag resets after exit, not persistent
@@ -0,0 +1,191 @@
1
+ # /handoff - Generate Session Continuity Document
2
+
3
+ > Create a handoff document preserving context for the next session.
4
+
5
+ ## When to Use
6
+ - At the end of every session
7
+ - Before stepping away for extended time
8
+ - When switching between tasks
9
+ - Before context compaction
10
+
11
+ ## Execution Steps
12
+
13
+ ### Step 1: Gather Session Context
14
+
15
+ Collect:
16
+ - Current branch and git status
17
+ - Issues worked on this session
18
+ - Files modified
19
+ - Current time/date
20
+
21
+ ### Step 2: Document Completed Work
22
+ List what was accomplished:
23
+ - Issues moved to "Done" or "In Review"
24
+ - PRs created
25
+ - Key decisions made
26
+
27
+ ### Step 3: Document In-Progress State
28
+ For any incomplete work:
29
+ - Current state of implementation
30
+ - What's left to do
31
+ - Any blockers encountered
32
+ - Files that were being edited
33
+
34
+ ### Step 4: Document Discovered Work
35
+ List any new issues/tasks discovered:
36
+ - Reference `/discover` calls made
37
+ - Captured in Linear or not yet filed
38
+
39
+ ### Step 5: Capture Environment State
40
+ ```bash
41
+ git status
42
+ git diff --stat
43
+ git log --oneline -3
44
+ ```
45
+
46
+ ### Step 5.5: Verify Changelog Entry
47
+
48
+ Before finalizing handoff, check if user-facing work was done this session:
49
+
50
+ 1. If work was user-facing (features, fixes, changes), verify CHANGELOG.md was updated:
51
+ ```bash
52
+ git diff --name-only main...HEAD | grep -c "CHANGELOG.md" || echo "0"
53
+ ```
54
+
55
+ 2. If no changelog entry detected but user-facing work completed:
56
+ ```markdown
57
+ ⚠️ Changelog Reminder:
58
+ You completed work this session but no CHANGELOG.md entry was detected.
59
+
60
+ Should this work be documented in the changelog?
61
+ - If yes: Add entry to [Unreleased] section before completing handoff
62
+ - If no: Internal/infrastructure change, proceed without entry
63
+ ```
64
+
65
+ 3. Document status for handoff:
66
+ - **Entry added**: Note what was added to [Unreleased]
67
+ - **No entry needed**: Confirm internal-only changes
68
+ - **Deferred**: Note that entry is still needed (carry forward to next session)
69
+
70
+ **Note**: This is a soft prompt—use judgment. Internal refactors and test-only changes don't require changelog entries.
71
+
72
+ ---
73
+
74
+ ### Step 6: Write Handoff File
75
+
76
+ Create file at: `.claude/handoffs/YYYY-MM-DD-HHMM.md`
77
+
78
+ Template:
79
+ ```markdown
80
+ ---
81
+ session_date: YYYY-MM-DD
82
+ session_time: HH:MM
83
+ branch: [current branch]
84
+ linear_issues: [comma-separated issue keys]
85
+ ---
86
+
87
+ # Session Handoff: [Brief description]
88
+
89
+ ## Session Summary
90
+ [1-2 sentence summary of what this session was about]
91
+
92
+ ## Completed This Session
93
+ - [x] [Issue key]: [What was done]
94
+ - [x] [Description of completed work]
95
+
96
+ ## In Progress (Not Complete)
97
+ ### [Issue key]: [Title]
98
+ - **Current state**: [Where we left off]
99
+ - **Next steps**: [What needs to happen next]
100
+ - **Files touched**: [List key files]
101
+ - **Blockers**: [Any blockers]
102
+
103
+ ## Discovered Work
104
+ - [ ] [Description] → Filed as [Issue key] / Not yet filed
105
+ - [ ] [Description] → Filed as [Issue key] / Not yet filed
106
+
107
+ ## Environment State
108
+ - **Branch**: [branch name]
109
+ - **Uncommitted changes**: [yes/no, brief description]
110
+ - **Last commit**: [hash] [message]
111
+
112
+ ## Changelog Status
113
+ - **Entry added to [Unreleased]**: Yes / No / Deferred
114
+ - **Change type**: Added / Changed / Fixed / Removed / N/A
115
+ - **Entry preview**: [First line of changelog entry, or "Internal changes only"]
116
+
117
+ ## Recommended Next Task
118
+ [What should be tackled first next session and why]
119
+
120
+ ## Critical Context for Next Session
121
+ [Any important context that might be lost]
122
+ - [Key decision made and why]
123
+ - [Important constraint discovered]
124
+ - [Thing to remember]
125
+ ```
126
+
127
+ ### Step 7: Deregister Agent (If Registered)
128
+
129
+ If agent registration is enabled (multi-terminal coordination), deregister this session:
130
+
131
+ ```bash
132
+ # Deregister agent with session summary
133
+ python3 project/hooks/session_start.py --deregister-agent --summary "[brief summary of work done]"
134
+ ```
135
+
136
+ This:
137
+ - Removes agent from coordination.md Active Sessions
138
+ - Adds completion entry to Session Log
139
+ - Clears agent from anvil-state.json
140
+
141
+ **Note**: Skip if not using multi-terminal coordination.
142
+
143
+ ### Step 8: Confirm Handoff
144
+
145
+ Output:
146
+ ```
147
+ ## Handoff Created
148
+
149
+ **File**: .claude/handoffs/YYYY-MM-DD-HHMM.md
150
+ **Session duration**: ~X hours
151
+ **Work items**: Y completed, Z in progress
152
+ **Agent**: [agent-id] deregistered (if applicable)
153
+
154
+ Next session should start with `/orient` to pick up context.
155
+ ```
156
+
157
+ ## Key Behaviors
158
+ - Be thorough—context is expensive to reconstruct
159
+ - Include specific file paths and line numbers
160
+ - Capture the "why" not just the "what"
161
+ - Recommend specific next action
162
+ - Verify changelog entry for user-facing work before handoff
163
+
164
+ ## State Sync (ANV-176)
165
+
166
+ After creating the handoff document, update the session state:
167
+
168
+ ```bash
169
+ python3 global/lib/state_manager.py handoff
170
+ ```
171
+
172
+ This updates `.claude/anvil-state.json` with:
173
+ - `phase: "handoff"`
174
+ - Sets `lastCommand: "/handoff"`
175
+
176
+ And syncs to the agent registry for statusline visibility.
177
+
178
+ ## Linear Issue State Note
179
+
180
+ If you created and merged a PR during this session, the associated Linear issue has **already been moved to Done** by Linear's GitHub integration. You don't need to manually update its status.
181
+
182
+ Check issue state before attempting updates — the `linear.py` state guard will skip redundant updates automatically.
183
+
184
+ ## Integration Points
185
+ - Creates: `.claude/handoffs/YYYY-MM-DD-HHMM.md`
186
+ - References: Linear issues worked on
187
+ - Used by: `/orient` command next session
188
+ - Calls: `project/hooks/session_start.py --deregister-agent` (if multi-terminal coordination enabled)
189
+ - Updates: `.claude/coordination.md` (removes from Active Sessions, adds to Session Log)
190
+ - Updates: `.claude/anvil-state.json` via state_manager.py
191
+ - Note: Linear issues may have auto-updated on PR merge
@@ -0,0 +1,302 @@
1
+ # /healthcheck - Framework Diagnostics
2
+
3
+ > Analyze session logs to identify framework issues, hook failures, and edge cases.
4
+
5
+ ## When to Use
6
+ - At end of development session (manual or auto-triggered)
7
+ - After encountering unexpected behavior
8
+ - When hooks seem to not be firing correctly
9
+ - To audit framework health periodically
10
+
11
+ ## Execution Steps
12
+
13
+ ### Step 1: Gather Session Data
14
+
15
+ Collect data from the current session's logs:
16
+
17
+ ```bash
18
+ # Check log files exist
19
+ ls -la logs/
20
+
21
+ # Expected files:
22
+ # - pre_tool_use.json (tool invocations, blocked commands)
23
+ # - post_tool_use.json (tool responses, errors)
24
+ # - session_start.json (session metadata)
25
+ # - stop.json (session end events)
26
+ # - user_prompt_submit.json (command usage)
27
+ ```
28
+
29
+ ### Step 2: Analyze Blocked Commands
30
+
31
+ Search `logs/pre_tool_use.json` for blocked operations:
32
+
33
+ **Pattern**: Look for entries where safety hooks blocked execution
34
+ - `rm -rf` commands blocked
35
+ - `.env` file access blocked
36
+ - Other safety rule triggers
37
+
38
+ ```python
39
+ # Pseudo-pattern for detection
40
+ blocked = [e for e in pre_tool_use if "BLOCKED" in stderr or exit_code == 2]
41
+ ```
42
+
43
+ ### Step 3: Analyze Tool Errors
44
+
45
+ Search `logs/post_tool_use.json` for failed tool calls:
46
+
47
+ **Patterns to detect**:
48
+ - `tool_response` containing `error` field
49
+ - File not found errors
50
+ - Permission denied
51
+ - Command execution failures
52
+ - Timeout errors
53
+
54
+ Group errors by:
55
+ - Tool name (Bash, Read, Write, Glob, etc.)
56
+ - Error type
57
+ - Frequency
58
+
59
+ ### Step 4: Analyze Hook Status
60
+
61
+ Check hook execution patterns:
62
+
63
+ | Hook | Expected | Check |
64
+ |------|----------|-------|
65
+ | session_start | 1 per session | Count in session_start.json |
66
+ | pre_tool_use | 1 per tool call | Count matches tool invocations |
67
+ | post_tool_use | 1 per tool call | Count matches tool completions |
68
+ | stop | 1 per session | Present in stop.json |
69
+
70
+ **Failure indicators**:
71
+ - Missing hook logs when hooks should fire
72
+ - Mismatched counts between pre/post
73
+ - Error messages in hook stderr
74
+
75
+ ### Step 5: Calculate Metrics
76
+
77
+ Compute session health metrics:
78
+
79
+ | Metric | Calculation |
80
+ |--------|-------------|
81
+ | Tool Invocations | Count of pre_tool_use entries |
82
+ | Success Rate | (total - errors) / total * 100 |
83
+ | Blocked Commands | Count of BLOCKED entries |
84
+ | Hook Coverage | hooks_fired / expected_hooks |
85
+
86
+ ### Step 6: Check Repository Hygiene (ANV-237)
87
+
88
+ Run the hygiene service to check for accumulated cruft:
89
+
90
+ ```bash
91
+ python3 global/lib/hygiene_service.py --check --json
92
+ ```
93
+
94
+ The hygiene service checks for:
95
+ - **Stash accumulation**: Warn if stashes exceed threshold (default: 5)
96
+ - **Old stashes**: Flag stashes older than threshold (default: 7 days)
97
+ - **Orphan branches**: Local branches with deleted remote tracking branches
98
+ - **Stale PRs**: Open PRs for issues already marked Done in Linear
99
+ - **Conflict PRs**: Open PRs with merge conflicts
100
+
101
+ **Status thresholds**:
102
+
103
+ | Check | ✅ PASS | ⚠️ WARN | ❌ FAIL |
104
+ |-------|---------|---------|---------|
105
+ | Stashes | ≤ threshold | > threshold | — |
106
+ | Old stashes | 0 | 1-3 | > 3 |
107
+ | Orphan branches | 0 | — | > 0 |
108
+ | Stale PRs | 0 | — | > 0 |
109
+ | Conflict PRs | 0 | > 0 | — |
110
+
111
+ If hygiene issues found, include in recommendations: "Run `/cleanup` to address repository hygiene issues."
112
+
113
+ ### Step 7: Generate Recommendations
114
+
115
+ Based on findings, generate actionable recommendations:
116
+
117
+ **If blocked commands > 0**:
118
+ - Review if blocks were false positives
119
+ - Consider adjusting safety rules if legitimate commands blocked
120
+
121
+ **If tool errors > 3**:
122
+ - Investigate repeated error patterns
123
+ - Check for path issues, permission problems
124
+
125
+ **If hook failures detected**:
126
+ - Verify hook scripts are executable
127
+ - Check for syntax errors in hook code
128
+ - Verify uv/Python availability
129
+
130
+ **If hygiene issues found**:
131
+ - Run `/cleanup` to address stale stashes, orphan branches, or stale PRs
132
+ - Consider closing PRs for issues already marked Done
133
+ - Delete local branches with deleted remotes
134
+
135
+ ### Step 8: Create Healthcheck Report
136
+
137
+ Save to: `.claude/healthchecks/YYYY-MM/{date}-{time}-{slug}.md`
138
+
139
+ ```markdown
140
+ # Healthcheck: YYYY-MM-DD HH:MM
141
+
142
+ **Session ID**: [from logs]
143
+ **Duration**: [calculated or estimated]
144
+ **Status**: ✅ Healthy | ⚠️ Issues Detected | ❌ Problems Found
145
+
146
+ ## Session Summary
147
+
148
+ [1-2 sentence narrative of what happened this session]
149
+
150
+ ## Metrics
151
+
152
+ | Metric | Value | Status |
153
+ |--------|-------|--------|
154
+ | Tool Invocations | X | — |
155
+ | Success Rate | X% | ✅/⚠️/❌ |
156
+ | Blocked Commands | X | ✅/⚠️ |
157
+ | Hook Failures | X | ✅/❌ |
158
+
159
+ ## Blocked Commands
160
+
161
+ | Time | Tool | Input | Reason |
162
+ |------|------|-------|--------|
163
+ | HH:MM | Bash | `rm -rf /` | Dangerous command |
164
+
165
+ *Or: "No commands blocked this session."*
166
+
167
+ ## Tool Errors
168
+
169
+ | Tool | Error | Count | Example |
170
+ |------|-------|-------|---------|
171
+ | Glob | File not found | 3 | Pattern `*.xyz` |
172
+
173
+ *Or: "No tool errors this session."*
174
+
175
+ ## Hook Status
176
+
177
+ | Hook | Executions | Status |
178
+ |------|------------|--------|
179
+ | session_start | 1 | ✅ |
180
+ | pre_tool_use | 145 | ✅ |
181
+ | post_tool_use | 143 | ✅ |
182
+ | stop | 0 | ⏳ Pending |
183
+
184
+ ## Repository Hygiene
185
+
186
+ | Check | Status | Details |
187
+ |-------|--------|---------|
188
+ | Stashes | ✅/⚠️ | X total (threshold: Y) |
189
+ | Old stashes | ✅/⚠️/❌ | X stashes older than Y days |
190
+ | Orphan branches | ✅/❌ | X with gone remotes |
191
+ | Stale PRs | ✅/❌ | X for Done issues |
192
+ | Conflict PRs | ✅/⚠️ | X with conflicts |
193
+
194
+ *Or if all pass: "Repository hygiene: ✅ No issues detected"*
195
+
196
+ *If issues found: "Run `/cleanup` to address hygiene issues."*
197
+
198
+ ## Recommendations
199
+
200
+ 1. **[Category]**: [Specific recommendation]
201
+ 2. **[Category]**: [Specific recommendation]
202
+
203
+ *Or: "Framework operating normally. No action required."*
204
+
205
+ ## Discovered Work
206
+
207
+ - [ ] [Issue description] — File with `/discover`
208
+ - [ ] [Issue description] — File with `/discover`
209
+
210
+ *Or: "No issues discovered."*
211
+ ```
212
+
213
+ ### Step 9: Offer to File Issues
214
+
215
+ If significant issues found:
216
+
217
+ ```
218
+ ## Issues Found
219
+
220
+ The following issues should be filed:
221
+
222
+ 1. **[Title]**: [Description]
223
+ → Run `/discover` to file as Linear issue
224
+
225
+ Would you like me to file these now?
226
+ ```
227
+
228
+ ### Step 10: Confirm Healthcheck
229
+
230
+ ```
231
+ ## Healthcheck Complete
232
+
233
+ **File**: .claude/healthchecks/2024-12/2024-12-24-1730-session.md
234
+ **Status**: ⚠️ Issues Detected
235
+ **Key Finding**: 3 Glob errors suggest path configuration issue
236
+
237
+ Run `/insights` to see patterns across multiple healthchecks.
238
+ ```
239
+
240
+ ## Log File Reference
241
+
242
+ ### pre_tool_use.json
243
+ ```json
244
+ {
245
+ "session_id": "abc123",
246
+ "hook_event_name": "PreToolUse",
247
+ "tool_name": "Bash",
248
+ "tool_input": { "command": "rm -rf /" }
249
+ }
250
+ ```
251
+
252
+ ### post_tool_use.json
253
+ ```json
254
+ {
255
+ "session_id": "abc123",
256
+ "hook_event_name": "PostToolUse",
257
+ "tool_name": "Glob",
258
+ "tool_input": { "pattern": "**/*.xyz" },
259
+ "tool_response": {
260
+ "filenames": [],
261
+ "error": "No files found"
262
+ }
263
+ }
264
+ ```
265
+
266
+ ## Status Thresholds
267
+
268
+ | Metric | ✅ Healthy | ⚠️ Warning | ❌ Problem |
269
+ |--------|-----------|-----------|-----------|
270
+ | Success Rate | >95% | 80-95% | <80% |
271
+ | Blocked Commands | 0-1 | 2-5 | >5 |
272
+ | Hook Failures | 0 | 1-2 | >2 |
273
+ | Tool Errors | 0-3 | 4-10 | >10 |
274
+ | Stash Count | ≤5 | >5 | — |
275
+ | Old Stashes | 0 | 1-3 | >3 |
276
+ | Orphan Branches | 0 | — | >0 |
277
+ | Stale PRs | 0 | — | >0 |
278
+ | Conflict PRs | 0 | >0 | — |
279
+
280
+ ## Key Behaviors
281
+
282
+ - Analyze current session only (not historical)
283
+ - Be specific about errors (include examples)
284
+ - Recommend actions, not just report issues
285
+ - Offer to file discovered work
286
+ - Keep narrative concise
287
+
288
+ ## What This Command Does NOT Do
289
+
290
+ - Modify log files
291
+ - Auto-fix issues
292
+ - Analyze historical sessions (use `/insights` for patterns)
293
+ - Replace manual debugging
294
+
295
+ ## Integration Points
296
+
297
+ - Creates: `.claude/healthchecks/YYYY-MM/*.md`
298
+ - Synthesized by: `/insights` command
299
+ - Triggered by: Stop hook (if `autoHealthcheck` enabled)
300
+ - Files work via: `/discover` command
301
+ - Uses: `global/lib/hygiene_service.py` for repository hygiene checks (ANV-237)
302
+ - Recommends: `/cleanup` command when hygiene issues found
@@ -0,0 +1,84 @@
1
+ # /hud - Launch Multi-Agent Dashboard
2
+
3
+ > Open the Anvil HUD terminal dashboard for monitoring all active Claude Code agents.
4
+
5
+ ## When to Use
6
+ - **Multi-agent sessions**: Running 2+ Claude Code agents in parallel
7
+ - **Cost monitoring**: Track API spending across agents
8
+ - **Context health**: Watch for compaction warnings
9
+ - **Coordination**: See which files/issues each agent is working on
10
+
11
+ ## Quick Launch
12
+
13
+ ### Option 1: Split Terminal (Recommended)
14
+ Open a new terminal pane (Cmd+D in Warp/iTerm, or `tmux split-window`) and run:
15
+
16
+ ```bash
17
+ uv run global/tools/anvil-hud.py
18
+ ```
19
+
20
+ ### Option 2: Demo Mode
21
+ Test the HUD with sample data:
22
+
23
+ ```bash
24
+ uv run global/tools/anvil-hud.py --demo
25
+ ```
26
+
27
+ ## Dashboard Keybindings
28
+
29
+ | Key | Action |
30
+ |-----|--------|
31
+ | `q` | Quit HUD |
32
+ | `r` | Force refresh |
33
+ | `d` | Toggle detailed view |
34
+ | `?` | Show help |
35
+
36
+ ## What the HUD Shows
37
+
38
+ ### Agent Panel
39
+ - **Agent ID**: Human-readable name (e.g., `swift-falcon-a3f2`)
40
+ - **Model**: Current model (Opus/Sonnet/Haiku)
41
+ - **Context**: Usage percentage with color-coded warnings
42
+ - **Cost**: Session spend in USD
43
+ - **Project**: Working directory
44
+ - **Status**: Active, idle, or stale
45
+
46
+ ### Status Indicators
47
+ | Icon | Meaning |
48
+ |------|---------|
49
+ | ● | Active (recent activity) |
50
+ | ○ | Idle (no recent activity) |
51
+ | ⚠ | Context warning (>70%) |
52
+ | 🔴 | Context critical (>85%) |
53
+
54
+ ## Data Sources
55
+
56
+ The HUD reads from:
57
+ - `~/.anvil/agents.json` - Agent registry (auto-updated by statusline hook)
58
+ - `.claude/anvil-state.json` - Current session state
59
+
60
+ ## Troubleshooting
61
+
62
+ ### HUD shows 0% context/cost
63
+ - Make sure the statusline hook is running (check `.claude/settings.local.json`)
64
+ - Data syncs on each Claude Code request via the StatusLine hook
65
+
66
+ ### Agents not appearing
67
+ - Run `/orient` in each Claude Code session to register agents
68
+ - Check that `~/.anvil/agents.json` exists
69
+
70
+ ### Stale agents showing
71
+ - Agents auto-mark as stale after 30 minutes of inactivity
72
+ - Force refresh with `r` key
73
+
74
+ ## Related Commands
75
+ - `/orient` - Register agent at session start
76
+ - `/validate` - Check environment before work
77
+ - `/handoff` - Preserve context before ending session
78
+
79
+ ## Future Enhancements (HUD v2)
80
+ See spec at `.claude/specs/current/SPEC-ANV-HUD-v2.md` for planned features:
81
+ - Cost attribution per issue
82
+ - Quality gates panel (CI, tests, CodeRabbit)
83
+ - Linear issue board integration
84
+ - File lock coordination