agentleFS
KcAnomKcAnom/pi-fairy-tales-chains/skills/migrate-inventory/SKILL.md

migrate-inventory

Skill0 starsChanged 4 months agoMITView on GitHub

Phase 1 of 3 in the migrate chain (inventory → transform → verify) — the durable, human-in-the-loop code migration pipeline. Fans out fairy-tales explore-role subagents to find EVERY call site of the thing being migrated and records them as a per-site checklist in the chain's durable state. This phase starts the durable chain run (state tracked by the chain tool). Trigger whenever the user wants to migrate, replace, swap out, or upgrade something across a codebase: "migrate-inventory", "start a migration", "migrate <thing>", "begin the migrate chain", or standalone "migrate".

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All chain state is managed by the chain tool: authoritative JSON at .pi/fairy-tales/chains/migrate/state.json with a human-readable …

    line 29
  2. Very specific:

    Call the chain tool with action: "status", chain: "migrate":

    line 38
  3. Very specific:

    If an active run exists, a migration is already mid-flight (the status shows its current phase and, once inventoried, the checklist …

    line 40
  4. Very specific:

    If the tool reports the chain is locked by another session, abort and tell the user.

    line 46
  5. Very specific:

    If there is no run, or the last run is complete/abandoned, start fresh: action: "start", chain: "migrate", task: "migrate <description>".

    line 48
  6. Distinctive:

    Call the chain tool:

    line 91
  7. Distinctive:

    After completing this phase, output exactly:

    line 112
  8. Distinctive:

    Do not start the next phase.

    line 117

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Migrate: Inventory

Chain version: 2 (durable state contract — see docs/STATE-CONTRACT.md)

Phase 1 of 3: migrate-inventory → migrate-transform → migrate-verify

Overview

Entry point of the migrate chain. Fans out fairy-tales explore role subagents to locate every call site of the thing being migrated — an API, a function, a dependency, a pattern — and records the full list as a file:line checklist in chain state. This inventory is the backbone of the whole chain: a large migration can span many sessions, and the checklist is what lets migrate-transform resume exactly where it left off, and what lets migrate-verify confirm nothing was missed.

All chain state is managed by the chain tool: authoritative JSON at .pi/fairy-tales/chains/migrate/state.json with a human-readable state.md projection beside it. Never create or edit state files by hand, and never create lock files — the tool locks for you.

Workflow

Step 1 — Start the run (entry phase)

Call the chain tool with action: "status", chain: "migrate":

  • If an active run exists, a migration is already mid-flight (the status shows its current phase and, once inventoried, the checklist progress — a legacy .migrate-state.md from an older version is imported automatically). Show the user the status and ask whether to resume from the current phase (run that phase's skill) or discard it (action: "abandon") and start over. Do not silently overwrite.
  • If the tool reports the chain is locked by another session, abort and tell the user; a dead session's lock can be cleared with action: "unlock".
  • If there is no run, or the last run is complete/abandoned, start fresh: action: "start", chain: "migrate", task: "migrate <description>". Note the runId in the response — it keys this run's quest dedupe keys.

Step 2 — Define the migration target

Confirm with the user (or infer from the task) exactly what is being migrated — the old symbol, API, dependency, or pattern — and what it's being replaced with. This becomes the target/replacement values recorded in chain state and the brief every explore quest will receive.

Step 3 — Fan out explore-role subagents via durable quests

Because a large codebase search can be long-running and must survive a session restart, use the quest tool rather than bare agent calls. Split the search by directory, module, or file-type boundary and, for each split, enqueue a quest with:

  • role: "explore", a self-contained task (the exact symbol/pattern to search for, and instruction to return every match as file:line plus a one-line snippet of context);
  • dedupeKey: "migrate/<runId>/inventory/<split>" (a descriptive id for the directory/module/file-type this quest covers) — re-running a crashed phase returns the same quest instead of duplicating a search;
  • chain: { chain: "migrate", runId: "<runId>", phase: "inventory" };
  • retainUntilConsumed: true.

Issue all the split quests' enqueue calls in one message so they run in parallel. If a returned quest is already done (crash-resume case), reuse its stored result; otherwise quest action run with its id and collect the result.

Merge the results from all explore quests into a single deduplicated list. This list is authoritative — do not spot-check by hand afterward and silently add sites; if more turn up later, add them to the checklist explicitly instead. After extracting what's needed into chain state (Step 5), quest action consume each quest by id.

Step 4 — Build the checklist

Format the merged results as a list of per-site entries, one { "site": "file:line", "snippet": "<context>", "done": false } object per call site, sorted by file then line.

Step 5 — Complete the phase

Call the chain tool:

action: "complete-phase", chain: "migrate", phase: "inventory",
summary: "N call sites found across M files by K explore quests; search split used (directories/modules assigned per quest)",
data: {
  "target": "<old symbol/API/dependency/pattern being migrated>",
  "replacement": "<what it's being migrated to>",
  "inventory": [
    { "site": "path/to/file.ts:42", "snippet": "<context>", "done": false },
    { "site": "path/to/file2.ts:108", "snippet": "<context>", "done": false }
  ]
},
artifacts: { "inventoryQuests": "<quest ids>" }

The tool validates this is the current phase, advances the run to transform, and rewrites the JSON + markdown projection atomically.

Handoff

After completing this phase, output exactly:

Phase 1 complete. Chain state updated (.pi/fairy-tales/chains/migrate/state.json). Run /migrate-transform to begin Phase 2.

Do not start the next phase. Do not offer to continue. Output only the handoff line and stop.

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.