@neyugn/agent-kits 0.1.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 (158) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +514 -0
  3. package/README.vi.md +410 -0
  4. package/README.zh.md +410 -0
  5. package/dist/cli.d.ts +1 -0
  6. package/dist/cli.js +422 -0
  7. package/kits/coder/ARCHITECTURE.md +289 -0
  8. package/kits/coder/agents/ai-engineer.md +344 -0
  9. package/kits/coder/agents/backend-specialist.md +270 -0
  10. package/kits/coder/agents/cloud-architect.md +363 -0
  11. package/kits/coder/agents/code-reviewer.md +284 -0
  12. package/kits/coder/agents/data-engineer.md +401 -0
  13. package/kits/coder/agents/database-specialist.md +251 -0
  14. package/kits/coder/agents/debugger.md +209 -0
  15. package/kits/coder/agents/devops-engineer.md +281 -0
  16. package/kits/coder/agents/documentation-writer.md +296 -0
  17. package/kits/coder/agents/frontend-specialist.md +298 -0
  18. package/kits/coder/agents/i18n-specialist.md +348 -0
  19. package/kits/coder/agents/integration-specialist.md +314 -0
  20. package/kits/coder/agents/mobile-developer.md +271 -0
  21. package/kits/coder/agents/multi-tenant-architect.md +281 -0
  22. package/kits/coder/agents/orchestrator.md +263 -0
  23. package/kits/coder/agents/performance-analyst.md +327 -0
  24. package/kits/coder/agents/project-planner.md +277 -0
  25. package/kits/coder/agents/queue-specialist.md +282 -0
  26. package/kits/coder/agents/realtime-specialist.md +267 -0
  27. package/kits/coder/agents/security-auditor.md +253 -0
  28. package/kits/coder/agents/test-engineer.md +315 -0
  29. package/kits/coder/agents/ux-researcher.md +388 -0
  30. package/kits/coder/rules/.cursorrules +287 -0
  31. package/kits/coder/rules/CLAUDE.md +287 -0
  32. package/kits/coder/rules/CODEX.md +287 -0
  33. package/kits/coder/rules/GEMINI.md +287 -0
  34. package/kits/coder/scripts/checklist.py +318 -0
  35. package/kits/coder/scripts/kit_status.py +292 -0
  36. package/kits/coder/scripts/skills_manager.py +243 -0
  37. package/kits/coder/scripts/verify_all.py +391 -0
  38. package/kits/coder/skills/accessibility-patterns/SKILL.md +372 -0
  39. package/kits/coder/skills/accessibility-patterns/scripts/a11y_checker.py +211 -0
  40. package/kits/coder/skills/ai-rag-patterns/SKILL.md +444 -0
  41. package/kits/coder/skills/api-patterns/SKILL.md +316 -0
  42. package/kits/coder/skills/api-patterns/assets/.gitkeep +1 -0
  43. package/kits/coder/skills/api-patterns/references/deep-dive.md +21 -0
  44. package/kits/coder/skills/api-patterns/scripts/api_validator.py +253 -0
  45. package/kits/coder/skills/api-patterns/scripts/validate.py +56 -0
  46. package/kits/coder/skills/auth-patterns/SKILL.md +267 -0
  47. package/kits/coder/skills/aws-patterns/SKILL.md +576 -0
  48. package/kits/coder/skills/brainstorming/SKILL.md +370 -0
  49. package/kits/coder/skills/brainstorming/assets/.gitkeep +1 -0
  50. package/kits/coder/skills/brainstorming/references/deep-dive.md +21 -0
  51. package/kits/coder/skills/brainstorming/scripts/validate.py +56 -0
  52. package/kits/coder/skills/clean-code/SKILL.md +240 -0
  53. package/kits/coder/skills/clean-code/assets/.gitkeep +1 -0
  54. package/kits/coder/skills/clean-code/references/deep-dive.md +21 -0
  55. package/kits/coder/skills/clean-code/scripts/lint_runner.py +186 -0
  56. package/kits/coder/skills/clean-code/scripts/validate.py +56 -0
  57. package/kits/coder/skills/database-design/SKILL.md +255 -0
  58. package/kits/coder/skills/database-design/assets/.gitkeep +1 -0
  59. package/kits/coder/skills/database-design/references/deep-dive.md +21 -0
  60. package/kits/coder/skills/database-design/scripts/schema_validator.py +272 -0
  61. package/kits/coder/skills/database-design/scripts/validate.py +56 -0
  62. package/kits/coder/skills/docker-patterns/SKILL.md +240 -0
  63. package/kits/coder/skills/documentation-templates/SKILL.md +441 -0
  64. package/kits/coder/skills/e2e-testing/SKILL.md +457 -0
  65. package/kits/coder/skills/flutter-patterns/SKILL.md +330 -0
  66. package/kits/coder/skills/frontend-design/SKILL.md +127 -0
  67. package/kits/coder/skills/github-actions/SKILL.md +349 -0
  68. package/kits/coder/skills/gitlab-ci-patterns/SKILL.md +466 -0
  69. package/kits/coder/skills/graphql-patterns/SKILL.md +558 -0
  70. package/kits/coder/skills/i18n-localization/SKILL.md +345 -0
  71. package/kits/coder/skills/i18n-localization/scripts/i18n_checker.py +267 -0
  72. package/kits/coder/skills/kubernetes-patterns/SKILL.md +357 -0
  73. package/kits/coder/skills/mermaid-diagrams/SKILL.md +351 -0
  74. package/kits/coder/skills/mobile-design/SKILL.md +305 -0
  75. package/kits/coder/skills/monitoring-observability/SKILL.md +458 -0
  76. package/kits/coder/skills/multi-tenancy/SKILL.md +317 -0
  77. package/kits/coder/skills/multi-tenancy/assets/.gitkeep +1 -0
  78. package/kits/coder/skills/multi-tenancy/references/deep-dive.md +21 -0
  79. package/kits/coder/skills/multi-tenancy/scripts/validate.py +56 -0
  80. package/kits/coder/skills/nodejs-best-practices/SKILL.md +220 -0
  81. package/kits/coder/skills/performance-profiling/SKILL.md +333 -0
  82. package/kits/coder/skills/performance-profiling/assets/.gitkeep +1 -0
  83. package/kits/coder/skills/performance-profiling/references/deep-dive.md +21 -0
  84. package/kits/coder/skills/performance-profiling/scripts/validate.py +56 -0
  85. package/kits/coder/skills/plan-writing/SKILL.md +360 -0
  86. package/kits/coder/skills/plan-writing/assets/.gitkeep +1 -0
  87. package/kits/coder/skills/plan-writing/references/deep-dive.md +21 -0
  88. package/kits/coder/skills/plan-writing/scripts/validate.py +56 -0
  89. package/kits/coder/skills/postgres-patterns/SKILL.md +361 -0
  90. package/kits/coder/skills/prompt-engineering/SKILL.md +277 -0
  91. package/kits/coder/skills/queue-patterns/SKILL.md +359 -0
  92. package/kits/coder/skills/queue-patterns/assets/.gitkeep +1 -0
  93. package/kits/coder/skills/queue-patterns/references/deep-dive.md +21 -0
  94. package/kits/coder/skills/queue-patterns/scripts/validate.py +56 -0
  95. package/kits/coder/skills/react-native-patterns/SKILL.md +393 -0
  96. package/kits/coder/skills/react-patterns/SKILL.md +319 -0
  97. package/kits/coder/skills/realtime-patterns/SKILL.md +506 -0
  98. package/kits/coder/skills/realtime-patterns/assets/.gitkeep +1 -0
  99. package/kits/coder/skills/realtime-patterns/references/deep-dive.md +21 -0
  100. package/kits/coder/skills/realtime-patterns/scripts/validate.py +56 -0
  101. package/kits/coder/skills/redis-patterns/SKILL.md +484 -0
  102. package/kits/coder/skills/security-fundamentals/SKILL.md +363 -0
  103. package/kits/coder/skills/security-fundamentals/assets/.gitkeep +1 -0
  104. package/kits/coder/skills/security-fundamentals/references/deep-dive.md +21 -0
  105. package/kits/coder/skills/security-fundamentals/scripts/security_scan.py +326 -0
  106. package/kits/coder/skills/security-fundamentals/scripts/validate.py +56 -0
  107. package/kits/coder/skills/seo-patterns/SKILL.md +262 -0
  108. package/kits/coder/skills/seo-patterns/scripts/seo_checker.py +211 -0
  109. package/kits/coder/skills/systematic-debugging/SKILL.md +478 -0
  110. package/kits/coder/skills/systematic-debugging/assets/.gitkeep +1 -0
  111. package/kits/coder/skills/systematic-debugging/references/deep-dive.md +21 -0
  112. package/kits/coder/skills/systematic-debugging/scripts/validate.py +56 -0
  113. package/kits/coder/skills/tailwind-patterns/SKILL.md +395 -0
  114. package/kits/coder/skills/terraform-patterns/SKILL.md +470 -0
  115. package/kits/coder/skills/testing-patterns/SKILL.md +285 -0
  116. package/kits/coder/skills/testing-patterns/assets/.gitkeep +1 -0
  117. package/kits/coder/skills/testing-patterns/references/deep-dive.md +21 -0
  118. package/kits/coder/skills/testing-patterns/scripts/test_runner.py +219 -0
  119. package/kits/coder/skills/testing-patterns/scripts/validate.py +56 -0
  120. package/kits/coder/skills/typescript-patterns/SKILL.md +417 -0
  121. package/kits/coder/skills/ui-ux-pro-max/SKILL.md +364 -0
  122. package/kits/coder/skills/ui-ux-pro-max/data/charts.csv +26 -0
  123. package/kits/coder/skills/ui-ux-pro-max/data/colors.csv +97 -0
  124. package/kits/coder/skills/ui-ux-pro-max/data/icons.csv +101 -0
  125. package/kits/coder/skills/ui-ux-pro-max/data/landing.csv +31 -0
  126. package/kits/coder/skills/ui-ux-pro-max/data/products.csv +97 -0
  127. package/kits/coder/skills/ui-ux-pro-max/data/prompts.csv +24 -0
  128. package/kits/coder/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  129. package/kits/coder/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  130. package/kits/coder/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  131. package/kits/coder/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  132. package/kits/coder/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  133. package/kits/coder/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  134. package/kits/coder/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  135. package/kits/coder/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  136. package/kits/coder/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  137. package/kits/coder/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  138. package/kits/coder/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  139. package/kits/coder/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  140. package/kits/coder/skills/ui-ux-pro-max/data/styles.csv +59 -0
  141. package/kits/coder/skills/ui-ux-pro-max/data/typography.csv +58 -0
  142. package/kits/coder/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  143. package/kits/coder/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  144. package/kits/coder/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  145. package/kits/coder/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-314.pyc +0 -0
  146. package/kits/coder/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-314.pyc +0 -0
  147. package/kits/coder/skills/ui-ux-pro-max/scripts/core.py +257 -0
  148. package/kits/coder/skills/ui-ux-pro-max/scripts/design_system.py +488 -0
  149. package/kits/coder/skills/ui-ux-pro-max/scripts/search.py +76 -0
  150. package/kits/coder/workflows/.gitkeep +20 -0
  151. package/kits/coder/workflows/create.md +152 -0
  152. package/kits/coder/workflows/debug.md +223 -0
  153. package/kits/coder/workflows/deploy.md +283 -0
  154. package/kits/coder/workflows/orchestrate.md +243 -0
  155. package/kits/coder/workflows/plan.md +134 -0
  156. package/kits/coder/workflows/test.md +237 -0
  157. package/kits/coder/workflows/ui-ux-pro-max.md +109 -0
  158. package/package.json +49 -0
