The guard hook only sees shell commands, so file edits to live systems (like the local kubeconfig) need a written rule.
4.1 KiB
CLAUDE.md
Repository-wide instructions. Each stack directory has its own CLAUDE.md with stack-specific commands and architecture.
Project overview
Pulumi (TypeScript) IaC for a Proxmox-based k3s homelab. Independent Pulumi projects ("stacks"), each with its own Pulumi.yaml/package.json, deployed in order and linked via pulumi.StackReference:
| # | Directory | Pulumi stack | Purpose |
|---|---|---|---|
| 1 | 01-proxmox-infra |
proxmox-infra |
Provisions k3s VMs + DHCP on Proxmox/pfSense |
| 2 | 02-k8s-bootstrap |
k8s-bootstrap |
Installs k3s on the VMs over SSH |
| 3 | 03-k8s-infra |
k8s-infra |
Cluster infra: storage, cert-manager, kube-vip |
| 4 | 04-k8s-apps |
k8s-apps |
Application workloads (e.g. heimdall) |
| 5 | 05-monitoring |
monitoring |
kube-prometheus-stack (Prometheus + Grafana) |
All stacks use the Pulumi stack name dev.
Deployment order & StackReferences
proxmox-infra → k8s-bootstrap → k8s-infra
↘ k8s-apps → monitoring
k8s-bootstrapreads VM IDs, Proxmox credentials, and the SSH private key fromproxmox-infravia StackReference.k8s-infra,k8s-apps, andmonitoringall readkubeconfigfromk8s-bootstrapvia StackReference (requireOutput("kubeconfig")) — never setkubeconfigas Pulumi config in these stacks.monitoringadditionally readsdomainfromk8s-appsvia StackReference.- StackReference format:
${pulumi.getOrganization()}/<stack-name>/dev.
A stack's outputs must exist (i.e. it must have been deployed) before any downstream stack referencing it will succeed.
Shared conventions
- TypeScript:
strict: true,target: es2024,module/moduleResolution: nodenext,noImplicitReturns,noFallthroughCasesInSwitch— functions need explicit return types where TS can't infer them. - Secrets: read via
config.requireSecret(), never via environment variables or hardcoded values. Pulumi.dev.yaml: gitignored (contains the encryption salt) — never delete it or secrets become unrecoverable. Encrypted withPULUMI_CONFIG_PASSPHRASE.- Backend: self-hosted Postgres state backend, set via
PULUMI_BACKEND_URL.
Git conventions
Branch names, commit messages and PR titles follow @CONVENTIONS.md. Don't add a co-author when committing to git.
Live infrastructure
- Don't change live systems (cluster, pfSense, Proxmox, VMs, my local kubeconfig) on your own initiative, even for small or reversible changes. Give me the exact steps and let me decide who runs them.
- Code edits in the repo are fine without asking.
- Never recreate VMs to apply a change. Write code for a clean fresh install, plus separate manual steps for the running cluster.
Verifying changes
After editing a stack, run npm run typecheck in that stack's directory, then pulumi preview, and show the output of both. A passing typecheck only proves the code compiles; the preview is what shows which resources would be created, updated or replaced.
Common commands (run from a stack directory)
npm install
npm run typecheck
pulumi preview
pulumi up --yes # run by the user or CI
pulumi destroy # run by the user
pulumi stack output
pulumi config
Requires PULUMI_BACKEND_URL and PULUMI_CONFIG_PASSPHRASE in the environment (or pulumi login).
Start Claude Code sessions from the repository root: the permission rules and the live-infra hook in .claude/settings.json only load from there.
CI/CD (Gitea Actions)
One workflow per stack: .gitea/workflows/0N-deploy-<stack>.yaml, scoped to changes under that stack's directory.
- Pull request →
main:pulumi previewonly. 01/02(VM provisioning / cluster bootstrap — riskier to automate): deploy only via manualworkflow_dispatch.03–05: deploy on push tomainorworkflow_dispatch—pulumi refreshthenpulumi up.- Each workflow restores
Pulumi.dev.yamlfrom a base64-encoded Gitea secret (<STACK>_PULUMI_DEV_YAML). After changing local config, re-encode and update the secret:base64 -w 0 0N-<stack>/Pulumi.dev.yaml