@smicolon/ai-kit 0.0.1 → 0.1.1

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 (163) hide show
  1. package/.claude-plugin/CLAUDE.md +7 -0
  2. package/.claude-plugin/marketplace.json +373 -0
  3. package/README.md +132 -0
  4. package/package.json +13 -3
  5. package/packs/architect/CHANGELOG.md +17 -0
  6. package/packs/architect/README.md +58 -0
  7. package/packs/architect/agents/system-architect.md +768 -0
  8. package/packs/architect/commands/diagram-create.md +300 -0
  9. package/packs/better-auth/.claude-plugin/plugin.json +14 -0
  10. package/packs/better-auth/.mcp.json +14 -0
  11. package/packs/better-auth/CHANGELOG.md +26 -0
  12. package/packs/better-auth/README.md +125 -0
  13. package/packs/better-auth/agents/auth-architect.md +278 -0
  14. package/packs/better-auth/commands/auth-provider-add.md +265 -0
  15. package/packs/better-auth/commands/auth-setup.md +298 -0
  16. package/packs/better-auth/skills/auth-security/SKILL.md +425 -0
  17. package/packs/better-auth/skills/better-auth-patterns/SKILL.md +455 -0
  18. package/packs/dev-loop/.claude-plugin/plugin.json +10 -0
  19. package/packs/dev-loop/CHANGELOG.md +69 -0
  20. package/packs/dev-loop/README.md +155 -0
  21. package/packs/dev-loop/commands/cancel-dev.md +21 -0
  22. package/packs/dev-loop/commands/dev-loop.md +72 -0
  23. package/packs/dev-loop/commands/dev-plan.md +351 -0
  24. package/packs/dev-loop/hooks/hooks.json +15 -0
  25. package/packs/dev-loop/hooks/stop-hook.sh +178 -0
  26. package/packs/dev-loop/scripts/setup-dev-loop.sh +194 -0
  27. package/packs/dev-loop/skills/tdd-planner/SKILL.md +249 -0
  28. package/packs/dev-loop/skills/tdd-planner/references/framework-patterns.md +874 -0
  29. package/packs/dev-loop/skills/tdd-planner/references/good-example.md +260 -0
  30. package/packs/dev-loop/skills/tdd-planner/references/plan-template.md +275 -0
  31. package/packs/django/CHANGELOG.md +39 -0
  32. package/packs/django/README.md +92 -0
  33. package/packs/django/agents/django-architect.md +182 -0
  34. package/packs/django/agents/django-builder.md +250 -0
  35. package/packs/django/agents/django-feature-based.md +420 -0
  36. package/packs/django/agents/django-reviewer.md +253 -0
  37. package/packs/django/agents/django-tester.md +230 -0
  38. package/packs/django/commands/api-endpoint.md +285 -0
  39. package/packs/django/commands/model-create.md +178 -0
  40. package/packs/django/commands/test-generate.md +325 -0
  41. package/packs/django/rules/migrations.md +138 -0
  42. package/packs/django/rules/models.md +167 -0
  43. package/packs/django/rules/serializers.md +126 -0
  44. package/packs/django/rules/services.md +131 -0
  45. package/packs/django/rules/tests.md +140 -0
  46. package/packs/django/rules/views.md +102 -0
  47. package/packs/django/skills/import-convention-enforcer/SKILL.md +226 -0
  48. package/packs/django/skills/import-convention-enforcer/patterns/django-imports.md +343 -0
  49. package/packs/django/skills/migration-safety-checker/SKILL.md +375 -0
  50. package/packs/django/skills/model-entity-validator/SKILL.md +298 -0
  51. package/packs/django/skills/performance-optimizer/SKILL.md +447 -0
  52. package/packs/django/skills/red-phase-verifier/SKILL.md +180 -0
  53. package/packs/django/skills/security-first-validator/SKILL.md +435 -0
  54. package/packs/django/skills/test-coverage-advisor/SKILL.md +394 -0
  55. package/packs/django/skills/test-validity-checker/SKILL.md +194 -0
  56. package/packs/failure-log/.claude-plugin/plugin.json +14 -0
  57. package/packs/failure-log/CHANGELOG.md +20 -0
  58. package/packs/failure-log/README.md +168 -0
  59. package/packs/failure-log/commands/failure-add.md +106 -0
  60. package/packs/failure-log/commands/failure-list.md +89 -0
  61. package/packs/failure-log/hooks/hooks.json +16 -0
  62. package/packs/failure-log/hooks/scripts/inject-failures.sh +64 -0
  63. package/packs/failure-log/skills/failure-log-manager/SKILL.md +164 -0
  64. package/packs/flutter/.claude-plugin/plugin.json +10 -0
  65. package/packs/flutter/CHANGELOG.md +19 -0
  66. package/packs/flutter/README.md +170 -0
  67. package/packs/flutter/agents/flutter-architect.md +166 -0
  68. package/packs/flutter/agents/flutter-builder.md +303 -0
  69. package/packs/flutter/agents/release-manager.md +355 -0
  70. package/packs/flutter/commands/fastlane-setup.md +188 -0
  71. package/packs/flutter/commands/flutter-build.md +90 -0
  72. package/packs/flutter/commands/flutter-deploy.md +133 -0
  73. package/packs/flutter/commands/flutter-test.md +117 -0
  74. package/packs/flutter/commands/signing-setup.md +209 -0
  75. package/packs/flutter/hooks/hooks.json +17 -0
  76. package/packs/flutter/skills/fastlane-knowledge/SKILL.md +193 -0
  77. package/packs/flutter/skills/flutter-architecture/SKILL.md +127 -0
  78. package/packs/flutter/skills/store-publishing/SKILL.md +163 -0
  79. package/packs/hono/.claude-plugin/plugin.json +19 -0
  80. package/packs/hono/CHANGELOG.md +19 -0
  81. package/packs/hono/README.md +143 -0
  82. package/packs/hono/agents/hono-architect.md +240 -0
  83. package/packs/hono/agents/hono-builder.md +285 -0
  84. package/packs/hono/agents/hono-reviewer.md +279 -0
  85. package/packs/hono/agents/hono-tester.md +346 -0
  86. package/packs/hono/commands/middleware-create.md +223 -0
  87. package/packs/hono/commands/project-init.md +306 -0
  88. package/packs/hono/commands/route-create.md +153 -0
  89. package/packs/hono/commands/rpc-client.md +263 -0
  90. package/packs/hono/hooks/hooks.json +4 -0
  91. package/packs/hono/skills/cloudflare-bindings/SKILL.md +408 -0
  92. package/packs/hono/skills/hono-patterns/SKILL.md +309 -0
  93. package/packs/hono/skills/rpc-typesafe/SKILL.md +388 -0
  94. package/packs/hono/skills/zod-validation/SKILL.md +332 -0
  95. package/packs/nestjs/CHANGELOG.md +29 -0
  96. package/packs/nestjs/README.md +75 -0
  97. package/packs/nestjs/agents/nestjs-architect.md +402 -0
  98. package/packs/nestjs/agents/nestjs-builder.md +301 -0
  99. package/packs/nestjs/agents/nestjs-tester.md +437 -0
  100. package/packs/nestjs/commands/module-create.md +369 -0
  101. package/packs/nestjs/rules/controllers.md +92 -0
  102. package/packs/nestjs/rules/dto.md +124 -0
  103. package/packs/nestjs/rules/entities.md +102 -0
  104. package/packs/nestjs/rules/services.md +106 -0
  105. package/packs/nestjs/skills/barrel-export-manager/SKILL.md +389 -0
  106. package/packs/nestjs/skills/import-convention-enforcer/SKILL.md +365 -0
  107. package/packs/nextjs/CHANGELOG.md +36 -0
  108. package/packs/nextjs/README.md +76 -0
  109. package/packs/nextjs/agents/frontend-tester.md +680 -0
  110. package/packs/nextjs/agents/frontend-visual.md +820 -0
  111. package/packs/nextjs/agents/nextjs-architect.md +331 -0
  112. package/packs/nextjs/agents/nextjs-modular.md +433 -0
  113. package/packs/nextjs/commands/component-create.md +398 -0
  114. package/packs/nextjs/rules/api-routes.md +129 -0
  115. package/packs/nextjs/rules/components.md +106 -0
  116. package/packs/nextjs/rules/hooks.md +132 -0
  117. package/packs/nextjs/skills/accessibility-validator/SKILL.md +445 -0
  118. package/packs/nextjs/skills/import-convention-enforcer/SKILL.md +399 -0
  119. package/packs/nextjs/skills/react-form-validator/SKILL.md +569 -0
  120. package/packs/nuxtjs/CHANGELOG.md +30 -0
  121. package/packs/nuxtjs/README.md +56 -0
  122. package/packs/nuxtjs/agents/frontend-tester.md +680 -0
  123. package/packs/nuxtjs/agents/frontend-visual.md +820 -0
  124. package/packs/nuxtjs/agents/nuxtjs-architect.md +537 -0
  125. package/packs/nuxtjs/commands/component-create.md +223 -0
  126. package/packs/nuxtjs/rules/components.md +101 -0
  127. package/packs/nuxtjs/rules/composables.md +118 -0
  128. package/packs/nuxtjs/rules/server-routes.md +127 -0
  129. package/packs/nuxtjs/skills/accessibility-validator/SKILL.md +183 -0
  130. package/packs/nuxtjs/skills/import-convention-enforcer/SKILL.md +196 -0
  131. package/packs/nuxtjs/skills/veevalidate-form-validator/SKILL.md +190 -0
  132. package/packs/onboard/CHANGELOG.md +22 -0
  133. package/packs/onboard/README.md +103 -0
  134. package/packs/onboard/agents/onboard-guide.md +118 -0
  135. package/packs/onboard/commands/onboard.md +313 -0
  136. package/packs/onboard/skills/onboard-context-provider/SKILL.md +98 -0
  137. package/packs/tanstack-router/.claude-plugin/plugin.json +14 -0
  138. package/packs/tanstack-router/CHANGELOG.md +30 -0
  139. package/packs/tanstack-router/README.md +113 -0
  140. package/packs/tanstack-router/agents/tanstack-architect.md +173 -0
  141. package/packs/tanstack-router/agents/tanstack-builder.md +360 -0
  142. package/packs/tanstack-router/agents/tanstack-tester.md +454 -0
  143. package/packs/tanstack-router/commands/form-create.md +313 -0
  144. package/packs/tanstack-router/commands/query-create.md +263 -0
  145. package/packs/tanstack-router/commands/route-create.md +190 -0
  146. package/packs/tanstack-router/commands/table-create.md +413 -0
  147. package/packs/tanstack-router/skills/ai-patterns/SKILL.md +370 -0
  148. package/packs/tanstack-router/skills/db-patterns/SKILL.md +346 -0
  149. package/packs/tanstack-router/skills/devtools-patterns/SKILL.md +415 -0
  150. package/packs/tanstack-router/skills/form-patterns/SKILL.md +425 -0
  151. package/packs/tanstack-router/skills/pacer-patterns/SKILL.md +341 -0
  152. package/packs/tanstack-router/skills/query-patterns/SKILL.md +359 -0
  153. package/packs/tanstack-router/skills/router-patterns/SKILL.md +285 -0
  154. package/packs/tanstack-router/skills/store-patterns/SKILL.md +351 -0
  155. package/packs/tanstack-router/skills/table-patterns/SKILL.md +531 -0
  156. package/packs/tanstack-router/skills/tanstack-conventions/SKILL.md +428 -0
  157. package/packs/tanstack-router/skills/virtual-patterns/SKILL.md +490 -0
  158. package/packs/worktree/.claude-plugin/plugin.json +19 -0
  159. package/packs/worktree/CHANGELOG.md +24 -0
  160. package/packs/worktree/README.md +110 -0
  161. package/packs/worktree/commands/wt.md +73 -0
  162. package/packs/worktree/scripts/wt.sh +396 -0
  163. package/packs/worktree/skills/worktree-manager/SKILL.md +68 -0
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: dev-loop
3
+ description: "Start dev loop for iterative development"
4
+ argument-hint: '"Your prompt here" [--from-plan] [--max-iterations N] [--promise TEXT]'
5
+ allowed-tools: ["Bash(${CLAUDE_PLUGIN_ROOT}/scripts/setup-dev-loop.sh:*)"]
6
+ ---
7
+
8
+ ```!
9
+ "${CLAUDE_PLUGIN_ROOT}/scripts/setup-dev-loop.sh" $ARGUMENTS
10
+ ```
11
+
12
+ # Dev Loop Started
13
+
14
+ You are now in a development loop. The loop will continue until you output `<promise>DONE</promise>` or reach the maximum iterations (default: 50).
15
+
16
+ ## How It Works
17
+
18
+ 1. **You receive a prompt** - Work on the task iteratively
19
+ 2. **Complete work** - When done, output `<promise>DONE</promise>`
20
+ 3. **Loop continues** - If you don't output the promise, you'll get the prompt again
21
+ 4. **Max safety** - After 50 iterations, the loop stops automatically
22
+
23
+ ## Completion
24
+
25
+ When your work is complete, output:
26
+
27
+ ```
28
+ <promise>DONE</promise>
29
+ ```
30
+
31
+ This ends the loop successfully.
32
+
33
+ ## Flags
34
+
35
+ ```bash
36
+ # Use existing plan from /dev-plan command
37
+ /dev-loop --from-plan
38
+
39
+ # Override max iterations (default: 50)
40
+ /dev-loop "Build feature X" --max-iterations 30
41
+
42
+ # Custom completion promise (default: DONE)
43
+ /dev-loop "Refactor module Y" --promise "REFACTOR_COMPLETE"
44
+ ```
45
+
46
+ ## Recommended Workflow
47
+
48
+ For best results, use the planning phase first:
49
+
50
+ ```bash
51
+ # 1. Generate structured TDD plan
52
+ /dev-plan "Build user authentication"
53
+
54
+ # 2. Review and edit .claude/dev-plan.local.md if needed
55
+
56
+ # 3. Execute with structured plan
57
+ /dev-loop --from-plan
58
+ ```
59
+
60
+ This creates a plan with:
61
+ - TDD phases (Red-Green-Refactor)
62
+ - Clear verification commands
63
+ - Self-correction rules
64
+ - Stuck handling
65
+
66
+ ## Tips
67
+
68
+ - Use `/dev-plan` first for complex tasks
69
+ - Break complex tasks into smaller steps
70
+ - Test your work before declaring completion
71
+ - Use `<promise>DONE</promise>` only when truly finished
72
+ - If stuck, the loop will eventually timeout at max iterations
@@ -0,0 +1,351 @@
1
+ ---
2
+ name: dev-plan
3
+ description: Generate a structured TDD plan for dev-loop execution
4
+ argument-hint: '"Your goal" [--framework NAME] [--test-cmd "cmd"] [--lint-cmd "cmd"] [--interactive]'
5
+ allowed-tools: ["Read", "Write", "Glob", "Grep", "Bash", "AskUserQuestion"]
6
+ ---
7
+
8
+ # Create Development Plan
9
+
10
+ Generate a high-quality, structured TDD plan for use with `/dev-loop --from-plan`.
11
+
12
+ **Quality Standard:** See `references/good-example.md` for the expected output quality.
13
+
14
+ ---
15
+
16
+ ## Steps
17
+
18
+ ### 1. Parse Arguments
19
+
20
+ Extract from user input:
21
+ - **Goal**: The main objective (required)
22
+ - **--framework**: Override auto-detection (optional, any framework name)
23
+ - **--test-cmd**: Custom test command (optional, overrides auto-detect)
24
+ - **--lint-cmd**: Custom lint command (optional, overrides auto-detect)
25
+ - **--interactive**: Ask clarifying questions (optional)
26
+
27
+ ### 2. Detect Framework
28
+
29
+ **Priority order:**
30
+ 1. Use `--test-cmd` and `--lint-cmd` if provided (custom stack)
31
+ 2. Use `--framework` if specified
32
+ 3. Auto-detect from project files
33
+
34
+ **Auto-detection (first match wins):**
35
+
36
+ ```bash
37
+ # Mobile
38
+ [ -f "pubspec.yaml" ] && grep -q "flutter:" pubspec.yaml && echo "flutter"
39
+ [ -f "package.json" ] && grep -q "react-native" package.json && echo "react-native"
40
+
41
+ # Python
42
+ [ -f "manage.py" ] && echo "django"
43
+ [ -f "pyproject.toml" ] && grep -q "fastapi" pyproject.toml && echo "fastapi"
44
+ [ -f "pyproject.toml" ] && grep -q "flask" pyproject.toml && echo "flask"
45
+
46
+ # Node.js
47
+ grep -q "@nestjs/core" package.json 2>/dev/null && echo "nestjs"
48
+ grep -q '"next"' package.json 2>/dev/null && echo "nextjs"
49
+ grep -q '"nuxt"' package.json 2>/dev/null && echo "nuxtjs"
50
+ grep -q '"hono"' package.json 2>/dev/null && echo "hono"
51
+ grep -q '"express"' package.json 2>/dev/null && echo "express"
52
+ grep -q '"@tanstack/react-router"' package.json 2>/dev/null && echo "tanstack"
53
+
54
+ # Go
55
+ [ -f "go.mod" ] && echo "go"
56
+
57
+ # Rust
58
+ [ -f "Cargo.toml" ] && echo "rust"
59
+
60
+ # Ruby
61
+ [ -f "Gemfile" ] && grep -q "rails" Gemfile && echo "rails"
62
+
63
+ # PHP
64
+ [ -f "composer.json" ] && grep -q "laravel" composer.json && echo "laravel"
65
+
66
+ # Generic fallbacks
67
+ [ -f "pyproject.toml" ] || [ -f "requirements.txt" ] && echo "python"
68
+ [ -f "package.json" ] && echo "node"
69
+ ```
70
+
71
+ **Package Manager Detection (for Node.js projects):**
72
+
73
+ ```bash
74
+ # Detect package manager (first match wins)
75
+ [ -f "bun.lockb" ] && PM="bun"
76
+ [ -f "pnpm-lock.yaml" ] && PM="pnpm"
77
+ [ -f "yarn.lock" ] && PM="yarn"
78
+ [ -f "package-lock.json" ] && PM="npm"
79
+ # Default to bun if no lockfile
80
+ [ -z "$PM" ] && PM="bun"
81
+ ```
82
+
83
+ **Framework Commands Table:**
84
+
85
+ Use `${PM}` for the detected package manager (defaults to `bun`).
86
+
87
+ | Framework | Test Command | Lint Command |
88
+ |-----------|--------------|--------------|
89
+ | **Mobile** | | |
90
+ | Flutter | `flutter test` | `flutter analyze` |
91
+ | React Native | `${PM} test` | `${PM} run lint` |
92
+ | **Python** | | |
93
+ | Django | `pytest --tb=short` | `ruff check .` |
94
+ | FastAPI | `pytest --tb=short` | `ruff check .` |
95
+ | Flask | `pytest --tb=short` | `ruff check .` |
96
+ | Python (generic) | `pytest` | `ruff check .` |
97
+ | **Node.js** | | |
98
+ | NestJS | `${PM} test` | `${PM} run lint` |
99
+ | Next.js | `${PM} test` | `${PM} run lint` |
100
+ | Nuxt.js | `${PM} test` | `${PM} run lint` |
101
+ | Hono | `bun test` | `bun run lint` |
102
+ | Express | `${PM} test` | `${PM} run lint` |
103
+ | TanStack | `bun test` | `bun run lint` |
104
+ | Node (generic) | `${PM} test` | `${PM} run lint` |
105
+ | **Systems** | | |
106
+ | Go | `go test ./...` | `golangci-lint run` |
107
+ | Rust | `cargo test` | `cargo clippy` |
108
+ | **Web Frameworks** | | |
109
+ | Rails | `bundle exec rspec` | `bundle exec rubocop` |
110
+ | Laravel | `php artisan test` | `./vendor/bin/pint` |
111
+
112
+ **Unknown Framework Handling:**
113
+
114
+ If framework is unknown or not detected:
115
+ 1. Check for common test files (`*_test.go`, `*_spec.rb`, `*.test.ts`)
116
+ 2. Check package.json/pyproject.toml for test scripts
117
+ 3. If `--interactive`, ask user for test/lint commands
118
+ 4. Default: prompt user to specify `--test-cmd` and `--lint-cmd`
119
+
120
+ ### 3. Deep Codebase Analysis
121
+
122
+ **CRITICAL:** Analyze the codebase thoroughly before planning.
123
+
124
+ Read and understand:
125
+ - [ ] Existing test files (understand testing patterns)
126
+ - [ ] Related modules/components (understand current structure)
127
+ - [ ] Configuration files (package.json, pubspec.yaml, etc.)
128
+ - [ ] Similar implementations (reuse patterns)
129
+ - [ ] Documentation (CLAUDE.md, README.md)
130
+
131
+ Identify specifically:
132
+ - **Current State**: What exists now that relates to the goal?
133
+ - **Work Items**: List each specific item to create/modify
134
+ - **Files to Modify**: Which existing files need changes?
135
+ - **New Files**: Which files need to be created?
136
+ - **Dependencies**: What packages/imports are needed?
137
+
138
+ ### 4. Generate File Tables
139
+
140
+ **REQUIRED:** Every plan must include these tables.
141
+
142
+ #### Files to Modify
143
+
144
+ | File | Action |
145
+ |------|--------|
146
+ | `path/to/file.ext` | Description of changes |
147
+
148
+ #### New Files to Create
149
+
150
+ | File | Purpose |
151
+ |------|---------|
152
+ | `path/to/new/file.ext` | What this file does |
153
+
154
+ ### 5. Create TDD Phases
155
+
156
+ For each component, create Red-Green-Refactor phases:
157
+
158
+ #### Phase Structure
159
+
160
+ ```markdown
161
+ ### Phase N: {{TYPE}} - {{COMPONENT}}
162
+
163
+ **Goal:** {{SPECIFIC_GOAL}}
164
+
165
+ **Tasks:**
166
+ - [ ] {{TASK}} in `{{FILE_PATH}}`:
167
+ - {{DETAIL_1}}
168
+ - {{DETAIL_2}}
169
+
170
+ **Implementation Structure:**
171
+ ```{{language}}
172
+ // Show actual code structure expected
173
+ ```
174
+
175
+ **Verification:**
176
+ ```bash
177
+ {{COMMAND}}
178
+ ```
179
+ **Expected:** {{OUTCOME}} (e.g., "should FAIL - tests don't exist yet")
180
+
181
+ **Self-correction:**
182
+ - {{PHASE_SPECIFIC_TIP}}
183
+ ```
184
+
185
+ #### Phase Types
186
+
187
+ **Red Phase:**
188
+ - Write failing tests first
189
+ - Expected: Tests FAIL (implementation doesn't exist)
190
+ - Self-correction: "If tests pass, they're not testing the right thing"
191
+
192
+ **Green Phase:**
193
+ - Implement minimum code to pass tests
194
+ - Include code snippet showing structure
195
+ - Expected: Tests PASS
196
+ - Self-correction: "If tests fail, read error, fix implementation (not test)"
197
+
198
+ **Refactor Phase:**
199
+ - Clean up code, add types, documentation
200
+ - Expected: Tests still PASS, lint clean
201
+ - Self-correction: "If tests fail, refactoring broke something - revert"
202
+
203
+ ### 6. Define Success Criteria
204
+
205
+ Measurable criteria with specifics:
206
+
207
+ ```markdown
208
+ ## Success Criteria
209
+
210
+ - [ ] {{SPECIFIC_BEHAVIOR}} (e.g., "Login returns JWT token")
211
+ - [ ] {{QUANTITATIVE}} (e.g., "81+ tests pass")
212
+ - [ ] {{NEGATIVE_CASE}} (e.g., "Invalid credentials return 401")
213
+ - [ ] All tests pass (`{{TEST_COMMAND}}`)
214
+ - [ ] Linter clean (`{{LINT_COMMAND}}`)
215
+ ```
216
+
217
+ ### 7. Add Acceptance Criteria (Optional)
218
+
219
+ For user-facing features, add Given/When/Then:
220
+
221
+ ```markdown
222
+ ## Acceptance Criteria
223
+
224
+ ### 1. User can login with valid credentials
225
+ - **Given**: Valid email and password
226
+ - **When**: POST /api/auth/login
227
+ - **Then**: Returns 200 + JWT token
228
+
229
+ ### 2. Invalid credentials rejected
230
+ - **Given**: Wrong password
231
+ - **When**: POST /api/auth/login
232
+ - **Then**: Returns 401 + error message
233
+ ```
234
+
235
+ ### 8. Add Stuck Handling
236
+
237
+ **REQUIRED:** Framework-specific stuck handling, not generic.
238
+
239
+ ```markdown
240
+ ## Stuck Handling
241
+
242
+ ### If same test keeps failing:
243
+ 1. Read the exact error message (not just "test failed")
244
+ 2. Check if {{FRAMEWORK_SPECIFIC_THING}} is configured correctly
245
+ 3. Verify {{COMMON_MISTAKE_FOR_THIS_FRAMEWORK}}
246
+ 4. Check ProviderScope/dependency injection/imports
247
+
248
+ ### If app/server won't start:
249
+ 1. Check {{ENTRY_POINT_FILE}}
250
+ 2. Verify {{INITIALIZATION_ORDER}}
251
+ 3. Look for circular dependencies
252
+
253
+ ### Alternative approaches if blocked:
254
+ 1. {{SIMPLER_APPROACH}}
255
+ 2. {{INCREMENTAL_APPROACH}}
256
+ 3. {{FALLBACK_APPROACH}}
257
+ ```
258
+
259
+ ### 9. Quality Checklist
260
+
261
+ Before saving, verify the plan meets quality standards:
262
+
263
+ - [ ] Context lists **specific items** to work on
264
+ - [ ] Success criteria are **measurable**
265
+ - [ ] **Every task** has a file path
266
+ - [ ] **Code snippets** show implementation structure
267
+ - [ ] Verification has **expected output** with reasoning
268
+ - [ ] Self-correction is **phase-specific**
269
+ - [ ] **Files to Modify** table exists
270
+ - [ ] **New Files to Create** table exists
271
+ - [ ] Stuck handling is **framework-specific**
272
+
273
+ ### 10. Save Plan
274
+
275
+ Save to `.claude/dev-plan.local.md`:
276
+
277
+ ```markdown
278
+ # Dev Loop Plan: {{GOAL}}
279
+
280
+ Generated: {{TIMESTAMP}}
281
+
282
+ ---
283
+
284
+ ## Context
285
+ [Framework, test/lint commands, work items...]
286
+
287
+ ## Success Criteria
288
+ [Measurable outcomes...]
289
+
290
+ ## Acceptance Criteria (if applicable)
291
+ [Given/When/Then...]
292
+
293
+ ## Files to Modify
294
+ [Table...]
295
+
296
+ ## New Files to Create
297
+ [Table...]
298
+
299
+ ## Progress Tracking
300
+ [Instructions...]
301
+
302
+ ## Phases
303
+ [Red/Green/Refactor phases with code snippets...]
304
+
305
+ ## Final Verification
306
+ [Combined verification command...]
307
+
308
+ ## Completion
309
+ When ALL criteria met: <promise>DONE</promise>
310
+
311
+ ## Stuck Handling
312
+ [Framework-specific tips...]
313
+ ```
314
+
315
+ ### 11. Confirm with User
316
+
317
+ After generating:
318
+ - Show plan summary
319
+ - Ask: "Plan saved to `.claude/dev-plan.local.md`. Start with `/dev-loop --from-plan`?"
320
+
321
+ ---
322
+
323
+ ## Interactive Mode (--interactive)
324
+
325
+ When `--interactive` flag is present:
326
+
327
+ 1. "What's the current state of this feature?" (understand starting point)
328
+ 2. "Which specific components need to be created?" (scope)
329
+ 3. "Are there existing patterns I should follow?" (consistency)
330
+ 4. "What's the most important acceptance criterion?" (priority)
331
+ 5. "Any known edge cases or risks?" (robustness)
332
+
333
+ ---
334
+
335
+ ## Anti-Patterns to Avoid
336
+
337
+ | Don't | Do Instead |
338
+ |-------|------------|
339
+ | "Implement the feature" | "Create `lib/auth/login.dart` with ConsumerWidget" |
340
+ | "If it fails, fix it" | "If tests pass in Red phase, tests aren't specific enough" |
341
+ | Missing code snippets | Show actual structure with types and patterns |
342
+ | No file tables | Always list files to modify/create |
343
+ | "App works" | "Login returns JWT, logout invalidates token" |
344
+
345
+ ---
346
+
347
+ ## References
348
+
349
+ - `references/plan-template.md` - Full template with variables
350
+ - `references/good-example.md` - High-quality example plan
351
+ - `references/framework-patterns.md` - Framework-specific patterns
@@ -0,0 +1,15 @@
1
+ {
2
+ "description": "Dev loop Stop hook for autonomous iterative development",
3
+ "hooks": {
4
+ "Stop": [
5
+ {
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "${CLAUDE_PLUGIN_ROOT}/hooks/stop-hook.sh"
10
+ }
11
+ ]
12
+ }
13
+ ]
14
+ }
15
+ }
@@ -0,0 +1,178 @@
1
+ #!/bin/bash
2
+
3
+ # Dev Loop Stop Hook
4
+ # Based on Ralph Wiggum pattern from official plugin
5
+ # Prevents session exit when a dev-loop is active
6
+ # Feeds Claude's output back as input to continue the loop
7
+
8
+ set -euo pipefail
9
+
10
+ # Read hook input from stdin (advanced stop hook API)
11
+ HOOK_INPUT=$(cat)
12
+
13
+ # Check if dev-loop is active
14
+ STATE_FILE=".claude/dev-loop.local.md"
15
+
16
+ if [[ ! -f "$STATE_FILE" ]]; then
17
+ # No active loop - allow exit
18
+ exit 0
19
+ fi
20
+
21
+ # Parse markdown frontmatter (YAML between ---) and extract values
22
+ FRONTMATTER=$(sed -n '/^---$/,/^---$/{ /^---$/d; p; }' "$STATE_FILE")
23
+ ITERATION=$(echo "$FRONTMATTER" | grep '^iteration:' | sed 's/iteration: *//')
24
+ MAX_ITERATIONS=$(echo "$FRONTMATTER" | grep '^max_iterations:' | sed 's/max_iterations: *//')
25
+ # Extract completion_promise and strip surrounding quotes if present
26
+ COMPLETION_PROMISE=$(echo "$FRONTMATTER" | grep '^completion_promise:' | sed 's/completion_promise: *//' | sed 's/^"\(.*\)"$/\1/')
27
+
28
+ # Validate numeric fields before arithmetic operations
29
+ if [[ ! "$ITERATION" =~ ^[0-9]+$ ]]; then
30
+ echo "⚠️ Dev loop: State file corrupted" >&2
31
+ echo " File: $STATE_FILE" >&2
32
+ echo " Problem: 'iteration' field is not a valid number (got: '$ITERATION')" >&2
33
+ echo "" >&2
34
+ echo " This usually means the state file was manually edited or corrupted." >&2
35
+ echo " Dev loop is stopping. Run /dev-loop again to start fresh." >&2
36
+ rm "$STATE_FILE"
37
+ exit 0
38
+ fi
39
+
40
+ if [[ ! "$MAX_ITERATIONS" =~ ^[0-9]+$ ]]; then
41
+ echo "⚠️ Dev loop: State file corrupted" >&2
42
+ echo " File: $STATE_FILE" >&2
43
+ echo " Problem: 'max_iterations' field is not a valid number (got: '$MAX_ITERATIONS')" >&2
44
+ echo "" >&2
45
+ echo " This usually means the state file was manually edited or corrupted." >&2
46
+ echo " Dev loop is stopping. Run /dev-loop again to start fresh." >&2
47
+ rm "$STATE_FILE"
48
+ exit 0
49
+ fi
50
+
51
+ # Check if max iterations reached
52
+ if [[ $MAX_ITERATIONS -gt 0 ]] && [[ $ITERATION -ge $MAX_ITERATIONS ]]; then
53
+ echo "🛑 Dev loop: Max iterations ($MAX_ITERATIONS) reached."
54
+ rm "$STATE_FILE"
55
+ exit 0
56
+ fi
57
+
58
+ # Get transcript path from hook input
59
+ TRANSCRIPT_PATH=$(echo "$HOOK_INPUT" | jq -r '.transcript_path')
60
+
61
+ if [[ ! -f "$TRANSCRIPT_PATH" ]]; then
62
+ echo "⚠️ Dev loop: Transcript file not found" >&2
63
+ echo " Expected: $TRANSCRIPT_PATH" >&2
64
+ echo " This is unusual and may indicate a Claude Code internal issue." >&2
65
+ echo " Dev loop is stopping." >&2
66
+ rm "$STATE_FILE"
67
+ exit 0
68
+ fi
69
+
70
+ # Read last assistant message from transcript (JSONL format - one JSON per line)
71
+ # First check if there are any assistant messages
72
+ if ! grep -q '"role":"assistant"' "$TRANSCRIPT_PATH"; then
73
+ echo "⚠️ Dev loop: No assistant messages found in transcript" >&2
74
+ echo " Transcript: $TRANSCRIPT_PATH" >&2
75
+ echo " This is unusual and may indicate a transcript format issue" >&2
76
+ echo " Dev loop is stopping." >&2
77
+ rm "$STATE_FILE"
78
+ exit 0
79
+ fi
80
+
81
+ # Extract last assistant message with explicit error handling
82
+ LAST_LINE=$(grep '"role":"assistant"' "$TRANSCRIPT_PATH" | tail -1)
83
+ if [[ -z "$LAST_LINE" ]]; then
84
+ echo "⚠️ Dev loop: Failed to extract last assistant message" >&2
85
+ echo " Dev loop is stopping." >&2
86
+ rm "$STATE_FILE"
87
+ exit 0
88
+ fi
89
+
90
+ # Parse JSON with error handling
91
+ LAST_OUTPUT=$(echo "$LAST_LINE" | jq -r '
92
+ .message.content |
93
+ map(select(.type == "text")) |
94
+ map(.text) |
95
+ join("\n")
96
+ ' 2>&1)
97
+
98
+ # Check if jq succeeded
99
+ if [[ $? -ne 0 ]]; then
100
+ echo "⚠️ Dev loop: Failed to parse assistant message JSON" >&2
101
+ echo " Error: $LAST_OUTPUT" >&2
102
+ echo " This may indicate a transcript format issue" >&2
103
+ echo " Dev loop is stopping." >&2
104
+ rm "$STATE_FILE"
105
+ exit 0
106
+ fi
107
+
108
+ if [[ -z "$LAST_OUTPUT" ]]; then
109
+ echo "⚠️ Dev loop: Assistant message contained no text content" >&2
110
+ echo " Dev loop is stopping." >&2
111
+ rm "$STATE_FILE"
112
+ exit 0
113
+ fi
114
+
115
+ # Check for completion promise (only if set)
116
+ if [[ "$COMPLETION_PROMISE" != "null" ]] && [[ -n "$COMPLETION_PROMISE" ]]; then
117
+ # Extract text from <promise> tags using Perl for multiline support
118
+ # -0777 slurps entire input, s flag makes . match newlines
119
+ # .*? is non-greedy (takes FIRST tag), whitespace normalized
120
+ PROMISE_TEXT=$(echo "$LAST_OUTPUT" | perl -0777 -pe 's/.*?<promise>(.*?)<\/promise>.*/$1/s; s/^\s+|\s+$//g; s/\s+/ /g' 2>/dev/null || echo "")
121
+
122
+ # Use = for literal string comparison (not pattern matching)
123
+ # == in [[ ]] does glob pattern matching which breaks with *, ?, [ characters
124
+ if [[ -n "$PROMISE_TEXT" ]] && [[ "$PROMISE_TEXT" = "$COMPLETION_PROMISE" ]]; then
125
+ echo "✅ Dev loop: Detected <promise>$COMPLETION_PROMISE</promise>"
126
+ rm "$STATE_FILE"
127
+ exit 0
128
+ fi
129
+ fi
130
+
131
+ # Not complete - continue loop with SAME PROMPT
132
+ NEXT_ITERATION=$((ITERATION + 1))
133
+
134
+ # Extract prompt (everything after the closing ---)
135
+ # Skip first --- line, skip until second --- line, then print everything after
136
+ # Use i>=2 instead of i==2 to handle --- in prompt content
137
+ PROMPT_TEXT=$(awk '/^---$/{i++; next} i>=2' "$STATE_FILE")
138
+
139
+ if [[ -z "$PROMPT_TEXT" ]]; then
140
+ echo "⚠️ Dev loop: State file corrupted or incomplete" >&2
141
+ echo " File: $STATE_FILE" >&2
142
+ echo " Problem: No prompt text found" >&2
143
+ echo "" >&2
144
+ echo " This usually means:" >&2
145
+ echo " • State file was manually edited" >&2
146
+ echo " • File was corrupted during writing" >&2
147
+ echo "" >&2
148
+ echo " Dev loop is stopping. Run /dev-loop again to start fresh." >&2
149
+ rm "$STATE_FILE"
150
+ exit 0
151
+ fi
152
+
153
+ # Update iteration in frontmatter (portable across macOS and Linux)
154
+ # Create temp file, then atomically replace
155
+ TEMP_FILE="${STATE_FILE}.tmp.$$"
156
+ sed "s/^iteration: .*/iteration: $NEXT_ITERATION/" "$STATE_FILE" > "$TEMP_FILE"
157
+ mv "$TEMP_FILE" "$STATE_FILE"
158
+
159
+ # Build system message with iteration count and completion promise info
160
+ if [[ "$COMPLETION_PROMISE" != "null" ]] && [[ -n "$COMPLETION_PROMISE" ]]; then
161
+ SYSTEM_MSG="🔄 Dev loop iteration $NEXT_ITERATION of $MAX_ITERATIONS | To stop: output <promise>$COMPLETION_PROMISE</promise> (ONLY when task is COMPLETE - do not lie to exit!)"
162
+ else
163
+ SYSTEM_MSG="🔄 Dev loop iteration $NEXT_ITERATION | No completion promise set - loop runs until max iterations"
164
+ fi
165
+
166
+ # Output JSON to block the stop and feed prompt back
167
+ # The "reason" field contains the prompt that will be sent back to Claude
168
+ jq -n \
169
+ --arg prompt "$PROMPT_TEXT" \
170
+ --arg msg "$SYSTEM_MSG" \
171
+ '{
172
+ "decision": "block",
173
+ "reason": $prompt,
174
+ "systemMessage": $msg
175
+ }'
176
+
177
+ # Exit 0 for successful hook execution
178
+ exit 0