@@ -0,0 +1,470 @@
1
+ ---
2
+ name: terraform-patterns
3
+ description: Infrastructure as Code with Terraform/OpenTofu. Use when designing modules, managing state, implementing CI/CD for infrastructure, or choosing between IaC approaches. Covers testing, security, multi-environment strategies.
4
+ allowed-tools: Read, Write, Edit, Bash
5
+ version: 1.0
6
+ priority: HIGH
7
+ ---
8
+
9
+ # Terraform Patterns - Infrastructure as Code Excellence
10
+
11
+ > **Philosophy:** Infrastructure is code. Treat it with the same rigor as application code: version control, testing, code review, and automation.
12
+
13
+ ---
14
+
15
+ ## 🎯 Core Principles
16
+
17
+ | Principle | Rule |
18
+ | ---------------- | ----------------------------------------------------- |
19
+ | **Declarative** | Describe desired state, not steps to achieve it |
20
+ | **Idempotent** | Same code + same state = same result, every time |
21
+ | **Version-Able** | All infrastructure changes tracked in version control |
22
+ | **Testable** | Validate before apply, test after |
23
+ | **Modular** | Reusable components, single responsibility per module |
24
+
25
+ ```
26
+ ❌ WRONG: Manual console changes → Export to code
27
+ ✅ CORRECT: Code → Review → Plan → Apply → Verify
28
+ ```
29
+
30
+ ---
31
+
32
+ ## 📁 Project Structure
33
+
34
+ ### Standard Layout
35
+
36
+ ```
37
+ infrastructure/
38
+ ├── environments/ # Environment-specific configurations
39
+ │ ├── prod/
40
+ │ │ ├── main.tf
41
+ │ │ ├── variables.tf
42
+ │ │ └── terraform.tfvars
43
+ │ ├── staging/
44
+ │ └── dev/
45
+ ├── modules/ # Reusable modules
46
+ │ ├── networking/
47
+ │ │ ├── main.tf
48
+ │ │ ├── variables.tf
49
+ │ │ ├── outputs.tf
50
+ │ │ └── README.md
51
+ │ ├── compute/
52
+ │ └── database/
53
+ ├── examples/ # Usage examples (also test fixtures)
54
+ │ ├── complete/
55
+ │ └── minimal/
56
+ └── tests/ # Test files
57
+ └── module_test.tftest.hcl
58
+ ```
59
+
60
+ ### File Organization
61
+
62
+ | File | Purpose |
63
+ | ------------------ | --------------------------------------- |
64
+ | `main.tf` | Primary resources |
65
+ | `variables.tf` | Input variables with descriptions |
66
+ | `outputs.tf` | Output values |
67
+ | `versions.tf` | Provider/Terraform version constraints |
68
+ | `data.tf` | Data sources (optional) |
69
+ | `locals.tf` | Local values (optional) |
70
+ | `terraform.tfvars` | Environment-specific values (gitignore) |
71
+
72
+ ---
73
+
74
+ ## 🏗️ Module Hierarchy
75
+
76
+ | Type | When to Use | Example |
77
+ | ------------------------- | --------------------------------- | ------------------------- |
78
+ | **Resource Module** | Single logical group of resources | VPC + subnets, SG + rules |
79
+ | **Infrastructure Module** | Collection of resource modules | Full network stack |
80
+ | **Composition** | Complete infrastructure | Multi-region deployment |
81
+
82
+ ```
83
+ Resource → Resource Module → Infrastructure Module → Composition
84
+ ```
85
+
86
+ ---
87
+
88
+ ## 📝 Naming Conventions
89
+
90
+ ### Resources
91
+
92
+ ```hcl
93
+ # Good: Descriptive, contextual
94
+ resource "aws_instance" "web_server" { }
95
+ resource "aws_s3_bucket" "application_logs" { }
96
+
97
+ # Good: "this" for singleton resources (only one of that type)
98
+ resource "aws_vpc" "this" { }
99
+
100
+ # Avoid: Generic names for non-singletons
101
+ resource "aws_instance" "main" { } # Which one?
102
+ ```
103
+
104
+ ### Variables
105
+
106
+ ```hcl
107
+ # Prefix with context when needed
108
+ var.vpc_cidr_block # Not just "cidr"
109
+ var.database_instance_class # Not just "instance_class"
110
+ ```
111
+
112
+ ---
113
+
114
+ ## 🔢 Count vs For_Each
115
+
116
+ | Scenario | Use | Why |
117
+ | --------------------------------- | ----------------- | ------------------------- |
118
+ | Boolean condition (create or not) | `count = ? 1 : 0` | Simple on/off toggle |
119
+ | Simple numeric replication | `count = N` | Fixed number of identical |
120
+ | Items may be reordered/removed | `for_each` | Stable resource addresses |
121
+ | Reference by key | `for_each` | Named access |
122
+
123
+ ### Boolean Condition
124
+
125
+ ```hcl
126
+ resource "aws_nat_gateway" "this" {
127
+ count = var.create_nat_gateway ? 1 : 0
128
+ # ...
129
+ }
130
+ ```
131
+
132
+ ### Stable Addressing with for_each
133
+
134
+ ```hcl
135
+ # ✅ GOOD - Removing "us-east-1b" only affects that subnet
136
+ resource "aws_subnet" "private" {
137
+ for_each = toset(var.availability_zones)
138
+
139
+ availability_zone = each.key
140
+ # ...
141
+ }
142
+
143
+ # ❌ BAD - Removing middle AZ recreates all subsequent subnets
144
+ resource "aws_subnet" "private" {
145
+ count = length(var.availability_zones)
146
+
147
+ availability_zone = var.availability_zones[count.index]
148
+ # ...
149
+ }
150
+ ```
151
+
152
+ ---
153
+
154
+ ## 📦 Block Ordering Standard
155
+
156
+ ### Resource Block
157
+
158
+ 1. `count` or `for_each` FIRST (blank line after)
159
+ 2. Other arguments
160
+ 3. `tags` as last real argument
161
+ 4. `depends_on` after tags (if needed)
162
+ 5. `lifecycle` at the very end (if needed)
163
+
164
+ ```hcl
165
+ resource "aws_nat_gateway" "this" {
166
+ count = var.create_nat_gateway ? 1 : 0
167
+
168
+ allocation_id = aws_eip.this[0].id
169
+ subnet_id = aws_subnet.public[0].id
170
+
171
+ tags = {
172
+ Name = "${var.name}-nat"
173
+ }
174
+
175
+ depends_on = [aws_internet_gateway.this]
176
+
177
+ lifecycle {
178
+ create_before_destroy = true
179
+ }
180
+ }
181
+ ```
182
+
183
+ ### Variable Block
184
+
185
+ 1. `description` (ALWAYS required)
186
+ 2. `type`
187
+ 3. `default`
188
+ 4. `validation`
189
+ 5. `nullable` (when setting to false)
190
+
191
+ ```hcl
192
+ variable "environment" {
193
+ description = "Environment name for resource tagging"
194
+ type = string
195
+ default = "dev"
196
+
197
+ validation {
198
+ condition = contains(["dev", "staging", "prod"], var.environment)
199
+ error_message = "Environment must be one of: dev, staging, prod."
200
+ }
201
+
202
+ nullable = false
203
+ }
204
+ ```
205
+
206
+ ---
207
+
208
+ ## 🗄️ State Management
209
+
210
+ ### Backend Configuration
211
+
212
+ | Backend | Use Case | State Locking |
213
+ | ------------------- | ------------------------- | -------------- |
214
+ | **S3 + DynamoDB** | AWS projects | DynamoDB table |
215
+ | **Azure Storage** | Azure projects | Blob lease |
216
+ | **GCS** | GCP projects | Built-in |
217
+ | **Terraform Cloud** | Enterprise, collaboration | Built-in |
218
+
219
+ ### Remote State Example (AWS)
220
+
221
+ ```hcl
222
+ terraform {
223
+ backend "s3" {
224
+ bucket = "company-terraform-state"
225
+ key = "prod/network/terraform.tfstate"
226
+ region = "us-east-1"
227
+ encrypt = true
228
+ dynamodb_table = "terraform-locks"
229
+ }
230
+ }
231
+ ```
232
+
233
+ ### State Security Checklist
234
+
235
+ | Check | Implementation |
236
+ | ------------------------- | ---------------------------------- |
237
+ | **Encryption at rest** | `encrypt = true` in backend |
238
+ | **Encryption in transit** | HTTPS/TLS always |
239
+ | **Access control** | IAM policies limiting state access |
240
+ | **Versioning** | S3 bucket versioning enabled |
241
+ | **Backup** | Cross-region replication |
242
+
243
+ ---
244
+
245
+ ## 🧪 Testing Strategy
246
+
247
+ ### Testing Pyramid
248
+
249
+ ```
250
+ /\
251
+ / \ E2E Tests (Expensive)
252
+ /____\ - Full environment deployment
253
+ / \
254
+ /________\ Integration Tests (Moderate)
255
+ / \ - Module testing with real resources
256
+ /____________\
257
+ / \ Static Analysis (Cheap)
258
+ /________________\ - validate, fmt, lint, security scan
259
+ ```
260
+
261
+ ### Decision Matrix
262
+
263
+ | Situation | Approach | Tools |
264
+ | ------------------------- | --------------------- | ---------------------- |
265
+ | Quick syntax check | Static analysis | `terraform validate` |
266
+ | Pre-commit validation | Static + lint | `tflint`, `trivy` |
267
+ | Terraform 1.6+, simple | Native test framework | `terraform test` |
268
+ | Pre-1.6, or Go expertise | Integration testing | Terratest |
269
+ | Security/compliance focus | Policy as code | OPA, Sentinel, Checkov |
270
+ | Cost-sensitive workflow | Mock providers (1.7+) | Native tests + mocking |
271
+
272
+ ### Native Testing (1.6+)
273
+
274
+ ```hcl
275
+ # tests/module_test.tftest.hcl
276
+ run "verify_vpc_created" {
277
+ command = plan
278
+
279
+ assert {
280
+ condition = aws_vpc.this.cidr_block == "10.0.0.0/16"
281
+ error_message = "VPC CIDR block is incorrect"
282
+ }
283
+ }
284
+
285
+ run "verify_apply" {
286
+ command = apply
287
+
288
+ assert {
289
+ condition = output.vpc_id != ""
290
+ error_message = "VPC ID should not be empty"
291
+ }
292
+ }
293
+ ```
294
+
295
+ ---
296
+
297
+ ## 🔐 Security Best Practices
298
+
299
+ ### Essential Security Checks
300
+
301
+ ```bash
302
+ # Static security scanning
303
+ trivy config .
304
+ checkov -d .
305
+ tfsec .
306
+ ```
307
+
308
+ ### Security Rules
309
+
310
+ | Rule | Implementation |
311
+ | ------------------------- | -------------------------------------- |
312
+ | **No secrets in code** | Use secrets manager, not variables |
313
+ | **Pin provider versions** | `version = "~> 5.0"` not `>= 5.0` |
314
+ | **Enable encryption** | Encryption at rest for all data stores |
315
+ | **Least privilege IAM** | Minimal permissions, no wildcards |
316
+ | **Private by default** | No public IPs unless explicitly needed |
317
+
318
+ ### Sensitive Variables
319
+
320
+ ```hcl
321
+ variable "database_password" {
322
+ description = "Database master password"
323
+ type = string
324
+ sensitive = true # Won't show in logs
325
+ }
326
+
327
+ output "db_connection_string" {
328
+ description = "Database connection string"
329
+ value = local.db_connection
330
+ sensitive = true
331
+ }
332
+ ```
333
+
334
+ ---
335
+
336
+ ## 🔄 CI/CD Integration
337
+
338
+ ### Workflow Stages
339
+
340
+ ```
341
+ Format Check → Validate → Lint → Security Scan → Plan → Review → Apply
342
+ ```
343
+
344
+ ### GitHub Actions Example
345
+
346
+ ```yaml
347
+ name: Terraform
348
+
349
+ on:
350
+ pull_request:
351
+ paths: ["infrastructure/**"]
352
+ push:
353
+ branches: [main]
354
+ paths: ["infrastructure/**"]
355
+
356
+ jobs:
357
+ terraform:
358
+ runs-on: ubuntu-latest
359
+ defaults:
360
+ run:
361
+ working-directory: infrastructure/environments/prod
362
+
363
+ steps:
364
+ - uses: actions/checkout@v4
365
+
366
+ - uses: hashicorp/setup-terraform@v3
367
+ with:
368
+ terraform_version: 1.9.0
369
+
370
+ - name: Format Check
371
+ run: terraform fmt -check -recursive
372
+
373
+ - name: Init
374
+ run: terraform init -backend=false
375
+
376
+ - name: Validate
377
+ run: terraform validate
378
+
379
+ - name: Security Scan
380
+ uses: aquasecurity/trivy-action@master
381
+ with:
382
+ scan-type: config
383
+ scan-ref: .
384
+
385
+ - name: Plan
386
+ if: github.event_name == 'pull_request'
387
+ run: terraform plan -no-color
388
+ env:
389
+ AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
390
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
391
+ ```
392
+
393
+ ---
394
+
395
+ ## 📌 Version Management
396
+
397
+ ### Version Constraint Syntax
398
+
399
+ ```hcl
400
+ version = "5.0.0" # Exact (avoid - inflexible)
401
+ version = "~> 5.0" # Recommended: 5.0.x only
402
+ version = ">= 5.0" # Minimum (risky - breaking changes)
403
+ ```
404
+
405
+ ### Strategy by Component
406
+
407
+ | Component | Strategy | Example |
408
+ | ------------------ | ------------------- | ----------------------------- |
409
+ | **Terraform** | Pin minor version | `required_version = "~> 1.9"` |
410
+ | **Providers** | Pin major version | `version = "~> 5.0"` |
411
+ | **Modules (prod)** | Pin exact version | `version = "5.1.2"` |
412
+ | **Modules (dev)** | Allow patch updates | `version = "~> 5.1"` |
413
+
414
+ ---
415
+
416
+ ## 🚨 Anti-Patterns
417
+
418
+ | ❌ Don't | ✅ Do |
419
+ | -------------------------------- | ---------------------------------- |
420
+ | Manual console changes | All changes through code |
421
+ | Secrets in terraform.tfvars | External secrets manager |
422
+ | Single state file for everything | Per-environment, per-stack states |
423
+ | `terraform apply` without plan | Always review plan before apply |
424
+ | Hardcoded values | Variables with validation |
425
+ | `latest` provider versions | Pinned versions with lock file |
426
+ | Massive monolithic modules | Small, focused, composable modules |
427
+ | Skip state locking | Always enable locking |
428
+
429
+ ---
430
+
431
+ ## 🛠️ Common Issues & Fixes
432
+
433
+ | Issue | Cause | Fix |
434
+ | ---------------------- | ------------------------- | ---------------------------------- |
435
+ | **State lock stuck** | Previous run crashed | `terraform force-unlock <ID>` |
436
+ | **Resource recreated** | `count` index shifted | Use `for_each` instead |
437
+ | **Provider error** | Version mismatch | Check lock file, run init -upgrade |
438
+ | **Cycle detected** | Circular dependencies | Use `depends_on` or refactor |
439
+ | **Plan shows changes** | Drift from manual changes | Import or reconcile state |
440
+ | **Timeout on apply** | Resource creation slow | Increase timeout in lifecycle |
441
+
442
+ ---
443
+
444
+ ## ✅ Self-Check Before Completing
445
+
446
+ | Check | Question |
447
+ | --------------------------- | ---------------------------------------------- |
448
+ | ✅ **Modules?** | Is reusable logic extracted to modules? |
449
+ | ✅ **State remote?** | State stored remotely with locking? |
450
+ | ✅ **Versions pinned?** | Terraform and provider versions constrained? |
451
+ | ✅ **Variables validated?** | Input variables have description + validation? |
452
+ | ✅ **Secrets safe?** | No secrets in code or state? |
453
+ | ✅ **Tested?** | Plan reviewed, security scanned? |
454
+ | ✅ **Documented?** | README for modules, examples provided? |
455
+
456
+ ---
457
+
458
+ ## 🔗 Related Skills
459
+
460
+ | Need | Skill |
461
+ | ----------------------- | --------------------- |
462
+ | Container orchestration | `kubernetes-patterns` |
463
+ | Docker builds | `docker-patterns` |
464
+ | CI/CD workflows | `github-actions` |
465
+ | Database design | `database-design` |
466
+ | Cloud architecture | Cloud provider docs |
467
+
468
+ ---
469
+
470
+ > **Remember:** The best infrastructure code is boring, predictable, and well-tested. If you're debugging infrastructure in production, something went wrong in the development process.