/unwind:uw-buildfrom unwind
Executes a technology-agnostic rebuild by dispatching per-layer builder agents to reproduce source contracts in a target stack, maintaining a verification graph for completeness measurement.
Ships in unwind. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Turn the rebuild spec (layer docs + REBUILD-PLAN.md) into actual code in the
target stack, and measure how faithfully it carried over. The differentiator:
completeness is verified by re-scanning the rebuilt repo and diffing it against the
source graph — a before/after picture — not asserted.
Requires: a completed plan — docs/unwind/REBUILD-PLAN.md +
docs/unwind/.cache/rebuild-decisions.json + docs/unwind/rebuild-graph.json +
docs/unwind/layers/**. (Run uw-plan and uw-graph/uw-dashboard first.)
Produces:
docs/unwind/.cache/rebuild-state.json — the durable rebuild ledger (resume + loop).docs/unwind/.cache/rebuild-map/<sliceId>.json — per-slice source→target mappings.docs/unwind/.cache/rebuild-progress.json — overlay the dashboard renders.docs/unwind/rebuild-verification-graph.json + docs/unwind/rebuild-gaps.md.Principles: builders follow rebuild-principles.md (functional equivalence,
[MUST] inviolable, record every mapping, never silently skip).
Hybrid / graceful fallback: with
@unwind/coreavailable, the rebuilt target is re-scanned and completeness is measured. Without it (no Node/pnpm/core), the builders still run from the docs and the orchestrator records state in plain JSON, but there is no verification graph — completeness is LLM-asserted; say so.
Bootstrap the plugin + core, then read the decided strategy. Most of the "how" is already decided in the plan — apply the escape hatch and don't re-ask it.
# Locate the installed Unwind plugin, then load the core helper.
UNWIND_PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-${UNWIND_PLUGIN_ROOT:-}}"
[ -f "$UNWIND_PLUGIN_ROOT/skills/scripts/_resolve-plugin-root.sh" ] || \
UNWIND_PLUGIN_ROOT="$(ls -dt "$HOME"/.claude/plugins/cache/*/unwind/*/ 2>/dev/null | head -1)"
source "${UNWIND_PLUGIN_ROOT%/}/skills/scripts/_resolve-plugin-root.sh"
ensure_unwind_core || echo "core unavailable — pure-LLM build, no verification graph"
Read and hold in mind:
docs/unwind/REBUILD-PLAN.md — target stack, phasing order, re-use decisions.docs/unwind/.cache/rebuild-decisions.json — the machine-readable decisions
(target language/framework/datastore/ORM, API style, hosting, …). Note whether
the API contract style changed (REST→tRPC/GraphQL) — it affects verification.docs/unwind/rebuild-graph.json — the source nodes (id, layer, [MUST]/[SHOULD]/ [DON'T] priority, contractKind) you will rebuild and verify against.docs/unwind/layers/** — the per-item specifications.Derive the slice list: one slice per present layer, in dependency order
(database → domain → service → api → messaging → frontend → tests → infrastructure), seeded by the plan's phasing. Each slice's [MUST] source nodes
come from rebuild-graph.json (filter by layer, drop priority: "DON'T").
Ask only the genuinely-new decisions the plan didn't answer, one per
AskUserQuestion call, recommended-first. Skip anything the plan/decisions already
fix. Offer "Accept recommended defaults" in the first question for a one-shot.
rebuild-state.json already exists: resume (recommended) vs restart
(destructive — requires explicit confirmation before deleting state/maps).Warn at interview time if the target language is outside tree-sitter contract extraction (TypeScript/JavaScript, Python, Rust, Java, C#): verification will be file-grain only (presence, not contract diff). Set expectations now so a later "low %" isn't a surprise.
Write docs/unwind/.cache/rebuild-state.json from the interview answers (the schema
is validated by the scripts, so a malformed write is caught immediately):
{
"version": "1.0.0",
"generatedAt": "<ISO>", "updatedAt": "<ISO>",
"targetRoot": "<chosen target dir>",
"config": {
"scope": "one-slice|one-phase|whole",
"verificationDepth": "structural|contract-diff|run-tests",
"executionMode": "step-through|loop",
"sliceOrder": ["database", "domain", "service", "api", "..."],
"scaffolded": false
},
"nodes": {}, // filled by merge-rebuild-map as builders report mappings
"slices": {} // filled as slices are built/verified
}
In loop mode also add:
"loopState": { "enabled": true, "targetPct": 100, "dryRounds": 0, "lastCompletenessPct": 0, "lastSliceId": null }.
If restarting: after explicit confirmation, delete rebuild-state.json,
rebuild-map/, rebuild-verification-graph.json, rebuild-gaps.md,
rebuild-progress.json — and only those. Never touch the target code without
asking.
For each slice in sliceOrder (bounded by scope):
Read the slice's seed (docs/unwind/.cache/seeds/{layer}.json) and dispatch the
generic builder, pasting the decided stack + the seed + the layer + the spec path:
Task(subagent_type="general-purpose")
description: "Build [layer] slice"
prompt: |
Use unwind:uw-build-layer to rebuild this slice in the target stack.
sliceId: [layer]
targetRoot: [targetRoot from rebuild-state.json]
layer: [layer] (selects the contract-preservation section)
## Target stack (from REBUILD-PLAN.md / rebuild-decisions.json)
[paste the decided language, framework, datastore, ORM, etc.]
## Spec docs for this slice
docs/unwind/layers/[docDir]/ (read these — they are the authority)
## Candidate checklist (your [MUST] list)
[paste docs/unwind/.cache/seeds/[layer].json]
Build idiomatic target-stack code under targetRoot for every [MUST] (and clean
[SHOULD]); skip [DON'T]. Then WRITE the mapping file
docs/unwind/.cache/rebuild-map/[layer].json (see rebuild-principles.md §3) using
the verbatim sourceId and target ids computed against the files you wrote. Never
map an item to code you didn't write. Report what you built and any [MUST] you
could not build (leave it unmapped — it surfaces as a gap).
Dispatch slices in dependency order — wait for a layer before the layers that
depend on it (same rule as uw-analyze). Independent slices (e.g. tests, infra) may
go in parallel.
node "$UNWIND_PLUGIN_ROOT/skills/scripts/merge-rebuild-map.mjs" "$(pwd)"
node "$UNWIND_PLUGIN_ROOT/skills/scripts/verify-rebuild.mjs" "$(pwd)"
merge-rebuild-map ingests the per-slice maps into rebuild-state.json and derives
rebuild-progress.json. verify-rebuild re-scans the target (into an isolated
.cache/target-scan/ so the source baseline is never clobbered), writes
rebuild-verification-graph.json + rebuild-gaps.md, promotes built nodes to
verified/flags divergent, and prints the completeness %.
Read rebuild-gaps.md / the verification stats. If the slice's [MUST] completeness
is below target and the last round made progress, re-dispatch the builder for
that slice pointed at rebuild-gaps.md (it merges fixes into the existing mapping),
then repeat step 2. Stop the inner loop when the slice hits target or a round makes
no progress (a stuck slice — surface it; don't spin). This mirrors uw-analyze's
verify→complete loop and converges because the diff is deterministic.
AskUserQuestion to gate — continue to the next slice,
or pause. Report the slice's completeness and any gaps.Run uw-build under the harness /loop skill, self-paced (no interval →
the model paces itself; the loop ends when it stops scheduling the next iteration):
/loop /uw-build
Each iteration does one in-scope slice, then decides — using the measured number, never a feeling:
rebuild-state.json (the durable handoff) → pick the next slice whose status
isn't built/verified (or has needs-recheck nodes).rebuild-verification-graph.json.stats.completenessPct (over in-scope
[MUST]). Update loopState: set lastCompletenessPct; if it did not
increase vs the previous iteration, dryRounds++, else reset dryRounds = 0.completenessPct >= loopState.targetPct (default 100% of in-scope [MUST]), ORdryRounds >= 2 (stuck — escalate to the user with the gaps), ORThe dryRounds counter lives in rebuild-state.json, so even a fresh iteration that
starts cold (after context compaction) cannot spin forever.
Announce what was produced and the headline number:
Rebuild slice(s) complete. Completeness: N% of in-scope
[MUST]items present or equivalent (rebuild-verification-graph.json). Remaining gaps:docs/unwind/rebuild-gaps.md. Progress overlays the dashboard viarebuild-progress.json.
Remind that present ≠ correct — structural presence doesn't prove behavior; for
behavioral equivalence use run-tests depth / the project's equivalence vectors.
Use AskUserQuestion for the next step:
unwind:uw-dashboard (shows rebuild status on the graph,
plus a Rebuild view: the source→target file mapping + completeness, folded in
from rebuild-state.json + rebuild-verification-graph.json)./loop /uw-build).Pipeline: scan → analyze → grill → plan → build ✓ → dashboard.
After source code changes, uw-refresh flags changed contracts. On the next
uw-build run, merge-rebuild-map reads changes.json and flips affected
done/verified nodes to needs-recheck, so loop mode naturally re-builds the
slices whose source moved. No parallel mechanism — the same changes.json drives both.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub nearform/unwind --plugin unwind25 skills in this plugin
/uw-analyzeUse after unwind:uw-scan to orchestrate layer-by-layer analysis using specialist subagents/uw-analyze-apiUse when analyzing REST/GraphQL API endpoints, contracts, authentication, and client-facing interfaces/uw-analyze-databaseUse when analyzing the database layer including schema, migrations, ORM configuration, and data access patterns/uw-analyze-domainUse when analyzing domain entities, value objects, aggregates, and business rules encoded in the model/uw-analyze-e2e-testsUse when analyzing end-to-end tests including browser automation, API workflows, and full system testing/uw-analyze-frontendUse when analyzing frontend/UI layer including components, state management, routing, and API integration (optional - skip if no frontend exists)Other plugins' skills for the same job