Skip to content

Commit 7b872dc

Browse files
committed
feat: add infra flake template for cloud platform engineering
Combined IaC + K8s + Azure template with version-pinned Terraform via nixpkgs-terraform, security scanning (trivy, checkov), and full Claude Code integration (MCP servers, hooks, permissions).
1 parent 39cbe6e commit 7b872dc

File tree

14 files changed

+349
-1
lines changed

14 files changed

+349
-1
lines changed

.claude/settings.local.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"includeCoAuthoredBy": false,
32
"permissions": {
43
"allow": [
54
"Bash(git:*)",
@@ -14,6 +13,7 @@
1413
],
1514
"deny": []
1615
},
16+
"includeCoAuthoredBy": false,
1717
"enableAllProjectMcpServers": true,
1818
"outputStyle": "Architect",
1919
"spinnerTipsEnabled": false,

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Available templates for `flake-init <template>`:
121121
| `ansible` | Ansible playbooks and roles | ansible, ansible-lint, yamllint, yq |
122122
| `go` | Go development | go, gopls, golangci-lint, delve |
123123
| `java` | Java/Maven development | jdk, maven, google-java-format |
124+
| `infra` | Cloud infrastructure platform | terraform, kubectl, trivy, az, packer, helm, k9s |
124125

125126
Each template scaffolds: `flake.nix`, `.envrc`, `.gitignore`, `.pre-commit-config.yaml`, `.mcp.json`, `CLAUDE.md`, `.claude/settings.json`, `.claude/hooks.json`.
126127

flake.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@
187187
path = ./templates/java;
188188
description = "Java development with Maven";
189189
};
190+
infra = {
191+
path = ./templates/infra;
192+
description = "Cloud infrastructure platform engineering";
193+
};
190194
default = self.templates.minimal;
191195
};
192196
};

templates/infra/.claude/hooks.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"hooks": {
3+
"PostToolUse": [
4+
{
5+
"matcher": "Edit|Write",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": "case \"$CLAUDE_FILE_PATH\" in *.tf|*.hcl) terraform fmt \"$CLAUDE_FILE_PATH\" 2>/dev/null || true ;; esac",
10+
"timeout": 15
11+
},
12+
{
13+
"type": "command",
14+
"command": "case \"$CLAUDE_FILE_PATH\" in *.yaml|*.yml) yamllint \"$CLAUDE_FILE_PATH\" 2>/dev/null || true; kubeconform \"$CLAUDE_FILE_PATH\" 2>/dev/null || true ;; esac",
15+
"timeout": 15
16+
},
17+
{
18+
"type": "command",
19+
"command": "case \"$CLAUDE_FILE_PATH\" in Dockerfile*) hadolint \"$CLAUDE_FILE_PATH\" 2>/dev/null || true ;; esac",
20+
"timeout": 15
21+
},
22+
{
23+
"type": "command",
24+
"command": "pre-commit run --files \"$CLAUDE_FILE_PATH\" 2>/dev/null || true",
25+
"timeout": 30
26+
}
27+
]
28+
}
29+
],
30+
"Stop": [
31+
{
32+
"matcher": "",
33+
"hooks": [
34+
{
35+
"type": "command",
36+
"command": "terraform validate 2>&1 | head -20 || true",
37+
"timeout": 30
38+
},
39+
{
40+
"type": "command",
41+
"command": "[ -f flake.nix ] && nix flake check 2>&1 | head -20 || true",
42+
"timeout": 120
43+
}
44+
]
45+
}
46+
]
47+
}
48+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"includeCoAuthoredBy": false,
3+
"enableAllProjectMcpServers": true,
4+
"spinnerTipsEnabled": false,
5+
"BASH_DEFAULT_TIMEOUT_MS": "300000",
6+
"effortLevel": "high",
7+
"permissions": {
8+
"allow": [
9+
"Bash(terraform:*)",
10+
"Bash(tflint:*)",
11+
"Bash(terragrunt:*)",
12+
"Bash(packer:*)",
13+
"Bash(terraform-docs:*)",
14+
"Bash(checkov:*)",
15+
"Bash(trivy:*)",
16+
"Bash(kubectl:*)",
17+
"Bash(helm:*)",
18+
"Bash(kubeconform:*)",
19+
"Bash(kustomize:*)",
20+
"Bash(stern:*)",
21+
"Bash(kubectx:*)",
22+
"Bash(kubens:*)",
23+
"Bash(az:*)",
24+
"Bash(kubelogin:*)",
25+
"Bash(jq:*)",
26+
"Bash(yq:*)",
27+
"Bash(yamllint:*)",
28+
"Bash(hadolint:*)",
29+
"Bash(git:*)",
30+
"Bash(pre-commit:*)"
31+
],
32+
"deny": [
33+
"Read(*.tfstate)",
34+
"Read(*.tfstate.*)",
35+
"Read(.terraform/**)",
36+
"Bash(kubectl delete namespace *)",
37+
"Bash(kubectl delete -A *)",
38+
"Bash(terraform destroy *)"
39+
]
40+
}
41+
}

