@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,284 @@
1
+ ---
2
+ name: terraform-module-creator
3
+ description: Create or extend reusable Terraform modules with proper structure, interfaces, and documentation. Use when building new infrastructure modules or extending existing ones.
4
+ allowed_tools:
5
+ - Read
6
+ - Write
7
+ - Edit
8
+ - Glob
9
+ - Grep
10
+ ---
11
+
12
+ # Terraform Module Creator
13
+
14
+ Creates or extends reusable Terraform modules following standard conventions for structure, interfaces, and composition.
15
+
16
+ ## When to Use
17
+
18
+ - Creating a new reusable infrastructure module
19
+ - Extending an existing module with new resources
20
+ - Refactoring inline resources into a proper module
21
+ - Standardizing an ad-hoc module to follow conventions
22
+
23
+ ## Process
24
+
25
+ ### 1. Determine Module Purpose
26
+
27
+ Ask the user:
28
+ - **Module name** (e.g., `rds`, `ecs-service`, `s3-bucket`)
29
+ - **Resources managed** (what AWS/cloud resources it wraps)
30
+ - **Consumers** (which services will use this module)
31
+
32
+ ### 2. Create Module Directory
33
+
34
+ ```
35
+ modules/{module-name}/
36
+ main.tf # Core resource or locals
37
+ variables.tf # All input variables
38
+ outputs.tf # All outputs
39
+ {resource}.tf # One file per resource type
40
+ versions.tf # Provider version constraints
41
+ README.md # Auto-generated usage docs
42
+ ```
43
+
44
+ ### 3. Define Variables
45
+
46
+ ```hcl
47
+ # variables.tf — explicit interfaces, no hardcoded defaults for critical values
48
+
49
+ variable "name" {
50
+ description = "Resource name prefix"
51
+ type = string
52
+
53
+ validation {
54
+ condition = can(regex("^[a-z][a-z0-9-]+$", var.name))
55
+ error_message = "Name must be lowercase alphanumeric with hyphens."
56
+ }
57
+ }
58
+
59
+ variable "vpc_id" {
60
+ description = "VPC ID where resources are deployed"
61
+ type = string
62
+ }
63
+
64
+ variable "subnet_ids" {
65
+ description = "Subnet IDs for resource placement"
66
+ type = list(string)
67
+ }
68
+
69
+ variable "tags" {
70
+ description = "Additional tags to apply to all resources"
71
+ type = map(string)
72
+ default = {}
73
+ }
74
+
75
+ # Use object types for grouped config
76
+ variable "backup" {
77
+ description = "Backup configuration"
78
+ type = object({
79
+ enabled = bool
80
+ retention_days = number
81
+ window = optional(string, "03:00-04:00")
82
+ })
83
+ default = {
84
+ enabled = true
85
+ retention_days = 7
86
+ }
87
+ }
88
+ ```
89
+
90
+ ### 4. Resource Per File
91
+
92
+ ```hcl
93
+ # rds.tf — one resource type per file
94
+ resource "aws_db_instance" "this" {
95
+ identifier = var.name
96
+ engine = var.engine
97
+ engine_version = var.engine_version
98
+ instance_class = var.instance_class
99
+
100
+ allocated_storage = var.allocated_storage
101
+ max_allocated_storage = var.max_allocated_storage
102
+
103
+ db_name = var.db_name
104
+ username = var.master_username
105
+ password = var.master_password
106
+
107
+ db_subnet_group_name = aws_db_subnet_group.this.name
108
+ vpc_security_group_ids = [aws_security_group.rds.id]
109
+
110
+ backup_retention_period = var.backup.retention_days
111
+ backup_window = var.backup.window
112
+ deletion_protection = var.deletion_protection
113
+
114
+ tags = merge(var.tags, {
115
+ Name = var.name
116
+ })
117
+ }
118
+
119
+ resource "aws_db_subnet_group" "this" {
120
+ name = "${var.name}-subnet-group"
121
+ subnet_ids = var.subnet_ids
122
+
123
+ tags = merge(var.tags, {
124
+ Name = "${var.name}-subnet-group"
125
+ })
126
+ }
127
+ ```
128
+
129
+ ### 5. Security Group Per Resource
130
+
131
+ ```hcl
132
+ # sg.tf
133
+ resource "aws_security_group" "rds" {
134
+ name_prefix = "${var.name}-rds-"
135
+ vpc_id = var.vpc_id
136
+ description = "Security group for ${var.name} RDS instance"
137
+
138
+ tags = merge(var.tags, {
139
+ Name = "${var.name}-rds-sg"
140
+ })
141
+
142
+ lifecycle {
143
+ create_before_destroy = true
144
+ }
145
+ }
146
+
147
+ resource "aws_security_group_rule" "rds_ingress" {
148
+ type = "ingress"
149
+ from_port = 5432
150
+ to_port = 5432
151
+ protocol = "tcp"
152
+ security_group_id = aws_security_group.rds.id
153
+ source_security_group_id = var.app_security_group_id
154
+ description = "Allow access from application"
155
+ }
156
+ ```
157
+
158
+ ### 6. Define Outputs
159
+
160
+ ```hcl
161
+ # outputs.tf — expose values that consumers need
162
+ output "endpoint" {
163
+ description = "Database connection endpoint"
164
+ value = aws_db_instance.this.endpoint
165
+ }
166
+
167
+ output "port" {
168
+ description = "Database port"
169
+ value = aws_db_instance.this.port
170
+ }
171
+
172
+ output "security_group_id" {
173
+ description = "Security group ID for the database"
174
+ value = aws_security_group.rds.id
175
+ }
176
+
177
+ output "arn" {
178
+ description = "ARN of the database instance"
179
+ value = aws_db_instance.this.arn
180
+ }
181
+
182
+ # Mark sensitive outputs
183
+ output "connection_string" {
184
+ description = "Full connection string"
185
+ value = "postgresql://${var.master_username}:${var.master_password}@${aws_db_instance.this.endpoint}/${var.db_name}"
186
+ sensitive = true
187
+ }
188
+ ```
189
+
190
+ ### 7. Version Constraints
191
+
192
+ ```hcl
193
+ # versions.tf
194
+ terraform {
195
+ required_version = ">= 1.5.0"
196
+
197
+ required_providers {
198
+ aws = {
199
+ source = "hashicorp/aws"
200
+ version = ">= 5.0"
201
+ }
202
+ }
203
+ }
204
+ ```
205
+
206
+ ### 8. Publishing to Registry
207
+
208
+ New modules should be contributed to the [c0x12c Terraform Registry](https://registry.terraform.io/namespaces/c0x12c):
209
+
210
+ 1. Create a new repo at `https://github.com/c0x12c/terraform-aws-{module-name}` following the Terraform registry naming convention
211
+ 2. Push the module code with proper `versions.tf`, `variables.tf`, `outputs.tf`
212
+ 3. Tag a release: `git tag v0.1.0 && git push --tags`
213
+ 4. The registry auto-publishes from GitHub tags
214
+ 5. Consumers then use: `source = "c0x12c/{module-name}/aws"` with `version = "~> 0.1.0"`
215
+
216
+ ### 9. Module Usage Example
217
+
218
+ ```hcl
219
+ # How consumers call this module — use c0x12c registry
220
+ module "database" {
221
+ source = "c0x12c/rds/aws"
222
+ version = "~> 0.6.6"
223
+
224
+ name = "${local.name_prefix}-db"
225
+ engine = "postgres"
226
+ engine_version = "15.4"
227
+ instance_class = "db.t3.micro"
228
+ allocated_storage = 20
229
+ db_name = "myservice"
230
+ master_username = "admin"
231
+ master_password = var.db_password
232
+ vpc_id = local.vpc_id
233
+ subnet_ids = local.private_subnet_ids
234
+ app_security_group_id = module.ecs_service.security_group_id
235
+
236
+ deletion_protection = var.env == "prod"
237
+
238
+ backup = {
239
+ enabled = true
240
+ retention_days = var.env == "prod" ? 30 : 7
241
+ }
242
+
243
+ tags = local.common_tags
244
+ }
245
+ ```
246
+
247
+ ## Interaction Style
248
+
249
+ - Asks module purpose and consumers before generating
250
+ - Creates complete module in one pass
251
+ - Includes usage example showing how to call the module
252
+ - Validates naming and interface consistency
253
+
254
+ ## Rules
255
+
256
+ - NO provider blocks in modules — providers come from the caller
257
+ - NO hardcoded values — everything via variables
258
+ - Explicit interfaces — every input has description, type, and validation where useful
259
+ - One resource per file — named after the resource type
260
+ - Use `this` as the resource name for the primary resource
261
+ - `name_prefix` over `name` for security groups (allows create-before-destroy)
262
+ - Mark sensitive outputs with `sensitive = true`
263
+ - Use `object()` types for grouped configuration
264
+ - Use `optional()` for fields with sensible defaults
265
+ - Version constraints in `versions.tf`, not `main.tf`
266
+ - Tags passed through and merged, never overridden
267
+ - Lifecycle rules for zero-downtime updates where applicable
268
+
269
+ ## Output
270
+
271
+ Produces a module directory:
272
+
273
+ ```
274
+ modules/{module-name}/
275
+ main.tf
276
+ variables.tf
277
+ outputs.tf
278
+ versions.tf
279
+ sg.tf
280
+ {resource-1}.tf
281
+ {resource-2}.tf
282
+ ```
283
+
284
+ Plus a usage snippet for consumers to copy.
@@ -0,0 +1,222 @@
1
+ ---
2
+ name: terraform-review
3
+ description: PR review checklist for Terraform changes covering structure, state safety, security, naming, modules, variables, providers, and CI/CD. Use when reviewing Terraform PRs or doing pre-merge checks.
4
+ allowed_tools:
5
+ - Read
6
+ - Glob
7
+ - Grep
8
+ ---
9
+
10
+ # Terraform Review
11
+
12
+ Runs an 8-category review checklist on Terraform changes. Produces an Approved / Needs Changes / Blocked verdict.
13
+
14
+ ## When to Use
15
+
16
+ - Reviewing a Terraform pull request
17
+ - Pre-merge validation of infrastructure changes
18
+ - Self-review before opening a PR
19
+ - Auditing existing Terraform code
20
+
21
+ ## Process
22
+
23
+ ### 1. Structure
24
+
25
+ - [ ] Files follow standard layout: `live/`, `modules/`, `envs/`
26
+ - [ ] One resource per file in modules
27
+ - [ ] `terraform.tf` has backend + provider config
28
+ - [ ] `variables.tf`, `outputs.tf`, `locals.tf` are separate files
29
+ - [ ] No `.terraform/` or `*.tfstate*` in the PR
30
+
31
+ ```
32
+ # CORRECT structure
33
+ terraform/
34
+ live/terraform.tf # backend + provider
35
+ live/variables.tf # inputs
36
+ live/locals.tf # computed values
37
+ live/outputs.tf # exports
38
+ modules/{service}/ # one resource per file
39
+ envs/{env}/ # per-environment config
40
+
41
+ # WRONG — everything in one file
42
+ terraform/main.tf # 500 lines of mixed resources
43
+ ```
44
+
45
+ ### 2. State Safety
46
+
47
+ - [ ] No `terraform state` commands in automation
48
+ - [ ] State stored in S3 with DynamoDB locking
49
+ - [ ] `prevent_destroy` on critical resources (RDS, S3 with data)
50
+ - [ ] No resources removed without `terraform state rm` plan documented
51
+ - [ ] `create_before_destroy` on security groups and launch configs
52
+ - [ ] Import blocks used for adopting existing resources (not `terraform import` CLI)
53
+
54
+ ```hcl
55
+ # CORRECT — protect critical resources
56
+ resource "aws_db_instance" "main" {
57
+ lifecycle {
58
+ prevent_destroy = true
59
+ }
60
+ }
61
+
62
+ # CORRECT — zero-downtime SG updates
63
+ resource "aws_security_group" "app" {
64
+ name_prefix = "${local.name_prefix}-app-"
65
+ lifecycle {
66
+ create_before_destroy = true
67
+ }
68
+ }
69
+ ```
70
+
71
+ ### 3. Security
72
+
73
+ - [ ] No secrets in `.tf` or `.tfvars` committed to git
74
+ - [ ] Sensitive variables marked `sensitive = true`
75
+ - [ ] S3 buckets block public access
76
+ - [ ] RDS/Redis in private subnets only
77
+ - [ ] Security groups follow least privilege (no `0.0.0.0/0` ingress on non-ALB)
78
+ - [ ] Encryption enabled (S3 SSE, RDS encryption, Redis transit + at-rest)
79
+ - [ ] IAM policies use least privilege, no `*` actions on `*` resources
80
+
81
+ ```hcl
82
+ # WRONG — overly permissive
83
+ resource "aws_security_group_rule" "bad" {
84
+ cidr_blocks = ["0.0.0.0/0"]
85
+ from_port = 0
86
+ to_port = 65535
87
+ }
88
+
89
+ # CORRECT — scoped to specific source
90
+ resource "aws_security_group_rule" "good" {
91
+ source_security_group_id = var.alb_security_group_id
92
+ from_port = 8080
93
+ to_port = 8080
94
+ }
95
+ ```
96
+
97
+ ### 4. Naming
98
+
99
+ - [ ] Resources use `local.name_prefix` (pattern: `{project}-{service}-{env}`)
100
+ - [ ] Consistent naming across all resources in the module
101
+ - [ ] Tags include: Project, Service, Environment, ManagedBy
102
+ - [ ] No hardcoded names or account IDs
103
+
104
+ ```hcl
105
+ # CORRECT
106
+ locals {
107
+ name_prefix = "${var.project}-${var.service}-${var.env}"
108
+ }
109
+
110
+ # WRONG
111
+ resource "aws_s3_bucket" "assets" {
112
+ bucket = "my-bucket-prod" # hardcoded
113
+ }
114
+ ```
115
+
116
+ ### 5. Modules
117
+
118
+ - [ ] No provider blocks inside modules
119
+ - [ ] Module source uses version pinning (`?ref=vX.Y.Z`)
120
+ - [ ] No circular module dependencies
121
+ - [ ] Module outputs only expose what consumers need
122
+ - [ ] Modules have `versions.tf` with required provider versions
123
+
124
+ ```hcl
125
+ # CORRECT — pinned version
126
+ module "rds" {
127
+ source = "git::https://github.com/{project}/terraform-modules.git//rds?ref=v1.2.0"
128
+ }
129
+
130
+ # WRONG — no version pin
131
+ module "rds" {
132
+ source = "git::https://github.com/{project}/terraform-modules.git//rds"
133
+ }
134
+ ```
135
+
136
+ ### 6. Variables
137
+
138
+ - [ ] All variables have `description` and `type`
139
+ - [ ] Sensitive variables marked `sensitive = true`
140
+ - [ ] Validation blocks on critical inputs (CIDR, names, enums)
141
+ - [ ] No unused variables
142
+ - [ ] Defaults are sensible for dev, overridden per env
143
+
144
+ ```hcl
145
+ # CORRECT
146
+ variable "instance_class" {
147
+ description = "RDS instance class"
148
+ type = string
149
+ default = "db.t3.micro"
150
+
151
+ validation {
152
+ condition = can(regex("^db\\.", var.instance_class))
153
+ error_message = "Must be a valid RDS instance class."
154
+ }
155
+ }
156
+
157
+ # WRONG — no description, no type
158
+ variable "instance_class" {}
159
+ ```
160
+
161
+ ### 7. Providers
162
+
163
+ - [ ] Provider versions pinned with `~>` (pessimistic constraint)
164
+ - [ ] `required_version` for Terraform itself
165
+ - [ ] Provider config only in `live/terraform.tf`, never in modules
166
+ - [ ] Default tags configured at provider level
167
+
168
+ ### 8. CI/CD
169
+
170
+ - [ ] `terraform fmt -check` runs in CI
171
+ - [ ] `terraform validate` runs in CI
172
+ - [ ] Plan output posted as PR comment
173
+ - [ ] Apply only runs on merge to main
174
+ - [ ] State locking prevents concurrent applies
175
+ - [ ] Secrets injected via CI environment, not committed
176
+
177
+ ## Interaction Style
178
+
179
+ - Reads all changed `.tf` files in the PR
180
+ - Checks every category — does not skip sections
181
+ - Flags blocking issues (security, state safety) separately from suggestions
182
+ - Shows exact file and line for each finding
183
+
184
+ ## Rules
185
+
186
+ - Blocking issues: secrets in code, no state locking, `0.0.0.0/0` ingress, missing encryption
187
+ - Needs Changes: missing descriptions, no version pin, naming inconsistency
188
+ - Suggestions: code style, optional validations, documentation
189
+
190
+ ## Output
191
+
192
+ Produces a structured review:
193
+
194
+ ```
195
+ ## Terraform Review: {PR title}
196
+
197
+ ### Verdict: Approved | Needs Changes | Blocked
198
+
199
+ ### Findings
200
+
201
+ #### Blocked (if any)
202
+ - [ ] **[Security]** Secrets found in terraform.tfvars — file:line
203
+
204
+ #### Needs Changes (if any)
205
+ - [ ] **[Naming]** Hardcoded bucket name in s3.tf:12
206
+ - [ ] **[Modules]** Missing version pin on RDS module
207
+
208
+ #### Suggestions (if any)
209
+ - **[Variables]** Consider adding validation on `instance_class`
210
+
211
+ ### Checklist Summary
212
+ | Category | Status |
213
+ |-----------|--------|
214
+ | Structure | Pass |
215
+ | State | Pass |
216
+ | Security | Fail |
217
+ | Naming | Warn |
218
+ | Modules | Warn |
219
+ | Variables | Pass |
220
+ | Providers | Pass |
221
+ | CI/CD | Pass |
222
+ ```