/trails-dev:regrade-loopfrom trails-dev
Runs a Trails Regrade migration loop with dry-run discovery, occurrence judgment, safe apply, verification, ledger capture, and per-cycle resume. Use for vocabulary transitions and governed contract changes.
Ships in trails-dev. 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.
Read when SKILL.md points to them.
Use this skill when a Trails migration should go through Regrade instead of manual search-and-replace. It is for vocabulary transitions, downstream migration plans, and dogfood runs where the tool must discover, apply, verify, and report before an agent edits source by hand.
Doctrine: truth lives in the contract. Warden governs it. Regrade moves it. The regrade plan authors migration intent.
docs/adr/0053-regrade-moves-governed-contract-change.md - the accepted doctrine for governed contract changes, lifecycle, and evidence.docs/api-reference.md - committed Regrade package and CLI/MCP contract reference.packages/regrade/src/downstream/vocabulary.ts - vocabulary plan and report contracts.packages/regrade/src/history-receipt.ts - the canonical compact v3 history receipt contract.apps/trails/src/trails/regrade.ts - Trails CLI/MCP surface for Regrade.packages/warden/src/rules/retired-vocabulary.ts - governed vocabulary transition registry.Do not decide what to search for manually. Start from a Regrade plan or governed vocabulary transition, run the tool, and use its occurrence inventory as the work queue. Manual edits are allowed only as review/fix steps after Regrade has produced evidence.
Keep three artifacts distinct:
Committed history stores compact immutable receipts: authored intent, reproducibility keys, durable form judgments, Git blob identities, and completion facts. It does not store the full occurrence ledger or rendered report. Never hand-edit .trails/regrade/history/; regenerate and validate it through Regrade.
For a long run, write resume state under a gitignored working directory such as .agents/regrade/<plan-id>/:
plan.jsoncycle-001-ledger.jsoncycle-001-report.jsonRETRO.mdDo not commit these working artifacts unless the issue explicitly asks for a durable fixture or example.
Read the issue and the canonical Regrade note. Then inspect the accepted input surface before inventing flags:
trails schema regrade
# or, inside this repo:
bun apps/trails/bin/trails.ts schema regrade
Prefer the Trails surface over calling package internals. CLI and MCP should accept the same contract-shaped input. When using MCP, pass the same fields the schema exposes for the regrade trail.
Choose the public Regrade mode first:
from / to input is needed. The public input is classIds, include, exclude, extensions, apply, and includeEntries.from, to, optional intent, optional include / exclude / extensions, optional overrides, and optional preserve.The internal VocabularyRegradePlan stores scan scope under scope, but the CLI and MCP regrade trail expose those controls as top-level include, exclude, and extensions. Follow the schema output for the surface you are invoking.
Minimal vocabulary input:
fromtointentinclude, exclude, and extensionsoverridespreserveProject defaults may narrow scope, but an explicit plan can override them.
For governed work, use the schema-first saved-plan lifecycle. Create one run-specific directory under the repository's gitignored Regrade working area before either plan mode:
REGRADE_SCRATCH=".agents/regrade/$(date +%Y%m%d-%H%M%S)"
mkdir -p "$REGRADE_SCRATCH"
CYCLE=1
A class plan follows the live form documented by the cross-to-compose migration:
trails regrade plan \
--root-dir . \
--type class \
--name '<name>' \
--class-ids '<id>' \
--include-entries all \
--json > "$REGRADE_SCRATCH/plan.json"
PLAN_PATH="$(jq -r '.path' "$REGRADE_SCRATCH/plan.json")"
For vocabulary work, author the saved plan from the public positional from and to inputs, then capture the returned path the same way:
trails regrade plan '<from>' '<to>' \
--root-dir . \
--include-entries all \
--json > "$REGRADE_SCRATCH/plan.json"
PLAN_PATH="$(jq -r '.path' "$REGRADE_SCRATCH/plan.json")"
Keep PLAN_PATH for the whole governed cycle. Do not replace saved-plan apply with the legacy direct top-level trails regrade mode.
Derive the no-write preview and exercise apply preflight against the same saved plan before expecting a green gate:
trails regrade preview --root-dir . --plan "$PLAN_PATH"
trails regrade apply \
--root-dir . \
--plan "$PLAN_PATH" \
--include-entries all \
--dry-run
preview and dry-run apply do not mutate source or history. Save the returned occurrence inventory and report when the run is large or will cross context windows. A saved plan with safe rewrites or review work can make regrade check fail at this stage; that is real work to triage, not a reason to bypass the saved-plan lifecycle.
Use the report inventory:
modified means Regrade believes a safe rewrite exists.deferred means a human or agent must judge the occurrence.skipped means the plan or derived inventory intentionally preserved it.For deferred occurrences, inspect only enough source context to decide one of:
override when a form has a deterministic target;preserve rule when the old form is intentional;Never hide uncertainty by applying a broad replacement.
If triage changes authored plan fields, overrides, or preserve rules, rerun the plan command with the updated structured fields through --input or --input-json. Omit --fresh when unchanged authored fields should carry forward. If only the inventoried source changes, rerun the same plan command without --fresh. Use --fresh only for a deliberate full replacement, and then supply every authored field that must remain. Recapture PLAN_PATH and repeat preview and dry-run apply; never apply a stale inventory.
Apply only after the dry-run report is understood:
APPLY_REPORT="$REGRADE_SCRATCH/apply-cycle-${CYCLE}.json"
trails regrade apply \
--root-dir . \
--plan "$PLAN_PATH" \
--include-entries all \
--json > "$APPLY_REPORT"
HISTORY_ID="$(jq -r '.history.id' "$APPLY_REPORT")"
Safe apply may still leave the gate open when target text contains the source, when review inventory remains, or when new neighbor forms are discovered. That is expected. Continue the loop instead of calling the migration done.
After each apply cycle:
Prove the graduated receipt for either plan mode with trails regrade check --root-dir . --plan "$HISTORY_ID". The history selector is the opaque ID returned by apply, not a path or display name.
For a vocabulary transition, also run trails regrade audit --root-dir . --fail-on-open. Aggregate audit evaluates vocabulary histories; it is not class-history proof.
Compare the new ledger/report with the previous cycle.
Confirm changed files are expected.
Run targeted tests or commands for the migrated surface.
A clean active replan can also prove its gate with trails regrade check --root-dir . --plan "$PLAN_PATH". Do not require check to pass before occurrence triage.
If another apply cycle is needed after graduation, restore the active plan by its opaque receipt ID and recapture its path. Apply consumes the active plan, so this adjustment is required even when the authored intent is unchanged:
ADJUST_REPORT="$REGRADE_SCRATCH/adjust-after-cycle-${CYCLE}.json"
trails regrade adjust "$HISTORY_ID" \
--root-dir . \
--json > "$ADJUST_REPORT"
PLAN_PATH="$(jq -r '.path' "$ADJUST_REPORT")"
CYCLE=$((CYCLE + 1))
Then repeat preview, dry-run apply, triage, and apply on the same history spine. The cycle-numbered reports remain available for comparison and resume; do not overwrite them.
Repeat until the gate is green. If remaining entries require a decision or capability that is not available, stop and capture the review inventory plus its issue/comment as a blocker; do not report the loop as done.
adjust restores an active plan on the same history spine without mutating prior receipts.
For repo work, run local review loops on the branch diff. P0-P2 findings must be fixed or specifically acknowledged with evidence. Relevant P3s should be fixed when they improve operator clarity or prevent later drift.
A Regrade loop is done only when:
trails regrade check accepts the committed class or vocabulary receipt, and trails regrade audit --fail-on-open also accepts governed vocabulary histories when applicable;Stop and report if:
Report what you tried, the exact command, the report or error, your hypothesis, and the smallest Regrade capability needed to continue.
What SKILL.md sets; muted values are Claude Code's defaults
14 skills in this plugin
/building-trailsThe working-on-Trails doctrine digest — what governs the framework, the decision tools for framework work, and where truth lives. Use at the start of any session that changes Trails itself (framework code, docs, vocabulary, governance), when orienting a new agent or persona, or when deciding which governing source answers a question. Not for building apps with Trails; the trails skill covers consuming the framework./tenetsTrails framework design tenets — the foundational beliefs, promises, primitives, and patterns that govern the framework. Use when evaluating architectural decisions, reviewing feature proposals, checking alignment with framework principles, or when tenets, principles, or design philosophy are mentioned./npx claudepluginhub outfitter-dev/trails --plugin trails-dev