templates/infra/.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

templates/infra/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.direnv/
2+
.terraform/
3+
*.tfstate
4+
*.tfstate.*
5+
crash.log
6+
override.tf
7+
override.tf.json
8+
*.tfvars
9+
charts/**/*.tgz
10+
*.pkr.hcl.lock.hcl

templates/infra/.mcp.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"mcpServers": {
3+
"context7": {
4+
"command": "npx",
5+
"args": ["-y", "@upstash/context7-mcp@latest"]
6+
},
7+
"code-reasoning": {
8+
"command": "npx",
9+
"args": ["-y", "@anthropic/code-reasoning-mcp"]
10+
},
11+
"sequential-thinking": {
12+
"command": "npx",
13+
"args": ["-y", "@modelcontextprotocol/server-sequential-thinking"]
14+
},
15+
"terraform": {
16+
"command": "docker",
17+
"args": [
18+
"run", "-i", "--rm",
19+
"hashicorp/terraform-mcp-server"
20+
]
21+
},
22+
"kubernetes": {
23+
"command": "npx",
24+
"args": ["-y", "mcp-server-kubernetes"]
25+
}
26+
}
27+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v6.0.0
5+
hooks:
6+
- id: trailing-whitespace
7+
- id: end-of-file-fixer
8+
- id: check-yaml
9+
args: [--allow-multiple-documents]
10+
- id: check-merge-conflict
11+
- id: detect-private-key
12+
13+
- repo: https://github.com/compilerla/conventional-pre-commit
14+
rev: v4.0.0
15+
hooks:
16+
- id: conventional-pre-commit
17+
stages: [commit-msg]
18+
19+
- repo: https://github.com/antonbabenko/pre-commit-terraform
20+
rev: v1.103.0
21+
hooks:
22+
- id: terraform_fmt
23+
- id: terraform_validate
24+
- id: terraform_tflint
25+
- id: terraform_docs
26+
27+
- repo: https://github.com/adrienverge/yamllint
28+
rev: v1.38.0
29+
hooks:
30+
- id: yamllint
31+
32+
- repo: https://github.com/hadolint/hadolint
33+
rev: v2.12.0
34+
hooks:
35+
- id: hadolint-docker

templates/infra/.tflint.hcl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
plugin "terraform" {
2+
enabled = true
3+
preset = "recommended"
4+
}
5+
6+
plugin "aws" {
7+
enabled = true
8+
version = "0.45.0"
9+
source = "github.com/terraform-linters/tflint-ruleset-aws"
10+
}
11+
12+
config {
13+
call_module_type = "local"
14+
force = false
15+
disabled_by_default = false
16+
}

0 commit comments

Comments
 (0)