agentleFS
hasansezertasanhasansezertasan/infra-copilot/skills/prune/SKILL.md

prune

Skill2 starsChanged 2 months agoMITView on GitHub

Remove spent one-shot `import {}` and `moved {}` blocks after their apply landed, proving per block that state already holds the address and ending on a plan of No changes. Use once an import applied, never before.

9 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use plan, prototype and 2 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • BlockSkill

    plan

    Draft a TDD, PRD, or lightweight plan in the conversation without committing it.

    Also in 3 projects that use this

  • AWSSkill

    prototype

    Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.

    Also in 3 projects that use this

  • SentrySkill

    review

    Fixture review skill.

    Also in 3 projects that use this

  • DockerSkill

    research

    Research a documentation topic — locate affected files, understand the problem, identify what to change. Use when investigating an issue, a question, or a topic before writing a fix. Triggers on: "research issue 1234", "investigate what needs changing for #500", "what files are affected by #200", "where is X documented", "is our docs page about Y accurate", "look into how we document Z".

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 1

    Distinctive

    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
  1. Very specific:

    Delete the one-shot instruction blocks an adoption leaves behind.

    line 15
  2. Distinctive:

    Refuse on a dirty plan: If the leaf does not plan cleanly apart from the blocks you are about to remove, stop and report rather than prune …

    line 51
  3. Very specific:

    Leaves only — never terraform/modules/: Every consuming state reads a module's blocks separately, and that set is not closed.

    line 54
  4. Very specific:

    If the before-plan still carries the block's own import or move, the apply has not landed.

    line 71

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- AI-RULEZ :: GENERATED FILE — DO NOT EDIT Content-Hash: blake3:65c44127ac48a406b0e0125831aee62f46992e7390d65fd9f947a5d5201899e3 Source-Hash: blake3:3437c8021985fde0d012440ff680b556bdb5cb2d5225aef09511ba92b91f4f6e Schema-Version: v1 -->

infra-copilot: prune

Delete the one-shot instruction blocks an adoption leaves behind. import {} and moved {} execute once against a given state; after that run applies, the resources are managed by their addresses and the blocks are inert. Nothing else removes them, so they accumulate. Scope is one leaf at a time — blocks under terraform/modules/ are out, see guardrail 5.

This file is a router: the reusable machinery — actor model, handoff, resume, preflight — lives in ../infra-copilot/references/protocol.md; the manifest in ../infra-copilot/references/steps.yaml (phase 5, prune-spent-imports); the canonical runbook in ../infra-copilot/references/docs/prune.md.

Why not the last step of import? The apply has to land between the two, so they can never be the same pull request. import ends on imports, not creates; this ends on No changes. Two end states, days apart, usually two different sessions.

Guardrails

The only workflow here that deletes, and both failure directions hit live infrastructure:

  • Pruning too early — before the apply, the blocks still are the adoption instructions, so the next plan proposes creating resources that already exist.
  • Pruning the wrong construct — removing a resource block proposes a destroy. On something like google_project_service that is an API disable on a live project.

So:

  1. Touch only import {} and moved {} blocks. Never resource, data, module, provider, locals, or variable. Removing a resource is add's inverse and is not this workflow.
  2. Decide with Terraform, not a hunch: the plan after the edit must read No changes. A block that has not run still shows up — a pending import prints will be imported, a pending moved prints its rename — so the plan is what separates spent from pending. How many plans, where they run, and whether terraform state list can filter in front of them is the backend's answer and the runbook's to give; the prune-blocks operation supplies the procedure. Membership is never the sole evidence anywhere: an aggregate module target or a count added on one side defeats it.
  3. Refuse on a dirty plan. If the leaf does not plan cleanly apart from the blocks you are about to remove, stop and report rather than prune into an unrelated diff.
  4. One pull request per leaf. Leaves have separate states and separate applies.
  5. Leaves only — never terraform/modules/. Every consuming state reads a module's blocks separately, and that set is not closed. A module's moved block is its upgrade path, which Terraform says to retain; its import block is spent only per consumer, and deleting it while one is behind makes that consumer plan a create against a live resource. prune-spent-imports excludes the directory for the same reason, so a retained module block never shows up as work. The runbook has the citation.

Workflow

  1. Read config first (shared protocol, Step 0) and export the org vars — ../infra-copilot/references/config.md.
  2. Resume scan over prune-spent-imports in ../infra-copilot/references/steps.yaml. Green means no one-shot blocks are committed and there is nothing to do.
  3. Follow the runbook ../infra-copilot/references/docs/prune.md: discover candidates, prove each block spent by the evidence that backend allows — the runbook says which — delete only the block, plan, open the PR.
  4. If the before-plan still carries the block's own import or move, the apply has not landed. Stop and say so — that is infra-copilot:import finishing its work, not a prune.

Validation

terraform plan for the leaf reports No changes. Your infrastructure matches the configuration. with no will be created, will be imported, or will be destroyed. Capture that output for the pull request body — it is the evidence that the removed blocks were inert. That plan is the leaf's completion signal, not the manifest check: prune-spent-imports scans every leaf at once, so it stays red until the last one is pruned. With blocks in two leaves, a correct first PR leaves it red — that is the second leaf reporting, not a failure of the first. Do not combine leaves to turn it green, and do not withhold the PR waiting for it.

Example

# terraform/cloudflare — before (see the selected execution procedure)
$ grep -c '^import {' generated_dns.tf
99
get-plan output for the selected execution
No changes. Your infrastructure matches the configuration.   # nothing pending

# after removing the 99 import blocks, nothing else
get-plan output for the committed deletion
No changes. Your infrastructure matches the configuration.   # they were inert

A will be imported in the first plan means those blocks had not run yet — leave them. A will be created in the second means one address was not what the block named — restore it.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.