@c0x12c/ai-toolkit 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/.claude-plugin/marketplace.json +16 -0
  2. package/.claude-plugin/plugin.json +12 -0
  3. package/README.md +439 -0
  4. package/VERSION +1 -0
  5. package/agents/design-critic.md +127 -0
  6. package/agents/idea-killer.md +72 -0
  7. package/agents/infrastructure-expert.md +49 -0
  8. package/agents/micronaut-backend-expert.md +45 -0
  9. package/agents/phase-reviewer.md +150 -0
  10. package/agents/research-planner.md +70 -0
  11. package/agents/solution-architect-cto.md +49 -0
  12. package/agents/sre-architect.md +49 -0
  13. package/agents/team-coordinator.md +111 -0
  14. package/bin/cli.js +780 -0
  15. package/claude-md/00-header.md +39 -0
  16. package/claude-md/01-core.md +105 -0
  17. package/claude-md/05-database.md +20 -0
  18. package/claude-md/11-backend-micronaut.md +19 -0
  19. package/claude-md/20-frontend-react.md +44 -0
  20. package/claude-md/25-ux-design.md +56 -0
  21. package/claude-md/30-infrastructure.md +24 -0
  22. package/claude-md/30-project-mgmt.md +119 -0
  23. package/claude-md/40-product.md +39 -0
  24. package/claude-md/50-ops.md +34 -0
  25. package/claude-md/60-research.md +27 -0
  26. package/claude-md/90-footer.md +21 -0
  27. package/commands/spartan/brainstorm.md +134 -0
  28. package/commands/spartan/brownfield.md +157 -0
  29. package/commands/spartan/build.md +435 -0
  30. package/commands/spartan/careful.md +94 -0
  31. package/commands/spartan/commit-message.md +112 -0
  32. package/commands/spartan/content.md +17 -0
  33. package/commands/spartan/context-save.md +161 -0
  34. package/commands/spartan/contribute.md +140 -0
  35. package/commands/spartan/daily.md +42 -0
  36. package/commands/spartan/debug.md +308 -0
  37. package/commands/spartan/deep-dive.md +55 -0
  38. package/commands/spartan/deploy.md +207 -0
  39. package/commands/spartan/e2e.md +264 -0
  40. package/commands/spartan/env-setup.md +166 -0
  41. package/commands/spartan/epic.md +199 -0
  42. package/commands/spartan/fe-review.md +181 -0
  43. package/commands/spartan/figma-to-code.md +260 -0
  44. package/commands/spartan/forensics.md +46 -0
  45. package/commands/spartan/freeze.md +84 -0
  46. package/commands/spartan/fundraise.md +53 -0
  47. package/commands/spartan/gate-review.md +229 -0
  48. package/commands/spartan/gsd-upgrade.md +376 -0
  49. package/commands/spartan/guard.md +42 -0
  50. package/commands/spartan/init-project.md +178 -0
  51. package/commands/spartan/init-rules.md +298 -0
  52. package/commands/spartan/interview.md +154 -0
  53. package/commands/spartan/kickoff.md +73 -0
  54. package/commands/spartan/kotlin-service.md +109 -0
  55. package/commands/spartan/lean-canvas.md +222 -0
  56. package/commands/spartan/lint-rules.md +122 -0
  57. package/commands/spartan/map-codebase.md +124 -0
  58. package/commands/spartan/migration.md +82 -0
  59. package/commands/spartan/next-app.md +317 -0
  60. package/commands/spartan/next-feature.md +212 -0
  61. package/commands/spartan/onboard.md +326 -0
  62. package/commands/spartan/outreach.md +16 -0
  63. package/commands/spartan/phase.md +142 -0
  64. package/commands/spartan/pitch.md +18 -0
  65. package/commands/spartan/plan.md +210 -0
  66. package/commands/spartan/pr-ready.md +202 -0
  67. package/commands/spartan/project.md +106 -0
  68. package/commands/spartan/qa.md +222 -0
  69. package/commands/spartan/research.md +254 -0
  70. package/commands/spartan/review.md +132 -0
  71. package/commands/spartan/scan-rules.md +173 -0
  72. package/commands/spartan/sessions.md +143 -0
  73. package/commands/spartan/spec.md +131 -0
  74. package/commands/spartan/startup.md +257 -0
  75. package/commands/spartan/team.md +570 -0
  76. package/commands/spartan/teardown.md +161 -0
  77. package/commands/spartan/testcontainer.md +97 -0
  78. package/commands/spartan/tf-cost.md +123 -0
  79. package/commands/spartan/tf-deploy.md +116 -0
  80. package/commands/spartan/tf-drift.md +100 -0
  81. package/commands/spartan/tf-import.md +107 -0
  82. package/commands/spartan/tf-module.md +121 -0
  83. package/commands/spartan/tf-plan.md +100 -0
  84. package/commands/spartan/tf-review.md +106 -0
  85. package/commands/spartan/tf-scaffold.md +109 -0
  86. package/commands/spartan/tf-security.md +147 -0
  87. package/commands/spartan/think.md +221 -0
  88. package/commands/spartan/unfreeze.md +13 -0
  89. package/commands/spartan/update.md +134 -0
  90. package/commands/spartan/ux.md +1233 -0
  91. package/commands/spartan/validate.md +193 -0
  92. package/commands/spartan/web-to-prd.md +706 -0
  93. package/commands/spartan/workstreams.md +109 -0
  94. package/commands/spartan/write.md +16 -0
  95. package/commands/spartan.md +386 -0
  96. package/frameworks/00-framework-comparison-guide.md +317 -0
  97. package/frameworks/01-lean-canvas.md +196 -0
  98. package/frameworks/02-design-sprint.md +304 -0
  99. package/frameworks/03-foundation-sprint.md +337 -0
  100. package/frameworks/04-business-model-canvas.md +391 -0
  101. package/frameworks/05-customer-development.md +426 -0
  102. package/frameworks/06-jobs-to-be-done.md +358 -0
  103. package/frameworks/07-mom-test.md +392 -0
  104. package/frameworks/08-value-proposition-canvas.md +488 -0
  105. package/frameworks/09-javelin-board.md +428 -0
  106. package/frameworks/10-build-measure-learn.md +467 -0
  107. package/frameworks/11-mvp-approaches.md +533 -0
  108. package/frameworks/think-before-build.md +593 -0
  109. package/lib/assembler.js +197 -0
  110. package/lib/assembler.test.js +159 -0
  111. package/lib/detector.js +166 -0
  112. package/lib/detector.test.js +221 -0
  113. package/lib/packs.js +16 -0
  114. package/lib/resolver.js +272 -0
  115. package/lib/resolver.test.js +298 -0
  116. package/lib/worktree.sh +104 -0
  117. package/package.json +50 -0
  118. package/packs/backend-micronaut.yaml +35 -0
  119. package/packs/backend-nodejs.yaml +15 -0
  120. package/packs/backend-python.yaml +15 -0
  121. package/packs/core.yaml +37 -0
  122. package/packs/database.yaml +21 -0
  123. package/packs/frontend-react.yaml +24 -0
  124. package/packs/infrastructure.yaml +40 -0
  125. package/packs/ops.yaml +16 -0
  126. package/packs/packs.compiled.json +371 -0
  127. package/packs/product.yaml +22 -0
  128. package/packs/project-mgmt.yaml +24 -0
  129. package/packs/research.yaml +39 -0
  130. package/packs/shared-backend.yaml +14 -0
  131. package/packs/ux-design.yaml +21 -0
  132. package/rules/backend-micronaut/API_DESIGN.md +313 -0
  133. package/rules/backend-micronaut/BATCH_PROCESSING.md +92 -0
  134. package/rules/backend-micronaut/CONTROLLERS.md +388 -0
  135. package/rules/backend-micronaut/KOTLIN.md +414 -0
  136. package/rules/backend-micronaut/RETROFIT_PLACEMENT.md +290 -0
  137. package/rules/backend-micronaut/SERVICES_AND_BEANS.md +325 -0
  138. package/rules/core/NAMING_CONVENTIONS.md +208 -0
  139. package/rules/core/SKILL_AUTHORING.md +174 -0
  140. package/rules/core/TIMEZONE.md +316 -0
  141. package/rules/database/ORM_AND_REPO.md +289 -0
  142. package/rules/database/SCHEMA.md +146 -0
  143. package/rules/database/TRANSACTIONS.md +311 -0
  144. package/rules/frontend-react/FRONTEND.md +344 -0
  145. package/rules/infrastructure/MODULES.md +260 -0
  146. package/rules/infrastructure/NAMING.md +196 -0
  147. package/rules/infrastructure/PROVIDERS.md +309 -0
  148. package/rules/infrastructure/SECURITY.md +310 -0
  149. package/rules/infrastructure/STATE_AND_BACKEND.md +237 -0
  150. package/rules/infrastructure/STRUCTURE.md +234 -0
  151. package/rules/infrastructure/VARIABLES.md +285 -0
  152. package/rules/shared-backend/ARCHITECTURE.md +46 -0
  153. package/rules/ux-design/DESIGN_PROCESS.md +176 -0
  154. package/skills/api-endpoint-creator/SKILL.md +455 -0
  155. package/skills/api-endpoint-creator/error-handling-guide.md +244 -0
  156. package/skills/api-endpoint-creator/examples.md +522 -0
  157. package/skills/api-endpoint-creator/testing-patterns.md +302 -0
  158. package/skills/article-writing/SKILL.md +109 -0
  159. package/skills/article-writing/examples.md +59 -0
  160. package/skills/backend-api-design/SKILL.md +84 -0
  161. package/skills/backend-api-design/code-patterns.md +138 -0
  162. package/skills/brainstorm/SKILL.md +95 -0
  163. package/skills/browser-qa/SKILL.md +87 -0
  164. package/skills/browser-qa/playwright-snippets.md +110 -0
  165. package/skills/ci-cd-patterns/SKILL.md +108 -0
  166. package/skills/ci-cd-patterns/workflows.md +149 -0
  167. package/skills/competitive-teardown/SKILL.md +93 -0
  168. package/skills/competitive-teardown/example-analysis.md +50 -0
  169. package/skills/content-engine/SKILL.md +131 -0
  170. package/skills/content-engine/examples.md +72 -0
  171. package/skills/database-patterns/SKILL.md +72 -0
  172. package/skills/database-patterns/code-templates.md +114 -0
  173. package/skills/database-table-creator/SKILL.md +141 -0
  174. package/skills/database-table-creator/examples.md +552 -0
  175. package/skills/database-table-creator/kotlin-templates.md +400 -0
  176. package/skills/database-table-creator/migration-template.sql +68 -0
  177. package/skills/database-table-creator/validation-checklist.md +337 -0
  178. package/skills/deep-research/SKILL.md +80 -0
  179. package/skills/design-intelligence/SKILL.md +268 -0
  180. package/skills/design-workflow/SKILL.md +127 -0
  181. package/skills/design-workflow/checklists.md +45 -0
  182. package/skills/idea-validation/SKILL.md +129 -0
  183. package/skills/idea-validation/example-report.md +50 -0
  184. package/skills/investor-materials/SKILL.md +122 -0
  185. package/skills/investor-materials/example-outline.md +70 -0
  186. package/skills/investor-outreach/SKILL.md +112 -0
  187. package/skills/investor-outreach/examples.md +76 -0
  188. package/skills/kotlin-best-practices/SKILL.md +58 -0
  189. package/skills/kotlin-best-practices/code-patterns.md +132 -0
  190. package/skills/market-research/SKILL.md +99 -0
  191. package/skills/security-checklist/SKILL.md +65 -0
  192. package/skills/security-checklist/audit-reference.md +95 -0
  193. package/skills/service-debugging/SKILL.md +116 -0
  194. package/skills/service-debugging/common-issues.md +65 -0
  195. package/skills/startup-pipeline/SKILL.md +152 -0
  196. package/skills/terraform-best-practices/SKILL.md +244 -0
  197. package/skills/terraform-module-creator/SKILL.md +284 -0
  198. package/skills/terraform-review/SKILL.md +222 -0
  199. package/skills/terraform-security-audit/SKILL.md +280 -0
  200. package/skills/terraform-service-scaffold/SKILL.md +574 -0
  201. package/skills/testing-strategies/SKILL.md +116 -0
  202. package/skills/testing-strategies/examples.md +103 -0
  203. package/skills/testing-strategies/integration-test-setup.md +71 -0
  204. package/skills/ui-ux-pro-max/SKILL.md +238 -0
  205. package/skills/ui-ux-pro-max/data/charts.csv +26 -0
  206. package/skills/ui-ux-pro-max/data/colors.csv +97 -0
  207. package/skills/ui-ux-pro-max/data/icons.csv +101 -0
  208. package/skills/ui-ux-pro-max/data/landing.csv +31 -0
  209. package/skills/ui-ux-pro-max/data/products.csv +97 -0
  210. package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  211. package/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  212. package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  213. package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  214. package/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  215. package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  216. package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  217. package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  218. package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  219. package/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  220. package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  221. package/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  222. package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  223. package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  224. package/skills/ui-ux-pro-max/data/styles.csv +68 -0
  225. package/skills/ui-ux-pro-max/data/typography.csv +58 -0
  226. package/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  227. package/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  228. package/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  229. package/skills/ui-ux-pro-max/python-setup.md +146 -0
  230. package/skills/ui-ux-pro-max/scripts/core.py +253 -0
  231. package/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
  232. package/skills/ui-ux-pro-max/scripts/search.py +114 -0
  233. package/skills/web-to-prd/SKILL.md +478 -0
  234. package/templates/build-config.yaml +44 -0
  235. package/templates/commands-config.yaml +55 -0
  236. package/templates/competitor-analysis.md +60 -0
  237. package/templates/content/AGENT_TEMPLATE.md +47 -0
  238. package/templates/content/COMMAND_TEMPLATE.md +27 -0
  239. package/templates/content/RULE_TEMPLATE.md +40 -0
  240. package/templates/content/SKILL_TEMPLATE.md +41 -0
  241. package/templates/design-config.md +105 -0
  242. package/templates/design-doc.md +207 -0
  243. package/templates/epic.md +100 -0
  244. package/templates/feature-spec.md +181 -0
  245. package/templates/idea-canvas.md +47 -0
  246. package/templates/implementation-plan.md +159 -0
  247. package/templates/prd-template.md +86 -0
  248. package/templates/preamble.md +89 -0
  249. package/templates/project-readme.md +35 -0
  250. package/templates/quality-gates.md +230 -0
  251. package/templates/spartan-config.yaml +164 -0
  252. package/templates/user-interview.md +69 -0
  253. package/templates/validation-checklist.md +108 -0
  254. package/templates/workflow-backend-micronaut.md +409 -0
  255. package/templates/workflow-frontend-react.md +233 -0
