@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,435 @@
1
+ ---
2
+ name: spartan:build
3
+ description: "Build a new feature end-to-end — backend, frontend, or full-stack with auto-detection"
4
+ argument-hint: "[backend|frontend] [feature description]"
5
+ preamble-tier: 4
6
+ ---
7
+
8
+ # Build: {{ args[0] | default: "a new feature" }}
9
+
10
+ You are the **Build workflow leader** — go from requirement to merged PR.
11
+
12
+ ```
13
+ SINGLE FEATURE:
14
+ Context → Spec → Design? → Workspace → Plan → Implement → Review → Ship
15
+ ↑ ↑
16
+ git worktree Spawn agent
17
+ (MANDATORY) (MANDATORY)
18
+
19
+ PARALLEL (multiple terminals — each gets its own worktree):
20
+ Terminal 1: /spartan:build auth → .worktrees/auth/ → PR #1
21
+ Terminal 2: /spartan:build payments → .worktrees/payments/ → PR #2
22
+ ```
23
+
24
+ ### Mandatory Stages
25
+
26
+ | Stage | Can skip? |
27
+ |-------|-----------|
28
+ | 1 Spec | NO |
29
+ | 2 Design | Only if pure data change (no UI) |
30
+ | 3 Workspace + Plan | NO |
31
+ | 4 Implement | NO |
32
+ | 5 Review | **NEVER** — spawn review agent, never self-review |
33
+ | 6 Ship | NO |
34
+
35
+ **Auto mode:** Show output at each stage but don't pause for confirmation. Still stop for destructive actions and the 3 forcing questions.
36
+
37
+ **Fast path:** Small work (< 1 day, ≤ 4 tasks) → spec + plan inline. No separate commands.
38
+ **Full path:** Bigger work → `/spartan:spec`, `/spartan:ux prototype`, `/spartan:plan` as sub-steps.
39
+ **Epic path:** Feature name matches epic with 2+ specs → build all together, one branch, one PR. See Stage E.
40
+
41
+ ---
42
+
43
+ ## Preamble
44
+
45
+ ```bash
46
+ mkdir -p ~/.spartan/sessions
47
+ touch ~/.spartan/sessions/"$PPID"
48
+ _SESSIONS=$(find ~/.spartan/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ')
49
+ find ~/.spartan/sessions -mmin +120 -type f -delete 2>/dev/null || true
50
+ _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
51
+ _PROJECT=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || basename "$(pwd)")
52
+ echo "SESSIONS: $_SESSIONS"
53
+ echo "BRANCH: $_BRANCH"
54
+ echo "PROJECT: $_PROJECT"
55
+ cat .spartan/build.yaml 2>/dev/null || true
56
+ cat .spartan/commands.yaml 2>/dev/null || true
57
+ ```
58
+
59
+ If `SESSIONS` >= 3, start every response with: **[PROJECT / BRANCH]** Currently working on: [task]
60
+
61
+ If `.spartan/commands.yaml` has `prompts.build`, apply those instructions alongside built-in ones.
62
+
63
+ ### Build Config (`.spartan/build.yaml`)
64
+
65
+ All fields optional:
66
+
67
+ | Field | Default | What it does |
68
+ |-------|---------|-------------|
69
+ | `branch-prefix` | `"feature"` | Branch name: `[prefix]/[slug]` |
70
+ | `max-review-rounds` | `3` | Max review-fix cycles before asking user |
71
+ | `skip-stages` | `[]` | Stages to skip. Never `review`. |
72
+ | `prompts.*` | — | Custom instructions per stage: `spec`, `plan`, `implement`, `review`, `ship` |
73
+
74
+ ---
75
+
76
+ ## Step 0: Detect Mode & Stack (silent)
77
+
78
+ Parse input: `backend`/`be` → backend, `frontend`/`fe` → frontend, else auto-detect:
79
+
80
+ ```bash
81
+ ls build.gradle.kts settings.gradle.kts 2>/dev/null && echo "STACK:kotlin-micronaut"
82
+ ls package.json 2>/dev/null && cat package.json 2>/dev/null | grep -q '"next"' && echo "STACK:nextjs-react"
83
+ ls .planning/PROJECT.md 2>/dev/null && echo "GSD_ACTIVE"
84
+ ```
85
+
86
+ | Detected | Mode |
87
+ |----------|------|
88
+ | Kotlin only | Backend |
89
+ | Next.js only | Frontend |
90
+ | Both | Ask: "Backend, frontend, or both?" |
91
+
92
+ Check for installed skills — if backend mode but no `kotlin-best-practices` skill, or frontend mode but no `ui-ux-pro-max` skill → warn user to install the pack.
93
+
94
+ ---
95
+
96
+ ## Step 0.5: Check Context (silent)
97
+
98
+ ```bash
99
+ ls .memory/index.md 2>/dev/null
100
+ ls .planning/specs/*.md .planning/designs/*.md .planning/plans/*.md 2>/dev/null
101
+ ls .planning/epics/*.md 2>/dev/null
102
+ ls .handoff/*.md 2>/dev/null
103
+ ls .worktrees/ 2>/dev/null
104
+ git worktree list 2>/dev/null
105
+ ```
106
+
107
+ - **Memory exists** → read `.memory/index.md`, mention relevant context
108
+ - **Handoff exists** → resume from previous session
109
+ - **Spec/design/plan exist** → skip completed stages, jump ahead
110
+ - **Worktree exists for feature** → set WORKSPACE, resume from last stage
111
+ - **Epic matches feature name** with 2+ specs ready → switch to Epic mode (Stage E)
112
+
113
+ ---
114
+
115
+ ## Stage 1: Spec
116
+
117
+ **Size check:** Small (< 1 day, ≤ 4 tasks) → inline. Big (multi-day, 5+) → run `/spartan:spec` approach.
118
+
119
+ ### Fast path (small)
120
+
121
+ Ask 3 forcing questions (always, even in auto mode):
122
+ 1. **"What pain does this solve?"** — the pain, not the feature
123
+ 2. **"What's the narrowest version we can ship?"** — force MVP
124
+ 3. **"What assumption could be wrong?"** — surface risks
125
+
126
+ Produce:
127
+
128
+ ```markdown
129
+ ## Scope: [feature name]
130
+ **Pain:** [one sentence]
131
+ **Stack:** [backend / frontend / full-stack]
132
+
133
+ **IN:**
134
+ - [what will be built]
135
+
136
+ **OUT:**
137
+ - [what is NOT in scope]
138
+
139
+ **Risk:** [the assumption that could be wrong]
140
+ ```
141
+
142
+ ### Full path (big)
143
+
144
+ > "This is bigger work — running a proper spec."
145
+
146
+ Use `/spartan:spec` approach internally. Save to `.planning/specs/`.
147
+
148
+ If `.spartan/build.yaml` has `prompts.spec`, apply now.
149
+
150
+ **GATE 1:** "Here's the scope. Anything to change before I plan?"
151
+
152
+ ---
153
+
154
+ ## Stage 2: Design (UI work only)
155
+
156
+ Skip for pure backend. Check:
157
+ ```bash
158
+ ls .planning/designs/*.md 2>/dev/null
159
+ ```
160
+
161
+ If no design and feature has UI work, ask:
162
+ > - **A) Yes** — run design workflow with design-critic agent
163
+ > - **B) Skip** — design as I build (fine for simple UI)
164
+ > - **C) I have Figma** — point me to them
165
+
166
+ **Always ask for frontend work.** Only skip silently for pure data changes (no new screens/components/modals).
167
+
168
+ ---
169
+
170
+ ## Stage 3: Workspace + Plan
171
+
172
+ ### 3.1 Create workspace (MANDATORY — run FIRST)
173
+
174
+ **CRITICAL: NEVER use `git checkout -b`. NEVER work in the main repo. Every build runs in a git worktree.**
175
+
176
+ Generate a slug from the feature name (lowercase, dashes, no special chars: "user auth flow" → `user-auth-flow`). Then run immediately:
177
+
178
+ ```bash
179
+ SLUG="the-slug-you-generated"
180
+ BRANCH="feature/$SLUG"
181
+ MAIN_REPO="$(git rev-parse --show-toplevel)"
182
+ WORKSPACE="$MAIN_REPO/.worktrees/$SLUG"
183
+ if [ -d "$WORKSPACE" ]; then echo "RESUMING: $WORKSPACE"; else git worktree add "$WORKSPACE" -b "$BRANCH" 2>/dev/null || git worktree add "$WORKSPACE" "$BRANCH"; fi
184
+ for dir in .planning .memory .handoff .spartan; do [ -d "$MAIN_REPO/$dir" ] && [ ! -e "$WORKSPACE/$dir" ] && ln -s "$MAIN_REPO/$dir" "$WORKSPACE/$dir"; done
185
+ [ -f "$MAIN_REPO/.env" ] && [ ! -f "$WORKSPACE/.env" ] && cp "$MAIN_REPO/.env" "$WORKSPACE/.env"
186
+ grep -qxF '.worktrees/' "$MAIN_REPO/.gitignore" 2>/dev/null || echo '.worktrees/' >> "$MAIN_REPO/.gitignore"
187
+ echo "WORKSPACE=$WORKSPACE"
188
+ echo "BRANCH=$BRANCH"
189
+ ```
190
+
191
+ **Read the output.** If `WORKSPACE` is missing → worktree failed, STOP.
192
+
193
+ **From this point, ALL work uses WORKSPACE paths:**
194
+ - Bash: `cd $WORKSPACE && ./gradlew test`
195
+ - Read/Write/Edit: `$WORKSPACE/src/...` absolute paths
196
+ - Git: `git -C $WORKSPACE add` / `git -C $WORKSPACE commit`
197
+
198
+ > "Working in: `$WORKSPACE` on branch `$BRANCH`"
199
+
200
+ ### 3.2 Plan
201
+
202
+ If saved plan exists at `.planning/plans/` → use it.
203
+
204
+ **Fast path (1-4 tasks):**
205
+
206
+ ```markdown
207
+ ## Plan: [feature name]
208
+ Branch: `feature/[slug]`
209
+
210
+ ### Task 1: [name]
211
+ Files: [exact paths]
212
+ Test first: [what test]
213
+ Implementation: [what to change]
214
+ ```
215
+
216
+ Max 4 tasks inline. More → full path.
217
+
218
+ **Full path (5+ tasks):** Use `/spartan:plan` approach. Save to `.planning/plans/`.
219
+
220
+ **Task order by mode:**
221
+ - Backend: Migration → Entity/Table/Repo + tests → Service/Manager + tests → Controller + integration tests
222
+ - Frontend: Types → API client → Components (bottom-up) → Page + routing + tests
223
+ - Full-stack: Backend first, then frontend. Mark integration point. ALL layers must complete.
224
+
225
+ Uses skills: `database-patterns`, `api-endpoint-creator`, `kotlin-best-practices`, `testing-strategies`, `ui-ux-pro-max`, `security-checklist`
226
+
227
+ If `.spartan/build.yaml` has `prompts.plan`, apply now.
228
+
229
+ Write the first failing test for Task 1. Show it fails.
230
+
231
+ **GATE 2:** "Plan has [N] tasks. Does this make sense?"
232
+
233
+ ---
234
+
235
+ ## Stage 4: Implement
236
+
237
+ ### GUARD: Verify workspace (run before writing any code)
238
+
239
+ ```bash
240
+ MAIN_REPO="$(git worktree list | head -1 | awk '{print $1}')"
241
+ CURRENT="$(git rev-parse --show-toplevel 2>/dev/null)"
242
+ if [ "$MAIN_REPO" = "$CURRENT" ]; then echo "ERROR: In main repo, not a worktree!"; else echo "OK: Worktree at $CURRENT"; fi
243
+ ```
244
+
245
+ **If ERROR → STOP. Go back to 3.1 and create workspace.**
246
+
247
+ ### Route: parallel or sequential
248
+
249
+ ```bash
250
+ echo "${CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS:-not_set}"
251
+ ```
252
+
253
+ **Agent Teams enabled AND 2+ parallel tasks?** → Create team with `TeamCreate`. One teammate per parallel track:
254
+ - Full-stack: backend-dev + frontend-dev
255
+ - Backend: data-layer + api-layer
256
+ - Frontend: components + pages
257
+
258
+ Frontend/UI teammates MUST get design doc path in their prompt.
259
+
260
+ After team completes → continue to Stage 5.
261
+
262
+ **Otherwise → sequential execution:**
263
+
264
+ ### TDD per task
265
+
266
+ For each task:
267
+ 1. **Write test** → run → confirm fail (red)
268
+ 2. **Write code** → run → confirm pass (green)
269
+ 3. **Refactor** if needed (tests still green)
270
+ 4. **Commit:** `feat([scope]): [what this task does]`
271
+ 5. Brief status: "Task [N]/[total] done."
272
+
273
+ If a task is hard to test-first (UI, config) → implement-then-test. Always have a test when done.
274
+
275
+ If `.spartan/build.yaml` has `prompts.implement`, apply now.
276
+
277
+ ### Verify all layers
278
+
279
+ | Mode | Must pass before review |
280
+ |------|------------------------|
281
+ | Backend | Migration + Entity/Table/Repo + Manager + Controller + `./gradlew test` |
282
+ | Frontend | Types + API client + Components + Page + `npm test && npm run build` |
283
+ | Full-stack | ALL backend + ALL frontend + frontend calls backend correctly |
284
+
285
+ ```bash
286
+ # Backend
287
+ ./gradlew test
288
+ # Frontend
289
+ npm test && npm run build
290
+ ```
291
+
292
+ **GATE 3:** "All [N] tasks done. [X] tests passing. Starting review."
293
+
294
+ **You MUST run Stage 5 next. Do NOT create a PR. Do NOT skip review.**
295
+
296
+ ---
297
+
298
+ ## Stage 5: Review (MANDATORY — NEVER SKIP)
299
+
300
+ > Not optional. Not skippable. Spawn a separate agent. Never self-review. Never ask user if they want to skip.
301
+
302
+ ### Load rules
303
+
304
+ ```bash
305
+ cat .spartan/config.yaml 2>/dev/null || cat ~/.spartan/config.yaml 2>/dev/null
306
+ ```
307
+
308
+ **Config exists** → read `rules`, `review-stages`, `file-types`, `extends`, `conditional-rules`.
309
+
310
+ **No config** → auto-generate from installed packs:
311
+ ```bash
312
+ cat .claude/.spartan-packs 2>/dev/null || cat ~/.claude/.spartan-packs 2>/dev/null
313
+ ```
314
+ Match to profile: `backend-micronaut` → `kotlin-micronaut`, `frontend-react` → `react-nextjs`, etc. Copy profile to `.spartan/config.yaml`.
315
+
316
+ **Nothing found** → scan `rules/` or `.claude/rules/` or `~/.claude/rules/`. Use all 7 default review stages.
317
+
318
+ ### Gather context
319
+
320
+ ```bash
321
+ git diff main...HEAD --name-only
322
+ ls .planning/specs/*.md .planning/plans/*.md .planning/designs/*.md 2>/dev/null
323
+ ```
324
+
325
+ Classify changed files: `.kt/.java/.go/.py` = backend, `.tsx/.ts/.vue` = frontend, `.sql` = migration.
326
+
327
+ ### Spawn reviewer
328
+
329
+ ```
330
+ Agent:
331
+ name: "reviewer"
332
+ subagent_type: "phase-reviewer"
333
+ prompt: |
334
+ Review code for: {feature name}.
335
+ Changed files — backend: {list}, frontend: {list}, migrations: {list}.
336
+ Spec: {path}. Plan: {path}. Design: {path or "none"}.
337
+
338
+ Read ALL rule files BEFORE reviewing:
339
+ Backend: {paths from config.rules.backend + config.rules.shared}
340
+ Frontend: {paths from config.rules.frontend + config.rules.shared}
341
+ Conditional: {rules matching changed file globs}
342
+ {If design doc exists: check UI matches approved design.}
343
+
344
+ Review stages (skip any disabled in config.review-stages):
345
+ 1. Correctness — matches spec? edge cases? error handling?
346
+ 2. Stack Conventions — follows loaded rule files? idiomatic?
347
+ 3. Test Coverage — tests exist? independent? edge cases + error paths?
348
+ 4. Architecture — proper layers? no duplication? no dead code?
349
+ 5. Database & API — schema rules? API design rules? input validation?
350
+ 6. Security — auth? sanitized input? no data leaks? no injection?
351
+ 7. Doc Gaps — new pattern to document? flag for .memory/
352
+
353
+ Per issue: file:line, what's wrong, which rule, severity (HIGH/MEDIUM/LOW), fix.
354
+ End with: PASS or NEEDS CHANGES + what's clean (always praise good code).
355
+ ```
356
+
357
+ **Agent Teams enabled?** → Split into 3 parallel reviewers: quality (stages 1-2,4), tests (stage 3), security (stage 6). All must PASS. `TeamDelete` after.
358
+
359
+ If `.spartan/build.yaml` has `prompts.review`, inject into reviewer prompt.
360
+
361
+ ### Fix loop
362
+
363
+ - **PASS** → save any flagged docs to `.memory/`, continue to Ship
364
+ - **NEEDS CHANGES** → fix HIGH + reasonable MEDIUM, commit `fix([scope]): [what review caught]`, re-run tests, spawn reviewer again with updated diff
365
+ - Max rounds: 3 (configurable via `max-review-rounds`). After max → ask user what to do
366
+
367
+ ---
368
+
369
+ ## Stage 6: Ship
370
+
371
+ If `.spartan/build.yaml` has `prompts.ship`, apply now.
372
+
373
+ Run `/spartan:pr-ready` approach: rebase onto main, final checks, create PR.
374
+
375
+ Save notable learnings to `.memory/` if any.
376
+
377
+ Worktree stays for review fixes. When user says PR is merged:
378
+
379
+ ```bash
380
+ MAIN_REPO="$(git worktree list | head -1 | awk '{print $1}')"
381
+ SLUG="the-actual-slug"
382
+ git -C "$MAIN_REPO" worktree remove ".worktrees/$SLUG" --force 2>/dev/null
383
+ git -C "$MAIN_REPO" worktree prune 2>/dev/null
384
+ echo "Cleaned up worktree: $SLUG"
385
+ ```
386
+
387
+ **GATE 4:** "PR created: [link]. Here's what's in it: [summary]."
388
+
389
+ ---
390
+
391
+ ## Stage E: Epic Build
392
+
393
+ Replaces Stages 1–4 when epic mode is active. One branch, one PR for all features.
394
+
395
+ ### E.1: Collect and fill gaps
396
+
397
+ For each feature in epic with status `spec`/`planned`/`building`:
398
+ - Read spec, design, plan from `.planning/`
399
+ - Missing spec → skip feature, tell user to run `/spartan:spec`
400
+ - Missing design (with UI) → ask user: create now or skip?
401
+ - Missing plan → generate inline
402
+
403
+ Agent Teams enabled + 2+ features need plans → parallelize with one teammate per feature (`isolation: "worktree"`).
404
+
405
+ ### E.2: Create workspace + sort
406
+
407
+ Create worktree using epic name as slug (same bash block as Stage 3.1).
408
+
409
+ Sort features by dependency: no-deps first (can run in parallel), then dependents.
410
+
411
+ ### E.3: Implement
412
+
413
+ **Agent Teams enabled + 2+ independent features** → one teammate per feature. Frontend teammates MUST get design doc path. Wait for all, merge worktrees, run tests.
414
+
415
+ **Sequential** → build each feature with TDD, update epic status → `done` after each.
416
+
417
+ ### E.4: Verify
418
+
419
+ Run full test suite. Then continue to Stage 5 (Review) — one review for all features.
420
+
421
+ **GATE 3 (Epic):** "All {N} features built. {X} tests passing. Starting review."
422
+
423
+ ---
424
+
425
+ ## Rules
426
+
427
+ - **Orchestrate everything.** Don't tell user to run separate commands — run them yourself.
428
+ - **Fast path for small work** (1-4 tasks). Full path for big (5+).
429
+ - **TDD by default.** One commit per task. Override only when test-first doesn't fit.
430
+ - **Review is ALWAYS an agent. NEVER skip.** Fix until reviewer says PASS.
431
+ - **Design gate for frontend.** Any new component/screen/modal → ask. Pure data → skip.
432
+ - **Full-stack = both layers.** Don't create PR with only backend done.
433
+ - **Every build uses a worktree. NEVER `git checkout -b`.** Multiple terminals get separate worktrees.
434
+ - **Epic = one branch, one PR.** Auto-detect from `.planning/epics/`.
435
+ - **Don't over-plan.** If 1-2 files and 30 min of work, just do it. This workflow is for features that need structure.
@@ -0,0 +1,94 @@
1
+ ---
2
+ name: spartan:careful
3
+ description: Activate destructive operation warnings. Claude will detect and require explicit confirmation before running dangerous commands like rm -rf, DROP TABLE, force-push, git reset --hard, overwriting migrations, or deleting production resources.
4
+ ---
5
+
6
+ # Careful Mode — ACTIVATED
7
+
8
+ You are now in **careful mode**. Before executing any destructive operation, you MUST:
9
+ 1. Print a clear warning
10
+ 2. Explain what will be destroyed/changed irreversibly
11
+ 3. Wait for explicit confirmation ("I confirm" or "proceed anyway")
12
+
13
+ **Never skip this — not even in auto mode.**
14
+
15
+ ---
16
+
17
+ ## Destructive Operations Watchlist
18
+
19
+ Detect and block these patterns. This list is not exhaustive — use judgment for anything that smells destructive.
20
+
21
+ ### Filesystem
22
+ - `rm -rf` / `rm -r` on any directory
23
+ - Overwriting files without backup (especially config, migrations, `.env`)
24
+ - `chmod 777` or `chown` on sensitive paths
25
+ - Truncating or overwriting log files
26
+
27
+ ### Git
28
+ - `git push --force` or `git push -f` (use `--force-with-lease` instead, still warn)
29
+ - `git reset --hard`
30
+ - `git clean -fd`
31
+ - `git branch -D` (force delete branch)
32
+ - `git rebase` on shared branches (main, develop)
33
+ - Amending commits already pushed to remote
34
+
35
+ ### Database
36
+ - `DROP TABLE` / `DROP DATABASE` / `DROP SCHEMA`
37
+ - `TRUNCATE TABLE`
38
+ - `DELETE FROM` without `WHERE` clause
39
+ - `ALTER TABLE ... DROP COLUMN`
40
+ - Overwriting or renaming existing Flyway migrations (breaks checksum)
41
+ - Running migrations on production database
42
+
43
+ ### Infrastructure
44
+ - `terraform destroy`
45
+ - `terraform apply` without prior `terraform plan` review
46
+ - `docker system prune`
47
+ - `railway delete` / removing Railway services
48
+ - Modifying production env vars (DATASOURCES_DEFAULT_*, secrets)
49
+ - Scaling down to 0 replicas
50
+
51
+ ### Application
52
+ - Changing API endpoints that other services depend on (breaking changes)
53
+ - Removing Kafka topics or consumer groups
54
+ - Invalidating all user sessions / tokens
55
+
56
+ ---
57
+
58
+ ## Warning Format
59
+
60
+ When a destructive operation is detected, print:
61
+
62
+ ```
63
+ ⚠️ DESTRUCTIVE OPERATION DETECTED
64
+
65
+ Action: [what will happen]
66
+ Impact: [what will be destroyed/changed irreversibly]
67
+ Recovery: [how to undo, or "NOT RECOVERABLE"]
68
+
69
+ Alternatives:
70
+ - [safer approach if one exists]
71
+
72
+ Type "I confirm" or "proceed anyway" to execute.
73
+ Type "cancel" or "no" to abort.
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Behavior Rules
79
+
80
+ 1. **Always warn, even if user explicitly asked for the destructive action.** They may not realize the full impact.
81
+ 2. **Suggest safer alternatives when possible.** E.g., `--force-with-lease` instead of `--force`, soft delete instead of DROP, backup before overwrite.
82
+ 3. **In auto mode, careful mode OVERRIDES auto mode.** Destructive actions always require confirmation.
83
+ 4. **Chain detection:** If a script contains multiple destructive operations, warn about ALL of them upfront, not one at a time.
84
+ 5. **Stay active until `/spartan:careful off` or session ends.** This is sticky — once activated, it stays on.
85
+
86
+ ---
87
+
88
+ ## Quick Toggle
89
+
90
+ - `/spartan:careful` — activate (this command)
91
+ - `/spartan:careful off` — deactivate (say: "Careful mode OFF. Destructive operations will execute without extra confirmation.")
92
+
93
+ Claude should acknowledge activation:
94
+ "🛡️ Careful mode ON — tôi sẽ cảnh báo trước mọi thao tác destructive. Nói 'careful off' để tắt."
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: spartan:commit-message
3
+ description: Create a commit message and PR description by analyzing git diffs
4
+ allowed-tools: Bash(git status:*), Bash(git diff --staged), Bash(git diff:*), Bash(git log:*), Bash(git commit:*), Bash(git add:*), Bash(git push:*)
5
+ ---
6
+
7
+ ## Run these commands first:
8
+
9
+ ```bash
10
+ git status
11
+ git diff --staged
12
+ git log --oneline -5
13
+ git branch --show-current
14
+ ```
15
+
16
+ ## Your task:
17
+
18
+ Analyze the staged git changes and create a commit message with PR description.
19
+
20
+ ### Step 1: Extract ticket from branch name
21
+ The branch name follows pattern: `lbf-XXXX-description` or `feature/lbf-XXXX-description`
22
+ Extract the ticket number (e.g., LBF-1647) to use as prefix. Convert to uppercase (LBF-XXXX).
23
+
24
+ ### Step 2: Determine if this is the first commit on the branch
25
+ - Run `git log dev..HEAD --oneline` to see existing commits on this branch vs the base branch (dev)
26
+ - If no commits exist (empty output): Use FULL PR template in commit body
27
+ - If commits exist: Use SHORT format (just the change summary)
28
+
29
+ ### Commit types with emojis:
30
+
31
+ - ✨ `feat:` - New feature
32
+ - 🐛 `fix:` - Bug fix
33
+ - 🔨 `refactor:` - Refactoring code
34
+ - 📝 `docs:` - Documentation
35
+ - 🎨 `style:` - Styling/formatting
36
+ - ✅ `test:` - Tests
37
+ - ⚡ `perf:` - Performance
38
+ - 🔒 `security:` - Security fix
39
+ - 📗 `deps:` - Dependency update
40
+
41
+ ## Commit message format:
42
+
43
+ ### First commit on branch (FULL format):
44
+ ```
45
+ [TICKET-ID] <emoji> <type>: <concise_description>
46
+
47
+ ## Summary
48
+
49
+ ### Why
50
+ <Clearly define the issue or problem that your changes address.>
51
+
52
+ ### What
53
+ <High-level overview of what has been modified, added, or removed.>
54
+
55
+ ### Solution
56
+ <Architectural or design decisions made while implementing.>
57
+
58
+ ## Impact Area
59
+ <Impacted features - helps QA and Release Manager.>
60
+
61
+ ## Types of Changes
62
+ - [ ] ❌ Breaking change
63
+ - [ ] 🚀 New feature
64
+ - [ ] 🕷 Bug fix
65
+ - [ ] 👏 Performance optimization
66
+ - [ ] 🛠 Refactor
67
+ - [ ] 📗 Library update
68
+ - [ ] 📝 Documentation
69
+ - [ ] ✅ Test
70
+ - [ ] 🔒 Security awareness
71
+
72
+ ## Test Plan
73
+ <Steps to test this PR.>
74
+
75
+ ## Checklist:
76
+ - [ ] I have performed a self-review of my own code
77
+ - [ ] I have tested that the feature or bug fix works as expected
78
+ - [ ] I have included helpful comments, particularly in hard-to-understand areas
79
+ - [ ] I have added tests that prove my changes are functioning
80
+ - [ ] New and existing unit tests pass locally with my changes
81
+
82
+ ## Related Issues
83
+ <Reference tickets and conversations.>
84
+
85
+ Co-Authored-By: Claude <noreply@anthropic.com>
86
+ ```
87
+
88
+ ### Subsequent commits (SHORT format):
89
+ ```
90
+ [TICKET-ID] <emoji> <type>: <concise_description>
91
+
92
+ <Brief summary of changes in 2-3 lines>
93
+
94
+ Co-Authored-By: Claude <noreply@anthropic.com>
95
+ ```
96
+
97
+ ## Workflow:
98
+
99
+ 1. Run `git add .` to stage all changes
100
+ 2. Show summary of staged changes (files modified, lines added/removed)
101
+ 3. Propose the commit message based on whether it's first or subsequent commit
102
+ 4. **WAIT for user confirmation** - DO NOT auto-commit
103
+ 5. If user confirms, run `git commit` with the message using HEREDOC format:
104
+ ```bash
105
+ git commit -m "$(cat <<'EOF'
106
+ <commit message here>
107
+ EOF
108
+ )"
109
+ ```
110
+ 6. Then run `git push -u origin <branch-name>`
111
+
112
+ **CRITICAL: Always wait for explicit user approval before committing and pushing.**
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: spartan:content
3
+ description: Turn research or ideas into platform-native content — blog posts, tweets, LinkedIn, newsletters
4
+ argument-hint: "[source material and target platform]"
5
+ ---
6
+
7
+ # Content: {{ args[0] | default: "from existing research" }}
8
+
9
+ Create platform-native content from existing work.
10
+
11
+ ## Steps
12
+
13
+ 1. Use the `content-engine` skill
14
+ 2. Find the source material (research report, idea, validation, etc.)
15
+ 3. Ask: What platform? What audience? What goal?
16
+ 4. Create platform-specific drafts
17
+ 5. No copy-paste between platforms — each platform gets native format