@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,234 @@
1
+ ---
2
+ paths:
3
+ - "**/*.tf"
4
+ - "**/*.hcl"
5
+ - "**/*.tfvars"
6
+ ---
7
+ # Project Organization and Layering
8
+
9
+ > Full guide: use `/spartan:tf-scaffold` command
10
+
11
+ ## Two Template Variants
12
+
13
+ ### Multi-Root (v1)
14
+
15
+ Separate root modules per environment. Best for multi-account setups.
16
+
17
+ Reference: [template-infra-terraform-multiple-root](https://github.com/spartan-stratos/template-infra-terraform-multiple-root)
18
+
19
+ ```
20
+ infra-terraform/
21
+ ├── bootstrap/ # Foundational (S3 bucket, OIDC, Route53, SSM)
22
+ ├── config/ # Shared config modules (aws, general, github)
23
+ └── live/
24
+ ├── shared/ # Reusable module compositions
25
+ │ ├── ecr/
26
+ │ ├── rds/
27
+ │ └── redis/
28
+ ├── dev/ # Dev root module
29
+ │ ├── terraform.tf
30
+ │ ├── provider.tf
31
+ │ ├── variables.tf
32
+ │ ├── locals.tf
33
+ │ └── main.tf
34
+ └── prod/ # Prod root module
35
+ └── ...
36
+ ```
37
+
38
+ ### Single-Root (v2)
39
+
40
+ One root module with per-environment variable files. Supports both ECS and EKS. Best for simpler setups.
41
+
42
+ Reference: [template-infra-terraform-single-root](https://github.com/spartan-stratos/template-infra-terraform-single-root)
43
+
44
+ ```
45
+ infra-terraform/
46
+ ├── bootstrap/
47
+ ├── config/
48
+ │ ├── aws/
49
+ │ ├── general/
50
+ │ ├── github/
51
+ │ └── eks/ # or ecs/
52
+ └── live/
53
+ ├── terraform.tf
54
+ ├── provider.tf
55
+ ├── variables.tf
56
+ ├── locals.tf
57
+ ├── config.tf # Config module references
58
+ ├── data.tf # Remote state references
59
+ └── envs/
60
+ ├── dev/
61
+ │ ├── state.config
62
+ │ ├── terraform.tfvars
63
+ │ └── secrets.tfvars
64
+ └── prod/
65
+ └── ...
66
+ ```
67
+
68
+ ---
69
+
70
+ ## 3-Tier Architecture
71
+
72
+ All platform infrastructure follows a strict 3-tier dependency chain:
73
+
74
+ 1. **bootstrap/** -- Foundational resources. Manual admin setup, local or S3 backend.
75
+ - S3 state bucket, OIDC roles, Route53 zones, SSM parameters
76
+
77
+ 2. **config/** -- Centralized config modules (aws, general, github, eks/ecs, slack, datadog). Imported by both bootstrap and live layers. DRY constants.
78
+
79
+ 3. **live/** -- Active infrastructure. Contains shared modules (multi-root) or flat orchestration (single-root). Reads bootstrap outputs via `terraform_remote_state`.
80
+
81
+ ---
82
+
83
+ ## Service-Level Terraform
84
+
85
+ Service infrastructure lives in the **service repo**, not the infra-terraform repo.
86
+
87
+ ```
88
+ {service}-repo/
89
+ └── terraform/
90
+ ├── live/
91
+ │ ├── terraform.tf
92
+ │ ├── provider.tf
93
+ │ ├── variables.tf
94
+ │ ├── locals.tf
95
+ │ ├── data.tf # Remote state from infra-terraform
96
+ │ └── main.tf # Module call to modules/{service}
97
+ ├── modules/
98
+ │ └── {service}/
99
+ │ ├── variables.tf
100
+ │ ├── outputs.tf
101
+ │ ├── locals.tf
102
+ │ ├── ecr.tf
103
+ │ ├── rds.tf
104
+ │ ├── redis.tf
105
+ │ ├── s3.tf
106
+ │ ├── eks.tf
107
+ │ └── sqs.tf
108
+ └── envs/
109
+ ├── dev/
110
+ │ ├── state.config
111
+ │ ├── terraform.tfvars
112
+ │ └── secrets.tfvars
113
+ └── prod/
114
+ └── ...
115
+ ```
116
+
117
+ ---
118
+
119
+ ## File Conventions
120
+
121
+ Every directory follows these file conventions. Do not combine purposes into one file.
122
+
123
+ | File | Purpose |
124
+ |------|---------|
125
+ | `terraform.tf` | Backend config, `required_providers`, `required_version` |
126
+ | `variables.tf` | Input variable declarations |
127
+ | `locals.tf` | ALL `locals {}` blocks -- never scattered across files |
128
+ | `outputs.tf` | Module/layer outputs |
129
+ | `config.tf` | Config module references |
130
+ | `provider.tf` | Provider configurations (live layer only) |
131
+ | `data.tf` | Data sources and remote state references |
132
+
133
+ ---
134
+
135
+ ## Anti-Patterns
136
+
137
+ ### WRONG -- Flat structure with all resources in root
138
+
139
+ ```hcl
140
+ # Everything dumped in one directory, no layering
141
+ main.tf # 500+ lines: VPC, RDS, Redis, EKS, ECR, S3, IAM...
142
+ variables.tf # 200+ variables for everything
143
+ ```
144
+
145
+ ### CORRECT -- Layered separation
146
+
147
+ ```hcl
148
+ # bootstrap/ handles foundational resources
149
+ # config/ centralizes constants
150
+ # live/ orchestrates via module calls
151
+ # Each module has one resource type per file
152
+ ```
153
+
154
+ ### WRONG -- Mixing bootstrap and live in one state
155
+
156
+ ```hcl
157
+ # S3 state bucket and application RDS in the same terraform state
158
+ resource "aws_s3_bucket" "tf_state" { ... } # Bootstrap resource
159
+ resource "aws_db_instance" "app" { ... } # Live resource
160
+ ```
161
+
162
+ ### CORRECT -- Separate state files per tier
163
+
164
+ ```hcl
165
+ # bootstrap/terraform.tf
166
+ terraform {
167
+ backend "s3" {
168
+ key = "bootstrap.tfstate"
169
+ }
170
+ }
171
+
172
+ # live/terraform.tf
173
+ terraform {
174
+ backend "s3" {
175
+ key = "live-dev.tfstate"
176
+ }
177
+ }
178
+ ```
179
+
180
+ ### WRONG -- Service infrastructure in infra-terraform repo
181
+
182
+ ```hcl
183
+ # infra-terraform/live/dev/service-api.tf
184
+ module "service_api_rds" { ... }
185
+ module "service_api_ecr" { ... }
186
+ ```
187
+
188
+ ### CORRECT -- Service Terraform in service repo, consuming infra remote state
189
+
190
+ ```hcl
191
+ # {service}-repo/terraform/live/data.tf
192
+ data "terraform_remote_state" "infra" {
193
+ backend = "s3"
194
+ config = {
195
+ bucket = var.infra_state_bucket
196
+ key = var.infra_state_key
197
+ region = var.aws_region
198
+ }
199
+ }
200
+ ```
201
+
202
+ ### WRONG -- Locals scattered across files
203
+
204
+ ```hcl
205
+ # rds.tf
206
+ locals { db_name = "mydb" }
207
+
208
+ # redis.tf
209
+ locals { redis_name = "myredis" }
210
+ ```
211
+
212
+ ### CORRECT -- All locals in locals.tf
213
+
214
+ ```hcl
215
+ # locals.tf
216
+ locals {
217
+ db_name = "mydb"
218
+ redis_name = "myredis"
219
+ }
220
+ ```
221
+
222
+ ---
223
+
224
+ ## Quick Reference
225
+
226
+ | Aspect | Rule |
227
+ |--------|------|
228
+ | Template choice | Multi-root for multi-account, single-root for simple setups |
229
+ | Tiers | bootstrap -> config -> live (strict dependency chain) |
230
+ | Service infra | In service repo, not infra-terraform |
231
+ | File per resource | One resource type per `.tf` file in modules |
232
+ | Locals | ALL in `locals.tf`, never scattered |
233
+ | Providers | Only in `live/` layer |
234
+ | Environment config | `envs/{env}/` with state.config, terraform.tfvars, secrets.tfvars |
@@ -0,0 +1,285 @@
1
+ ---
2
+ paths:
3
+ - "**/*.tf"
4
+ - "**/*.hcl"
5
+ - "**/*.tfvars"
6
+ ---
7
+ # Variable Design and Validation
8
+
9
+ ## Validation Blocks
10
+
11
+ Add validation blocks to constrain variable values at plan time, not apply time.
12
+
13
+ ```hcl
14
+ variable "environment" {
15
+ description = "Deployment environment"
16
+ type = string
17
+
18
+ validation {
19
+ condition = can(regex("^(dev|staging|prod)$", var.environment))
20
+ error_message = "Must be dev, staging, or prod."
21
+ }
22
+ }
23
+
24
+ variable "aws_region" {
25
+ description = "AWS region"
26
+ type = string
27
+
28
+ validation {
29
+ condition = can(regex("^[a-z]{2}-[a-z]+-[0-9]$", var.aws_region))
30
+ error_message = "Must be a valid AWS region (e.g., us-west-2)."
31
+ }
32
+ }
33
+
34
+ variable "service_name" {
35
+ description = "Service name (kebab-case)"
36
+ type = string
37
+
38
+ validation {
39
+ condition = can(regex("^[a-z][a-z0-9-]+$", var.service_name))
40
+ error_message = "Must be lowercase kebab-case."
41
+ }
42
+ }
43
+ ```
44
+
45
+ ### WRONG -- No validation on constrained values
46
+
47
+ ```hcl
48
+ variable "environment" {
49
+ type = string
50
+ # No validation -- "production", "PROD", "p" all accepted
51
+ }
52
+ ```
53
+
54
+ ### CORRECT -- Validation with clear error message
55
+
56
+ ```hcl
57
+ variable "environment" {
58
+ type = string
59
+ validation {
60
+ condition = contains(["dev", "staging", "prod"], var.environment)
61
+ error_message = "Must be dev, staging, or prod."
62
+ }
63
+ }
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Sensitive Flag
69
+
70
+ Mark all credential variables with `sensitive = true`. This prevents values from appearing in plan output and logs.
71
+
72
+ ```hcl
73
+ variable "openai_api_key" {
74
+ description = "OpenAI API key"
75
+ type = string
76
+ sensitive = true
77
+ }
78
+
79
+ variable "datadog_api_key" {
80
+ description = "Datadog API key"
81
+ type = string
82
+ sensitive = true
83
+ }
84
+
85
+ variable "slack_webhook_url" {
86
+ description = "Slack webhook URL for alerts"
87
+ type = string
88
+ sensitive = true
89
+ }
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Flat Locals Pattern
95
+
96
+ Extract remote state values into flat locals in `locals.tf`. Reference locals throughout the module instead of repeating `data.terraform_remote_state` lookups.
97
+
98
+ ### WRONG -- Nested lookups in module calls
99
+
100
+ ```hcl
101
+ # rds.tf
102
+ module "rds" {
103
+ source = "c0x12c/rds/aws"
104
+ version = "~> 0.6.6"
105
+ vpc_id = data.terraform_remote_state.infra.outputs.vpc_id
106
+ subnet_ids = data.terraform_remote_state.infra.outputs.private_subnet_ids
107
+ }
108
+
109
+ # redis.tf
110
+ module "redis" {
111
+ source = "c0x12c/redis/aws"
112
+ version = "~> 0.2.0"
113
+ vpc_id = data.terraform_remote_state.infra.outputs.vpc_id # Repeated
114
+ subnet_ids = data.terraform_remote_state.infra.outputs.private_subnet_ids # Repeated
115
+ }
116
+ ```
117
+
118
+ ### CORRECT -- Flat locals, reference once
119
+
120
+ ```hcl
121
+ # locals.tf
122
+ locals {
123
+ vpc_id = data.terraform_remote_state.infra.outputs.vpc_id
124
+ private_subnet_ids = data.terraform_remote_state.infra.outputs.private_subnet_ids
125
+ vpc_cidr_block = data.terraform_remote_state.infra.outputs.vpc_cidr_block
126
+ eks_cluster_name = data.terraform_remote_state.infra.outputs.eks_cluster_name
127
+ }
128
+
129
+ # rds.tf
130
+ module "rds" {
131
+ source = "c0x12c/rds/aws"
132
+ version = "~> 0.6.6"
133
+ vpc_id = local.vpc_id
134
+ subnet_ids = local.private_subnet_ids
135
+ }
136
+
137
+ # redis.tf
138
+ module "redis" {
139
+ source = "c0x12c/redis/aws"
140
+ version = "~> 0.2.0"
141
+ vpc_id = local.vpc_id
142
+ subnet_ids = local.private_subnet_ids
143
+ }
144
+ ```
145
+
146
+ ---
147
+
148
+ ## ALL Locals in locals.tf
149
+
150
+ Never scatter `locals {}` blocks across multiple files. One file, one block.
151
+
152
+ ### WRONG -- Locals in multiple files
153
+
154
+ ```hcl
155
+ # rds.tf
156
+ locals {
157
+ db_name = replace(var.service_name, "-", "_")
158
+ }
159
+
160
+ # eks.tf
161
+ locals {
162
+ namespace = var.service_name
163
+ }
164
+ ```
165
+
166
+ ### CORRECT -- Single locals.tf
167
+
168
+ ```hcl
169
+ # locals.tf
170
+ locals {
171
+ db_name = replace(var.service_name, "-", "_")
172
+ namespace = var.service_name
173
+
174
+ vpc_id = data.terraform_remote_state.infra.outputs.vpc_id
175
+ private_subnet_ids = data.terraform_remote_state.infra.outputs.private_subnet_ids
176
+ }
177
+ ```
178
+
179
+ ---
180
+
181
+ ## .tfvars Separation
182
+
183
+ Split variable values into two files per environment:
184
+
185
+ - `terraform.tfvars` -- public, version-controlled, non-sensitive
186
+ - `secrets.tfvars` -- encrypted via git-secret-protector, sensitive values only
187
+
188
+ ```hcl
189
+ # envs/dev/terraform.tfvars
190
+ environment = "dev"
191
+ aws_region = "us-west-2"
192
+ service_name = "{service}"
193
+ rds_instance_class = "db.t3.micro"
194
+ redis_node_type = "cache.t3.micro"
195
+
196
+ # envs/dev/secrets.tfvars (encrypted in git)
197
+ openai_api_key = "sk-..."
198
+ datadog_api_key = "dd-..."
199
+ slack_webhook_url = "https://hooks.slack.com/..."
200
+ ```
201
+
202
+ Apply with both files:
203
+
204
+ ```bash
205
+ terraform plan \
206
+ -var-file=envs/dev/terraform.tfvars \
207
+ -var-file=envs/dev/secrets.tfvars
208
+ ```
209
+
210
+ ---
211
+
212
+ ## Default Values for Sizing
213
+
214
+ Provide sensible defaults for sizing parameters. Override per environment in `.tfvars`.
215
+
216
+ ```hcl
217
+ variable "rds_instance_class" {
218
+ description = "RDS instance class"
219
+ type = string
220
+ default = "db.t3.micro" # Dev default, override for prod
221
+ }
222
+
223
+ variable "redis_node_type" {
224
+ description = "ElastiCache node type"
225
+ type = string
226
+ default = "cache.t3.micro"
227
+ }
228
+
229
+ variable "rds_allocated_storage" {
230
+ description = "RDS allocated storage in GB"
231
+ type = number
232
+ default = 20
233
+ }
234
+
235
+ variable "eks_cluster_version" {
236
+ description = "EKS cluster Kubernetes version"
237
+ type = string
238
+ default = "1.31"
239
+ }
240
+ ```
241
+
242
+ ---
243
+
244
+ ## Config Modules for Shared Constants
245
+
246
+ Use config modules (in `config/`) for values shared across layers (region, AZs, stack name, default tags). Import in both bootstrap and live.
247
+
248
+ ```hcl
249
+ # config/aws/main.tf
250
+ output "region" {
251
+ value = "us-west-2"
252
+ }
253
+
254
+ output "availability_zones" {
255
+ value = ["us-west-2a", "us-west-2b"]
256
+ }
257
+
258
+ output "default_tags" {
259
+ value = {
260
+ ManagedBy = "Terraform"
261
+ Project = var.project_name
262
+ }
263
+ }
264
+
265
+ # live/config.tf
266
+ module "config_aws" {
267
+ source = "../config/aws"
268
+ }
269
+ ```
270
+
271
+ ---
272
+
273
+ ## Quick Reference
274
+
275
+ | Aspect | Rule |
276
+ |--------|------|
277
+ | Validation | Add `validation {}` blocks for constrained values |
278
+ | Sensitive | `sensitive = true` on all credentials |
279
+ | Flat locals | Extract remote state to `locals {}`, reference `local.*` |
280
+ | Locals file | ALL locals in `locals.tf`, never scattered |
281
+ | tfvars split | `terraform.tfvars` (public) + `secrets.tfvars` (encrypted) |
282
+ | Sizing defaults | Provide dev-appropriate defaults, override in tfvars |
283
+ | Config modules | `config/` for shared constants (region, AZs, tags) |
284
+ | Variable naming | `snake_case` with resource prefix |
285
+ | Descriptions | Every variable must have a `description` |
@@ -0,0 +1,46 @@
1
+ # Layered Architecture
2
+
3
+ > Full guide: use `/api-endpoint-creator` or `/backend-api-design` skill
4
+
5
+ ```
6
+ ┌─────────────────────────────────────────────────────────────────────────────┐
7
+ │ LAYERED ARCHITECTURE │
8
+ ├─────────────────────────────────────────────────────────────────────────────┤
9
+ │ │
10
+ │ CONTROLLER │
11
+ │ ─────────── │
12
+ │ HTTP handling, validation, authentication │
13
+ │ Calls: Managers ONLY │
14
+ │ │
15
+ │ │ │
16
+ │ ▼ │
17
+ │ │
18
+ │ MANAGER │
19
+ │ ──────── │
20
+ │ Business logic, orchestration, transactions, persistence │
21
+ │ Calls: Services (for external data), Repositories (for DB) │
22
+ │ │
23
+ │ │ │ │
24
+ │ ▼ ▼ │
25
+ │ │
26
+ │ SERVICE REPOSITORY │
27
+ │ ──────── ─────────── │
28
+ │ External API calls Database access │
29
+ │ Data transformation CRUD operations │
30
+ │ Returns DTOs Returns Entities │
31
+ │ │
32
+ │ │ │
33
+ │ ▼ │
34
+ │ │
35
+ │ EXTERNAL APIs DATABASE │
36
+ │ (GitHub, Slack, etc) (PostgreSQL) │
37
+ │ │
38
+ └─────────────────────────────────────────────────────────────────────────────┘
39
+ ```
40
+
41
+ | Layer | Can Call | Cannot Call |
42
+ |-------|----------|-------------|
43
+ | Controller | Managers, Detectors | Repositories, DB Context |
44
+ | Manager | Repositories, Services, Other Managers | External APIs directly |
45
+ | Service | External API clients, Config | Repositories, DB Context |
46
+ | Repository | Database | - |