sre-terraform
Skill4 starsChanged 24 days agoMITView on GitHub
Use for any Terraform change, plan review, drift check or rollback: confirm target, fmt/validate, saved-plan review, state inspection without leaking secrets, gated apply of the reviewed plan.
In this repository84 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/sre-safety-gates.mdcCursor rule
- sre-awsSkill
- sre-azureSkill
- sre-capacity-planningSkill
- sre-change-safetySkill
- sre-chaos-engineeringSkill
- sre-cloud-cost-reviewSkill
- sre-database-triageSkill
- sre-datadogSkill
- sre-dependency-mappingSkill
- sre-diagnosticsSkill
- sre-dr-backup-testSkill
- sre-dynatraceSkill
- sre-emudhra-ca-checkSkill
- sre-engineerSkill
- sre-expiry-auditSkill
- sre-gcpSkill
- sre-incident-commandSkill
- sre-incident-communicationSkill
- sre-k8s-safe-remediationSkill
- sre-k8s-triageSkill
- sre-k8s-upgrade-autopilotSkill
- sre-message-queue-triageSkill
- sre-migration-safetySkill
- sre-observability-cost-cutterSkill
- sre-observability-query-cookbookSkill
- sre-oncall-auditSkill
- sre-oncall-handoffSkill
- sre-pagerduty-opsgenieSkill
- sre-php2shell-checkSkill
- sre-postmortem-templatesSkill
- sre-production-readinessSkill
- sre-prometheus-grafanaSkill
- sre-remediation-actionsSkill
- sre-runbook-templatesSkill
- sre-safety-gatesSkill
- sre-security-incident-triageSkill
- sre-service-mesh-triageSkill
- sre-slo-alertingSkill
- sre-slo-burn-rate-rulesSkill
- sre-toil-reviewSkill
- sre-awsSkill
- sre-azureSkill
- sre-capacity-planningSkill
- sre-change-safetySkill
- sre-chaos-engineeringSkill
- sre-cloud-cost-reviewSkill
- sre-database-triageSkill
- sre-datadogSkill
- sre-dependency-mappingSkill
- sre-diagnosticsSkill
- sre-dr-backup-testSkill
- sre-dynatraceSkill
- sre-emudhra-ca-checkSkill
- sre-engineerSkill
- sre-expiry-auditSkill
- sre-gcpSkill
- sre-incident-commandSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 12
Wait for explicit human approval before any prod-changing command, MCP write tool, or external post.
- Very specific: line 41
Use for any change, drift fix or rollback before apply.
- Very specific: line 58
Check replace reasons (forced by: paths, action_reason), unexpected resources, drift seen during refresh, and provider or module version …
- Very specific: line 65
Only after step 6 of the plan review and explicit approval.
- Distinctive: line 84
0: no drift. Record the time and workspace.
- Distinctive: line 93
Run the plan review. Reverting doesn't bring back destroyed data, and a stateful delete or replace in the revert plan stops at step 5 like …
- Distinctive: line 105
If terraform is not available, output the commands for the human and stop.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Terraform
Safety gates (REQUIRED)
- Read-only diagnosis first.
- Propose each change with risk (low/med/high) and reversibility.
- Wait for explicit human approval before any prod-changing command, MCP write tool, or external post.
- Act only as approved, verify, and stop and escalate if anything gets worse.
Full rules: sre-safety-gates. Read-only MCP setup: sre-safety-gates/references/mcp.md.
Process skill: sre-change-safety (risk score, rollout, verification). Remediation reference: sre-remediation-actions.
Writes (each needs explicit approval)
apply, destroy and plan -destroy, import (command and import blocks), taint/untaint, -replace, -target, moved/removed blocks, state mv/rm/push/replace-provider, force-unlock, apply -refresh-only, terraform refresh, -lock=false, -refresh=false, init -upgrade/-migrate-state/-reconfigure/-force-copy, workspace new/select/delete, and HCP Terraform run/workspace actions. Full tiered list: references/dangerous-commands.md.
- Never:
-auto-approve,destroy,refresh,applywithout a saved plan file,force-unlock -force. - Only with explicit approval: everything else in the list above;
-lock=falseand-targetare emergency-only.
Secrets rule
Sensitive values: never print. terraform show masks only values marked sensitive; show -json, state show (unmarked attributes), output -json/-raw, state pull, and the plan/state files expose them in plain text. Never commit, upload or paste plan or state files. Use bash scripts/plan-risk.sh for machine review. See references/secrets-exposure.md.
Confirm the target first
# run from this skill folder (the one containing SKILL.md)
bash scripts/preflight.sh -C <root-module-dir> # version, workspace, backend type, lock file, risky env (names only)
terraform -chdir=<root-module-dir> workspace show
# plus the provider's own identity check, e.g. `aws sts get-caller-identity`, `az account show`, `gcloud config list`Plan review (read-only, one workflow)
Use for any change, drift fix or rollback before apply. It never applies. Every plan in this skill goes to one private path, "$P", outside the repo: plan files hold secrets in clear text, so never commit, upload or paste them.
P="$(mktemp -d)/tfplan" # the one plan path for this session
bash scripts/tf-readonly.sh -C <root-module-dir> fmt
bash scripts/tf-readonly.sh -C <root-module-dir> init # read-only flags forced; the lock file isn't rewritten
bash scripts/tf-readonly.sh -C <root-module-dir> validate
bash scripts/tf-readonly.sh -C <root-module-dir> plan -out="$P"
bash scripts/tf-readonly.sh -C <root-module-dir> show "$P" # human review (masks values marked sensitive)
bash scripts/plan-risk.sh -C <root-module-dir> "$P" # machine review without values; exit 3 = approval required
terraform -chdir=<root-module-dir> state listtf-readonly.sh forces the read-only flags (and -no-color on validate, fmt, init, plan and show, so pasted output has no ANSI codes) and refuses writes. terraform -chdir=<root-module-dir> state show '<address>' prints attributes not marked sensitive in clear text; quote the address and don't paste the output.
- Confirm the workspace and account match the intended environment. If anything looks off, stop.
plan-risk.shcounts create/update/delete/replace/forget, lists deletes, replaces (with forcing attribute paths), imports, moved and removed, sensitive attribute paths changed, output changes and drift, and never prints values. Treat any delete, replace, forget, import, errored or incomplete plan as high risk.- Check replace reasons (
forced by:paths,action_reason), unexpected resources, drift seen during refresh, and provider or module version changes. - Report sensitive changes as attribute paths only.
- Stateful delete or replace (databases, volumes, buckets, DNS zones, KMS keys, queues): stop. Don't propose an apply. Find out why (a removed block, a renamed address that needs a
movedblock, a forcing attribute, the wrong workspace or state) and report the cause and the config fix. The fix gets its own new plan review. - Otherwise, write the proposal: plan summary, risk, reversibility, rollback, and the plan file path. Then wait for explicit approval of that exact plan file.
Apply the approved plan
Only after step 6 of the plan review and explicit approval. A saved plan applies without a prompt. Never -auto-approve, never a plain apply without the plan file (it re-plans and skips the review).
Gate: approval required.
terraform -chdir=<root-module-dir> apply "$P"If the state changed since the plan, Terraform rejects the stale plan: run the plan review again and get approval again. A failed apply isn't rolled back automatically, so stop and report. Afterwards, check that bash scripts/drift-check.sh -C <root-module-dir> exits 0 and the service metrics are healthy, then delete the plan file and its folder (this fails safely if $P isn't set in this shell): rm -f -- "${P:?plan path not set}" && rmdir -- "$(dirname "$P")".
Drift check
bash scripts/drift-check.sh -C <root-module-dir> [-- -var-file=<env>.tfvars]
echo "exit=$?" # 0 = no drift, 1 = error, 2 = drift detectedThe script refuses -lock=false, -target, -replace, -destroy, -refresh=false and -auto-approve, keeps the state lock, and deletes its temporary plan. Detecting drift is read-only; never use terraform refresh (= apply -refresh-only -auto-approve).
- 0: no drift. Record the time and workspace.
- 2: for each drifted address find the cause (incident fix, console change, another tool, provider default), then propose one of: (a) change the config to match reality, then run a plan review; (b) revert reality with a normal plan review and apply; (c) accept reality into state with
terraform -chdir=<root-module-dir> plan -refresh-only -out="$P", reviewed like any plan, then applied through Apply the approved plan (it writes state). The script prints these options. Never propose (c) when the drift list showsdelete(the provider reports the object as gone; hashicorp/local also does this when a file's content changed): accepting it removes the resource from state, so Terraform stops tracking it. The script says "(c) NOT OFFERED" in that case; use (b) to recreate it or (a) to remove it from the config on purpose. - 1: report the diagnostics (credentials, lock held, provider error). Don't retry with
-lock=false.
Rolling back
There is no terraform rollback.
git revert <commit>(or check out the last good config).- Run the plan review. Reverting doesn't bring back destroyed data, and a stateful delete or replace in the revert plan stops at step 5 like any other.
- Apply through Apply the approved plan, after explicit approval only.
Guardrails
- Apply only a saved, reviewed plan file, after explicit approval, in every environment. Never
-auto-approve. lifecycle { prevent_destroy = true }on critical stateful resources. It doesn't protect a resource whose block is removed from config.- Remote state with locking.
terraform force-unlock LOCK_IDonly with explicit approval, after confirming no run is active, and never-force. - Opt-in second layer (not enabled by default): hooks/terraform-guard.sh (PreToolUse: denies auto-approve, destroy, refresh, plan-less apply; asks for saved-plan apply, state surgery, import, force-unlock) and the rules in assets/settings.example.json. They match strings: a guardrail, not a sandbox.
- MCP: references/mcp-server-safety.md.
- Tests:
bash tests/run-tests.sh(throwawayterraform_dataconfig). Requires bash 3.2+, jq, terraform 1.16+.
If terraform is not available, output the commands for the human and stop.
Output
- Target confirmed (workspace + identity), plan summary (adds/changes/destroys/replaces, risky resources, sensitive paths), drift result with exit code, likely cause and proposed option. For a stateful delete or replace: the cause and the config fix, with no apply proposed. Otherwise: the plan file path awaiting approval
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