@@ -0,0 +1,199 @@
1
+ ---
2
+ name: spartan:epic
3
+ description: Define an epic — break big work into ordered features with specs and plans
4
+ argument-hint: "[epic name]"
5
+ preamble-tier: 3
6
+ ---
7
+
8
+ # Epic: {{ args[0] | default: "unnamed epic" }}
9
+
10
+ You are running the **Epic workflow** — break a big piece of work into ordered features, each of which goes through the full spec → plan → build cycle.
11
+
12
+ ```
13
+ ► Epic → Spec → [Design] → Plan → Build → Review
14
+
15
+ start
16
+ ```
17
+
18
+ The epic gets saved to `.planning/epics/{{ args[0] | default: "epic-name" }}.md`.
19
+
20
+ ---
21
+
22
+ ## Step 0: Setup
23
+
24
+ ```bash
25
+ mkdir -p .planning/epics
26
+ ls .planning/epics/{{ args[0] | default: "epic-name" }}.md 2>/dev/null
27
+ ```
28
+
29
+ If it exists, ask:
30
+ > "An epic for **{{ args[0] }}** already exists. Want to **update** it or **start fresh**?"
31
+ >
32
+ > - A) Update — I'll show the current epic and we'll revise
33
+ > - B) Start fresh — overwrite
34
+
35
+ ---
36
+
37
+ ## Step 1: Understand the Big Picture
38
+
39
+ Ask these questions **one at a time**:
40
+
41
+ 1. **"What are we building and why?"** — Get the big picture in 2-3 sentences. What outcome does this epic deliver?
42
+
43
+ 2. **"How do we know it's done?"** — Get 2-3 concrete success criteria. Not vague ("users are happy") — specific ("users can create and manage profiles").
44
+
45
+ 3. **"What are the main pieces?"** — Have the user list the features they can think of. Don't worry about order yet.
46
+
47
+ 4. **"Anything risky or tricky?"** — What could block the whole epic?
48
+
49
+ ---
50
+
51
+ ## Step 2: Break into Features
52
+
53
+ Take the user's feature list and organize it:
54
+
55
+ 1. **Order by dependency.** Feature 2 shouldn't need Feature 5.
56
+ 2. **Keep features small.** Each should be 1-3 days of work. If one is bigger, split it.
57
+ 3. **Write a brief for each.** 2-3 sentences: what it does, why it matters, rough scope.
58
+
59
+ Present as a table:
60
+
61
+ ```markdown
62
+ | # | Feature | Depends On | Effort |
63
+ |---|---------|------------|--------|
64
+ | 1 | [name] | — | [S/M/L] |
65
+ | 2 | [name] | #1 | [S/M/L] |
66
+ | 3 | [name] | #1, #2 | [S/M/L] |
67
+ ```
68
+
69
+ Ask:
70
+ > "Here's how I'd order the features. Anything to change?"
71
+ >
72
+ > **Auto mode on?** → Show the order and continue.
73
+
74
+ ---
75
+
76
+ ## Step 3: Fill the Epic Document
77
+
78
+ Use the `epic.md` template structure:
79
+
80
+ ```markdown
81
+ # Epic: {{ args[0] }}
82
+
83
+ **Created**: [today's date]
84
+ **Status**: planning
85
+ **Owner**: [user's name or "team"]
86
+
87
+ ---
88
+
89
+ ## Why
90
+
91
+ [2-3 sentences from Step 1, question 1]
92
+
93
+ ---
94
+
95
+ ## Success Criteria
96
+
97
+ - [ ] [from Step 1, question 2]
98
+ - [ ] [criteria 2]
99
+ - [ ] [criteria 3]
100
+
101
+ ---
102
+
103
+ ## Features
104
+
105
+ | # | Feature | Status | Spec | Plan | Depends On |
106
+ |---|---------|--------|------|------|------------|
107
+ | 1 | [name] | todo | — | — | — |
108
+ | 2 | [name] | todo | — | — | #1 |
109
+ | 3 | [name] | todo | — | — | #1, #2 |
110
+
111
+ ---
112
+
113
+ ## Feature Briefs
114
+
115
+ ### Feature 1: [name]
116
+ [2-3 sentences from Step 2]
117
+
118
+ ### Feature 2: [name]
119
+ [2-3 sentences]
120
+
121
+ ---
122
+
123
+ ## Risks
124
+
125
+ - [from Step 1, question 4]
126
+
127
+ ---
128
+
129
+ ## Notes
130
+
131
+ - [anything else]
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Step 4: Save and Confirm
137
+
138
+ Save the epic to `.planning/epics/{{ args[0] | default: "epic-name" }}.md`.
139
+
140
+ Then tell the user:
141
+
142
+ > "Epic saved to `.planning/epics/{{ args[0] }}.md` with [N] features."
143
+ >
144
+ > **Next steps:**
145
+ >
146
+ > 1. Write specs for each feature (can do multiple before building):
147
+ > ```
148
+ > /spartan:spec [feature-1]
149
+ > /spartan:spec [feature-2]
150
+ > /spartan:ux prototype [feature-2] ← if it has UI work
151
+ > /spartan:spec [feature-3]
152
+ > ```
153
+ >
154
+ > 2. When specs are ready, build the whole epic at once:
155
+ > ```
156
+ > /spartan:build {{ args[0] }} ← builds all ready features, one branch, one PR
157
+ > ```
158
+ >
159
+ > Build auto-detects the epic, plans all features together, parallelizes independent ones with Agent Teams, and ships one PR.
160
+ >
161
+ > **Start with:** `/spartan:spec [first-feature-name]`
162
+
163
+ ---
164
+
165
+ ## Tracking Progress
166
+
167
+ When a spec or plan is written for a feature, update the epic's Features table:
168
+
169
+ | Status change | When |
170
+ |---|---|
171
+ | `todo` → `spec` | After `/spartan:spec` saves |
172
+ | `spec` → `planned` | After `/spartan:plan` saves |
173
+ | `planned` → `building` | After `/spartan:build` starts |
174
+ | `building` → `done` | After PR merged |
175
+ | any → `skipped` | User decides to skip |
176
+
177
+ The user can check progress anytime by reading `.planning/epics/{{ args[0] }}.md`.
178
+
179
+ ---
180
+
181
+ ## When NOT to Use This
182
+
183
+ | Situation | Use instead |
184
+ |---|---|
185
+ | Single feature | `/spartan:spec` → `/spartan:plan` → `/spartan:build` |
186
+ | Multi-week project with milestones | `/spartan:project new` (GSD lifecycle) |
187
+
188
+ Epics sit between a single feature (too small) and full GSD projects (too big). Use them for a batch of 3-8 related features.
189
+
190
+ ---
191
+
192
+ ## Rules
193
+
194
+ - **Ask questions one at a time.** Don't dump everything at once.
195
+ - **Keep features small.** If a feature is > 3 days, split it.
196
+ - **Order by dependency.** Feature N+1 can depend on Feature N, not the other way around.
197
+ - **Each feature gets its own spec.** The epic is the container, not the spec.
198
+ - **Update the epic as features progress.** Keep the Features table current.
199
+ - **Auto mode on?** → Skip confirmations, save directly.
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: spartan:fe-review
3
+ description: Thorough PR review for frontend code — loads rules from config, defaults to React/Next.js conventions
4
+ argument-hint: "[optional: PR title or focus area]"
5
+ ---
6
+
7
+ # Frontend PR Review: {{ args[0] | default: "current branch" }}
8
+
9
+ Performing a thorough review of frontend changes.
10
+
11
+ ## Step 0: Load rules
12
+
13
+ ```bash
14
+ # Check for project config
15
+ cat .spartan/config.yaml 2>/dev/null
16
+
17
+ # Get changed frontend files
18
+ git diff main...HEAD --name-only | grep -E '\.(tsx?|jsx?|vue|svelte|css)$'
19
+ ```
20
+
21
+ **If `.spartan/config.yaml` exists:**
22
+ - Read `rules.frontend` + `rules.shared` — check against these rules
23
+ - Read `review-stages` — only run enabled stages
24
+ - If `conditional-rules` is set, match rules to changed files
25
+
26
+ **If no config:** Use the default React/Next.js checklist below + scan for `rules/frontend-react/` or `~/.claude/rules/frontend-react/`.
27
+
28
+ Read all matched rule files before reviewing code.
29
+
30
+ ---
31
+
32
+ Run `git diff main...HEAD` and analyze all modified frontend files.
33
+
34
+ ## Stage 1: App Router Conventions
35
+
36
+ - [ ] New pages use **Server Components by default**
37
+ - Only `'use client'` when strictly needed (event handlers, browser APIs, stateful UI)
38
+ - No `'use client'` just to use async/await (Server Components handle async natively)
39
+ - [ ] Data fetching is in Server Components, not `useEffect`
40
+ - [ ] Mutations use **Server Actions** (`'use server'`), not client-side fetch to API routes
41
+ - [ ] `revalidatePath` or `revalidateTag` called after mutations (not manual router.refresh())
42
+ - [ ] Route groups `(group)/` used to avoid URL pollution when grouping by auth/layout
43
+ - [ ] Dynamic segments typed correctly: `{ params: { id: string } }`
44
+ - [ ] `loading.tsx` and `error.tsx` present for routes with async data
45
+
46
+ ```bash
47
+ # Check for anti-patterns
48
+ git diff main...HEAD -- "*.tsx" "*.ts" | grep "'use client'" | wc -l # count client components
49
+ git diff main...HEAD -- "*.tsx" | grep "useEffect.*fetch\|axios\|fetch(" # data fetching in effects
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Stage 2: TypeScript Strictness
55
+
56
+ - [ ] No `any` types — use `unknown` + type guard if uncertain
57
+ - [ ] API response types defined and mirror Kotlin DTOs
58
+ - [ ] Zod validation used for runtime API response checking
59
+ - [ ] No `!` non-null assertions without comment explaining why it's safe
60
+ - [ ] Props interfaces defined (not inline objects for complex shapes)
61
+ - [ ] Return types explicit on exported functions
62
+
63
+ ```bash
64
+ # Check for type escape hatches
65
+ git diff main...HEAD -- "*.tsx" "*.ts" | grep ": any\|as any\|@ts-ignore\|@ts-expect"
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Stage 3: Performance
71
+
72
+ - [ ] Images use `next/image` (not `<img>`)
73
+ - [ ] Links use `next/link` (not `<a href>`)
74
+ - [ ] Heavy components lazy-loaded with `dynamic()` if not needed on initial paint
75
+ - [ ] No unnecessary `'use client'` that pushes rendering to browser
76
+ - [ ] `fetch` calls in Server Components use `next: { revalidate }` or `next: { tags }` appropriately
77
+ - [ ] No fetching the same data multiple times (Request Memoization across same render)
78
+
79
+ ---
80
+
81
+ ## Stage 4: Component Quality
82
+
83
+ - [ ] Components are small and single-purpose (< ~100 lines ideally)
84
+ - [ ] No business logic in UI components — logic lives in Server Actions or custom hooks
85
+ - [ ] Custom hooks extracted for reusable client-side logic (`useFeature.ts`)
86
+ - [ ] Props destructured in function signature
87
+ - [ ] No prop drilling deeper than 2 levels (consider composition or Context)
88
+ - [ ] `key` prop on list items uses stable ID, not array index
89
+
90
+ ---
91
+
92
+ ## Stage 5: Test Coverage
93
+
94
+ - [ ] New components have test files (co-located: `Component.test.tsx`)
95
+ - [ ] Tests use `@testing-library/react` — no shallow rendering
96
+ - [ ] Tests verify **behavior**, not implementation details
97
+ - [ ] Server Actions tested with mocked dependencies
98
+ - [ ] No `querySelector` in tests — use accessible queries (`getByRole`, `getByLabelText`)
99
+
100
+ ```bash
101
+ # Find components without tests
102
+ git diff main...HEAD --name-only | grep "\.tsx$" | while read f; do
103
+ testfile="${f%.tsx}.test.tsx"
104
+ [[ ! -f "$testfile" ]] && echo "⚠️ Missing test: $testfile"
105
+ done
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Stage 6: Accessibility
111
+
112
+ - [ ] Interactive elements are semantic HTML (`<button>`, not `<div onClick>`)
113
+ - [ ] Form inputs have associated `<label>` (htmlFor + id, or `aria-label`)
114
+ - [ ] Images have meaningful `alt` text (empty `alt=""` for decorative)
115
+ - [ ] Color is not the only way to convey information
116
+ - [ ] Focus management handled on modal/dialog open/close
117
+
118
+ ---
119
+
120
+ ## Stage 7: Full-Stack Contract (FE ↔ Kotlin BE)
121
+
122
+ - [ ] TypeScript types in `_types/` match Kotlin DTOs exactly
123
+ - [ ] API base URL from env var (`process.env.NEXT_PUBLIC_API_URL`), never hardcoded
124
+ - [ ] Error handling for failed API calls — user-visible error state exists
125
+ - [ ] Loading states present for async operations
126
+ - [ ] No sensitive data logged to console
127
+
128
+ ---
129
+
130
+ ## Stage 8: Design Token Compliance
131
+
132
+ **Only runs if `.planning/design/system/tokens.md` or `.planning/design-config.md` exists.**
133
+
134
+ Read the design tokens file first. Then check every changed frontend file:
135
+
136
+ - [ ] Colors use token names or CSS variables, not hardcoded hex or Tailwind defaults
137
+ - Search for: raw hex values (#xxx), `bg-blue-*`, `bg-purple-*`, `text-gray-*`
138
+ - Each match: is this value in the token list? If not → flag as **critical**
139
+ - [ ] Font family matches design config, not generic fallbacks
140
+ - Search for: `font-sans`, `Inter`, `Roboto`, `Arial`, `system-ui`
141
+ - If project font is different → flag as **critical**
142
+ - [ ] Spacing uses the token scale, not arbitrary values
143
+ - Random values like `p-[13px]` or `mt-[7px]` → flag as **warning**
144
+ - [ ] Border radius matches token definitions
145
+ - [ ] New components reference the design system, not reinventing styles
146
+
147
+ ```bash
148
+ # Quick scan for hardcoded colors (should be tokens)
149
+ git diff main...HEAD -- "*.tsx" "*.ts" "*.css" | grep -E '#[0-9a-fA-F]{3,8}|bg-(blue|red|green|purple|pink|indigo|violet)-[0-9]' | head -20
150
+
151
+ # Quick scan for generic fonts
152
+ git diff main...HEAD -- "*.tsx" "*.ts" "*.css" | grep -E "font-sans|Inter|Roboto|Arial|system-ui" | head -10
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Output Format
158
+
159
+ ```markdown
160
+ ## Frontend PR Review: [title]
161
+
162
+ ### Approved / Needs Changes / Blocked
163
+
164
+ ### Critical Issues (must fix before merge)
165
+ - [issue with file:line reference and suggested fix]
166
+
167
+ ### Suggestions (improve code quality)
168
+ - [suggestion]
169
+
170
+ ### Performance Notes
171
+ - [any perf observations]
172
+
173
+ ### Accessibility Notes
174
+ - [any a11y issues]
175
+
176
+ ### Praise
177
+ - [what was done well — be specific]
178
+
179
+ ### Verdict
180
+ [recommendation + any conditions]
181
+ ```
@@ -0,0 +1,260 @@
1
+ ---
2
+ name: spartan:figma-to-code
3
+ description: Convert a Figma design screen to production code using Figma MCP. Manages token budget (one screen per session), extracts design tokens, and generates typed React components following App Router conventions.
4
+ argument-hint: "[figma URL or screen name] [optional: component | page | feature]"
5
+ ---
6
+
7
+ # Figma → Code: {{ args[0] }}
8
+ Output type: {{ args[1] | default: "feature" }}
9
+
10
+ You are converting a Figma design into production React/Next.js code using **Figma MCP**.
11
+
12
+ **Critical constraint:** Figma MCP responses are ~13k tokens each. Budget **one screen per Claude Code session** to avoid context exhaustion. If more screens are needed, use `/spartan:context-save` after each screen.
13
+
14
+ ---
15
+
16
+ ## Phase 0: Check for existing design tokens (silent)
17
+
18
+ ```bash
19
+ ls .planning/design/system/tokens.md .planning/design-config.md 2>/dev/null
20
+ ```
21
+
22
+ If design tokens already exist, read them FIRST. When extracting from Figma:
23
+ - **MERGE** Figma colors with existing tokens — don't create a second conflicting token set
24
+ - Use existing token NAMES (e.g., `--color-primary`) even if Figma uses different hex values
25
+ - If Figma colors differ from tokens, flag the mismatch and ask the user which to keep
26
+ - Any NEW tokens from Figma get added to the existing file, not written to a separate one
27
+
28
+ If NO tokens exist, proceed normally — extract from Figma and create new tokens.
29
+
30
+ ---
31
+
32
+ ## Phase 1: Extract Design Data (single MCP call)
33
+
34
+ Call Figma MCP to get the screen data:
35
+
36
+ ```
37
+ Use the Figma MCP tool to read the design at: {{ args[0] }}
38
+ Extract: layout structure, colors, typography, spacing, component hierarchy
39
+ ```
40
+
41
+ **Parse and organize immediately** — don't make a second MCP call unless absolutely necessary.
42
+
43
+ Extract into a structured brief:
44
+
45
+ ```markdown
46
+ ## Design Brief: [screen name]
47
+
48
+ ### Layout
49
+ - Container: [width, padding, layout direction]
50
+ - Grid: [columns, gap, breakpoints if visible]
51
+
52
+ ### Color Tokens
53
+ - Primary: [hex]
54
+ - Secondary: [hex]
55
+ - Background: [hex]
56
+ - Text primary: [hex]
57
+ - Text secondary: [hex]
58
+ - Border: [hex]
59
+ - [any other colors]
60
+
61
+ ### Typography
62
+ - Heading 1: [font, weight, size, line-height, color]
63
+ - Heading 2: [font, weight, size, line-height, color]
64
+ - Body: [font, weight, size, line-height, color]
65
+ - Caption: [font, weight, size, line-height, color]
66
+
67
+ ### Spacing Scale
68
+ - [extract consistent spacing values: 4, 8, 12, 16, 24, 32, 48, etc.]
69
+
70
+ ### Components Identified
71
+ 1. [ComponentName] — [brief description, interactive? server/client?]
72
+ 2. [ComponentName] — ...
73
+
74
+ ### Assets Needed
75
+ - Icons: [list]
76
+ - Images: [list — placeholder or Cloudinary URLs]
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Phase 2: Map to Code Architecture
82
+
83
+ Based on output type ({{ args[1] | default: "feature" }}):
84
+
85
+ **If `component`:**
86
+ ```
87
+ components/[ComponentName]/
88
+ [ComponentName].tsx ← Server or Client component
89
+ [ComponentName].test.tsx ← Tests
90
+ index.ts ← Re-export
91
+ ```
92
+
93
+ **If `page`:**
94
+ ```
95
+ app/[route]/
96
+ page.tsx ← Server Component
97
+ loading.tsx ← Skeleton matching Figma layout
98
+ _components/ ← Page-local components
99
+ ```
100
+
101
+ **If `feature` (default):**
102
+ ```
103
+ app/[feature]/
104
+ page.tsx ← Server Component, data fetching
105
+ loading.tsx ← Skeleton from Figma layout
106
+ error.tsx ← Error boundary
107
+ _components/
108
+ [Component1].tsx
109
+ [Component2].tsx
110
+ _actions/ ← Server Actions for mutations
111
+ _types/
112
+ [feature].types.ts ← Types mirroring Kotlin DTOs
113
+ ```
114
+
115
+ **Decision: Server vs Client Component**
116
+ - Default = Server Component
117
+ - `'use client'` ONLY if: onClick handlers, useState, browser APIs, animations
118
+ - Interactive parts should be the smallest possible client component, wrapped in a server component parent
119
+
120
+ ---
121
+
122
+ ## Phase 3: Generate Design Tokens
123
+
124
+ Create or update `src/lib/design-tokens.ts`:
125
+
126
+ ```typescript
127
+ // Auto-generated from Figma — [screen name] — [date]
128
+ // Do NOT edit manually. Re-run /spartan:figma-to-code to update.
129
+
130
+ export const colors = {
131
+ primary: '[hex]',
132
+ secondary: '[hex]',
133
+ background: '[hex]',
134
+ surface: '[hex]',
135
+ textPrimary: '[hex]',
136
+ textSecondary: '[hex]',
137
+ border: '[hex]',
138
+ // ...
139
+ } as const
140
+
141
+ export const typography = {
142
+ h1: 'text-[size] font-[weight] leading-[lh]', // Tailwind classes
143
+ h2: 'text-[size] font-[weight] leading-[lh]',
144
+ body: 'text-[size] font-[weight] leading-[lh]',
145
+ caption: 'text-[size] font-[weight] leading-[lh]',
146
+ } as const
147
+
148
+ export const spacing = {
149
+ xs: '[value]', // e.g., '0.25rem'
150
+ sm: '[value]',
151
+ md: '[value]',
152
+ lg: '[value]',
153
+ xl: '[value]',
154
+ } as const
155
+ ```
156
+
157
+ If `tailwind.config.ts` exists, extend it with these tokens instead of a separate file.
158
+
159
+ ---
160
+
161
+ ## Phase 4: Generate Components (TDD)
162
+
163
+ For each component identified in Phase 1:
164
+
165
+ ### 4a. Write test FIRST
166
+
167
+ ```typescript
168
+ // [ComponentName].test.tsx
169
+ import { render, screen } from '@testing-library/react'
170
+ import { describe, it, expect } from 'vitest'
171
+ import { ComponentName } from './ComponentName'
172
+
173
+ describe('ComponentName', () => {
174
+ it('renders with required props', () => {
175
+ render(<ComponentName {...mockProps} />)
176
+ expect(screen.getByRole('[role]')).toBeInTheDocument()
177
+ })
178
+
179
+ it('matches Figma layout structure', () => {
180
+ // Test key layout assertions from design
181
+ })
182
+ })
183
+ ```
184
+
185
+ ### 4b. Implement component
186
+
187
+ ```typescript
188
+ // [ComponentName].tsx
189
+ // Figma source: [screen name] > [layer path]
190
+
191
+ interface ComponentNameProps {
192
+ // typed from Figma + Kotlin DTO
193
+ }
194
+
195
+ export function ComponentName({ ...props }: ComponentNameProps) {
196
+ return (
197
+ // Tailwind classes derived from Figma tokens
198
+ // Use design-tokens.ts for colors/typography
199
+ )
200
+ }
201
+ ```
202
+
203
+ ### 4c. Verify test passes
204
+
205
+ ```bash
206
+ npm test -- --run [ComponentName]
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Phase 5: Loading Skeleton
212
+
213
+ Generate `loading.tsx` that matches the Figma layout with skeleton placeholders:
214
+
215
+ ```typescript
216
+ // loading.tsx — skeleton matching [screen name] layout
217
+ export default function Loading() {
218
+ return (
219
+ <div className="animate-pulse">
220
+ {/* Mirror exact Figma layout with gray placeholder blocks */}
221
+ </div>
222
+ )
223
+ }
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Phase 6: Handoff Summary
229
+
230
+ ```markdown
231
+ ## Figma → Code Complete: [screen name]
232
+
233
+ ### Files Created
234
+ - [list all files]
235
+
236
+ ### Design Tokens
237
+ - Colors: [N] tokens extracted
238
+ - Typography: [N] styles mapped
239
+ - Spacing: [scale]
240
+
241
+ ### Components
242
+ - [ComponentName]: Server/Client — [status]
243
+
244
+ ### Figma Fidelity Notes
245
+ - [any deviations from design and why]
246
+ - [responsive adaptations made]
247
+
248
+ ### Next Steps
249
+ - [ ] Connect to real API data (replace mock props)
250
+ - [ ] Add remaining screens: [list if multi-screen feature]
251
+ - [ ] Review with designer for pixel accuracy
252
+
253
+ ### Token Budget Used
254
+ - Figma MCP calls: [N] (~[N*13]k tokens)
255
+ - Remaining context: [estimate]
256
+ - Need more screens? → `/spartan:context-save` first
257
+ ```
258
+
259
+ If context is above 40% after this screen, proactively suggest:
260
+ "Context at ~[X]%. If you need another screen, I recommend `/spartan:context-save` now, then resume in a fresh session."
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: spartan:forensics
3
+ description: Post-mortem investigation for failed or stuck workflows. Analyzes git history, planning artifacts, and project state to diagnose what went wrong. Use when a phase failed, work got stuck, or you need to understand why something broke.
4
+ argument-hint: "\"problem description\""
5
+ ---
6
+
7
+ # Forensics Investigation
8
+
9
+ You are running a post-mortem investigation using GSD forensics under the hood.
10
+ The user does NOT need to know about `/gsd:*` commands — everything runs through `/spartan:*`.
11
+
12
+ ---
13
+
14
+ ## What this does
15
+
16
+ Forensics analyzes your project's history to figure out **what went wrong** and **why**:
17
+ - Git commit history and branch state
18
+ - Planning artifacts (`.planning/` files)
19
+ - Phase execution logs and deviations
20
+ - State inconsistencies
21
+
22
+ This is a **diagnostic tool** — it reads and analyzes, it does not modify anything.
23
+
24
+ ---
25
+
26
+ ## Run the investigation
27
+
28
+ **Run:** `/gsd:forensics {{ args | join: " " }}`
29
+
30
+ {% if args[0] %}
31
+ Investigating: **{{ args | join: " " }}**
32
+ {% else %}
33
+ No problem description provided. Claude will analyze the current project state and ask what went wrong.
34
+ {% endif %}
35
+
36
+ ---
37
+
38
+ ## After the investigation
39
+
40
+ Present findings using `/spartan:` commands for next steps:
41
+ - Need to re-plan a phase? → "Run `/spartan:phase plan N`"
42
+ - Need to re-execute? → "Run `/spartan:phase execute N`"
43
+ - Need to debug a specific issue? → "Run `/spartan:debug \"symptom\"`"
44
+ - Project state is corrupted? → Consider `/spartan:project status` to assess
45
+
46
+ **Never suggest `/gsd:*` commands to the user.** Always translate to `/spartan:*`.