web-infra-plan
Skill3 starsChanged 7 months agoMITView on GitHub
Produce a sprint INFRA.md covering Terraform / gcloud changes — dry-run plan, IAM diff, cost estimate, rollback. Coordinator-only — does not apply infra changes. Pauses for user confirmation. Bias toward GCP+Terraform but works with Pulumi / CloudFormation / Serverless / CDK.
In this repository16 other files it gives its agents.
- references/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- commitSkill
- goSkill
- helpSkill
- initSkill
- planSkill
- review-codeSkill
- review-planSkill
- setupSkill
- statusSkill
- tasksSkill
- web-backend-specSkill
- web-ci-specSkill
- web-frontend-specSkill
- yoloSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 22
If config missing → tell user to run /magi:setup.
- Distinctive: line 51
If there is NO IaC and the user is asking for non-trivial cloud changes,
- Very specific: line 57
Read PLAN/SPEC.md to understand what infra change is implied.
- Very specific: line 81
Add --dry-run or --validate-only if supported.
- Distinctive: line 82
If not supported, mark it 🟡 in INFRA.md as "no dry-run available.
- Distinctive: line 97
If the dry-run cannot be run for any reason (no creds, no state lock, network), abort and tell the user — never make up a fake plan.
- Very specific: line 124
If infracost is missing, do a manual estimate using:
- Very specific: line 158
Use the deliverable template from references/domain/web/infra.md.
- Very specific: line 169
Use output_language for prose.
- Very specific: line 181
If risks are 🔴: have user re-run /magi:review-plan so other models also see the IAM diff.
- Distinctive: line 183
If clean: tell user the apply commands they should run themselves (DO NOT run them).
- Distinctive: line 185
If something is missing for a clean apply (creds, backup), surface that.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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
/magi:web-infra-plan — infra elaboration
You are the coordinator. Plan an infrastructure change and capture the
analysis in magi/<num>-<slug>/INFRA.md. You never run terraform apply,
gcloud ... create, or any other resource-mutating command. Read
references/domain/web/infra.md before starting.
0. Preflight
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-}"
[[ -z "$PLUGIN_ROOT" ]] && PLUGIN_ROOT="$(cd "$(dirname "$BASH_SOURCE[0]")/../.." 2>/dev/null && pwd)"
USER_CONFIG="$HOME/.config/magi-workflow/config.json"If config missing → tell user to run /magi:setup.
0.5. State preflight (auto-refuse if not allowed)
STATE_JSON=$(bash "$PLUGIN_ROOT/scripts/shared/detect-state.sh")
blocked=$(jq -r '.disallowed_skills["web-infra-plan"] // empty' <<<"$STATE_JSON")
if [[ -n "$blocked" ]]; then
reason=$(jq -r '.disallowed_skills["web-infra-plan"].reason' <<<"$STATE_JSON")
suggest=$(jq -r '.disallowed_skills["web-infra-plan"].suggest' <<<"$STATE_JSON")
echo "Cannot run /magi:web-infra-plan: $reason"
echo "Suggested: $suggest"
exit 1
fi--force skips preflight (advanced/recovery only).
1. Locate sprint + IaC
Find the sprint folder (default: most recent; or --sprint <num>-<slug>).
Detect IaC tool per references/domain/web/infra.md "Discovery". Check:
- Is there a
*.tf/terraform//pulumi.yaml/cloudformation/etc.? - For Terraform: where is the state? Workspace pattern? Tooling
(
terragrunt,tflint,tfsec,checkov)?
If there is NO IaC and the user is asking for non-trivial cloud changes, push back: surface "no IaC = no reproducibility" as a 🔴 risk and recommend introducing a minimal Terraform setup before proceeding.
2. Read the existing spec
Read PLAN/SPEC.md to understand what infra change is implied. If the spec is silent on infra, ask the user to describe the intended change.
3. Generate the dry-run plan
Per references/domain/web/infra.md, run the appropriate dry-run:
Terraform
cd <terraform-dir>
terraform fmt -check -recursive
terraform validate
terraform plan -out=plan.tfplan -detailed-exitcode -input=false
plan_rc=$? # 0=no changes, 2=changes, 1=error
[[ $plan_rc -eq 1 ]] && abort # surface the error to the user
terraform show -no-color plan.tfplan > "$sprint_dir/plan.txt"
terraform show -json plan.tfplan > "$sprint_dir/plan.json"gcloud (no Terraform)
For each gcloud command in the proposed change:
- Add
--dry-runor--validate-onlyif supported. - If not supported, mark it 🟡 in INFRA.md as "no dry-run available; review carefully before apply".
Pulumi
pulumi preview --diff --json > "$sprint_dir/preview.json"CloudFormation
aws cloudformation create-change-set ... --change-set-type CREATE
aws cloudformation describe-change-set ... > "$sprint_dir/changeset.json"If the dry-run cannot be run for any reason (no creds, no state lock, network), abort and tell the user — never make up a fake plan.
4. IAM diff
Build the IAM impact table (per reference). For each binding change, identify principal × resource × role-before × role-after.
Flag as 🔴 Critical anything in the reference's "elevated risks" list:
roles/owner,roles/editorroles/iam.securityAdmin,roles/resourcemanager.projectIamAdminallUsers/allAuthenticatedUsers- Cross-project bindings without audit-logged SA
- Newly public bucket / firewall rule / Cloud Run service
5. Cost estimate
Pick the cheapest available tool:
# Preferred for Terraform projects:
infracost breakdown --path "$sprint_dir/plan.json" \
--format table > "$sprint_dir/cost.txt" 2>&1 \
|| echo "infracost unavailable; falling back to manual estimate"If infracost is missing, do a manual estimate using:
- Resource shape (machine type, region, storage class, retention).
- Public GCP / AWS / Azure pricing.
- Top 3 cost drivers.
- Cost-control levers.
State the methodology in INFRA.md so a reviewer can sanity-check.
6. Rollback plan
For every change, answer:
- Reversible? Can
terraform destroy <addr>(or equivalent) restore prior state without data loss? - Backup needed first? For DB / GCS / KMS / IAM cascading changes: yes, document the backup command.
- Blast radius: per-env vs cross-env vs whole project.
- Comm plan: who needs to know before / during / after apply.
For IRREVERSIBLE changes, INFRA.md must include a STOP-checklist the operator runs aloud before applying:
STOP — irreversible apply ahead.
Confirm:
[ ] Backup taken: <command and verified output>
[ ] Approver: <name>
[ ] Rollback path documented and tested
[ ] Off-hours window: <timestamp>7. Write INFRA.md
Use the deliverable template from references/domain/web/infra.md. Fields:
- Summary
- Resource changes (link to plan.tfplan / plan.txt)
- IAM diff table
- Cost estimate
- Network & security baseline check (TLS, WAF, secrets, logs)
- Rollback plan (+ STOP checklist if applicable)
- Verification (post-apply smoke commands; drift detection cadence)
- Open questions
Use output_language for prose; keep CLI commands and resource names in
English / canonical form.
8. Stop and hand off
Show the user:
- INFRA.md path
- Top 3 risks (especially any 🔴 IAM escalations)
- Cost delta summary
- Whether the change is reversible
Recommend next:
- If risks are 🔴: have user re-run
/magi:review-planso other models also see the IAM diff. - If clean: tell user the apply commands they should run themselves (DO NOT run them).
- If something is missing for a clean apply (creds, backup), surface that.
Never run terraform apply or any mutating gcloud command.
Argument parsing
--sprint <num>-<slug>— explicit sprint folder.--iac terraform|pulumi|cloudformation|gcloud— skip detection.--terraform-dir <path>— explicit terraform directory if not at sprint root.--no-cost— skip cost estimation (rare; usually wanted).--no-iam-diff— skip IAM diff (only for changes that don't touch IAM).
Conventions
- Plan, not apply — this skill never mutates state.
- Always dry-run first — even for "trivial" changes; the dry-run is the artefact reviewers compare against the apply.
- Errors are blocking —
terraform planreturning 1 = abort; do not guess at the missing pieces. - IAM is rarely "small" — even one role addition can be Critical. Be paranoid by default.
- Cost methodology must be stated — an unattributed number is worse than no number.
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.

