craft-analyze
Post-cycle analysis — QA, UX, Creative, and Style audits using MCP browser tools.
You are in story-implement Step 4. The chunk-validator agent returned **FAILED**. Follow this loop to fix and re-validate.
> /plugin marketplace add drobins25/craft > /plugin install craft@craft
How it fires
How this command gets triggered: by you, by Claude, or both.
/validate-fix-loopContext preview
What this command does when you run it.
You are in story-implement Step 4. The chunk-validator agent returned **FAILED**. Follow this loop to fix and re-validate.
You are in story-implement Step 4. The chunk-validator agent returned **FAILED**. Follow this loop to fix and re-validate.
Read `REFINE_COUNT` from persisted state. If `.craft/.chunk-state` exists AND its `REFINE_CHUNK` matches the current chunk number, restore `REFINE_COUNT` from the file. Otherwise set `REFINE_COUNT=0`.
CHUNK_STATE="${CRAFT_PROJECT_ROOT:-.}/.craft/.chunk-state"
if [ -f "$CHUNK_STATE" ]; then
source "$CHUNK_STATE"
if [ "$REFINE_CHUNK" != "[current_chunk_number]" ]; then
REFINE_COUNT=0
fi
else
REFINE_COUNT=0
fiThis counter persists across context compactions and loop iterations. It never resets within a single chunk unless `.chunk-state` references a different chunk (stale from previous chunk).
Parse the `**Type:**` field from each error in the `**Errors:**` section of the chunk-validator output.
**Mixed error types:** If output contains BOTH `test-failure` AND non-test errors (type-error, lint-error, build-error), route to **refine-chunk first**. Type/build errors often cause test failures as a side effect - fixing code errors first may resolve tests too. If tests still fail after refine-chunk, the next loop iteration routes to test-fix.
**Before invoking ANY fix skill**, write a continuation breadcrumb so the stop hook catches premature stops:
cat > "${CRAFT_PROJECT_ROOT:-.}/.craft/.continuation" << CRUMB
ACTION: Fix skill returned. Re-validate this chunk NOW using chunk-validator agent via Task tool. Do NOT stop.
WRITTEN_BY: validate-fix-loop
TIMESTAMP: $(date -u +%Y-%m-%dT%H:%M:%S)
CRUMB**Test failures only** (`Type: test-failure`, no other error types):
Increment `REFINE_COUNT`.
Persist the counter:
cat > "${CRAFT_PROJECT_ROOT:-.}/.craft/.chunk-state" << STATE
REFINE_COUNT=$REFINE_COUNT
REFINE_CHUNK=[current_chunk_number]
STATE-> **INVOKE `craft:test-fix` using the Skill tool** with args:
"[STORY_FILE] - Chunk [CHUNK]. Test failures detected. CHUNK: [CHUNK value] CHUNK_GOAL: [goal from chunk spec] FAILING_TESTS: [File and Message from error block] ERRORS: [full error block text] FILES_CHANGED: [FILES_CHANGED value]"
After test-fix returns: 1. If verdict is "Test stale": test-fix updated the test. Continue to Step 3 (re-validate). Do NOT increment REFINE_COUNT again. 2. If verdict is "Code wrong" or "Compile error": continue to Step 3 (re-validate). REFINE_COUNT already incremented. 3. If verdict is "Ambiguous": user decides, then route accordingly.
**All other failures** (`Type: type-error`, `lint-error`, `build-error`):
Increment `REFINE_COUNT`.
Persist the counter:
cat > "${CRAFT_PROJECT_ROOT:-.}/.craft/.chunk-state" << STATE
REFINE_COUNT=$REFINE_COUNT
REFINE_CHUNK=[current_chunk_number]
STATE-> **INVOKE `craft:refine-chunk` using the Skill tool** with args:
"[STORY_FILE] - Chunk [CHUNK]. Validation errors need fixing. CHUNK: [CHUNK value] ERRORS: [full Errors section from agent output] FILES_CHANGED: [FILES_CHANGED value] REFINE_COUNT: [current count]"
After the fix skill returns (look for `>>> HAND BACK` in its output), re-invoke the chunk-validator agent **immediately**. Do not stop. Do not output a summary. Go directly back to the Task tool invocation:
Task tool:
subagent_type: "craft:chunk-validator"
model: "haiku"
description: "Re-validate chunk [CHUNK] after fix (attempt [REFINE_COUNT])"
prompt: "Run validation checks on this project.
CHUNK: [CHUNK value]
FILES_CHANGED: [FILES_CHANGED value]
PROJECT_ROOT: [PROJECT_ROOT value]
PM: [PM value]
STORY_FILE: [STORY_FILE value]
MODE: [per-chunk or story-final]"Parse the output:
Before each new fix attempt, check REFINE_COUNT:
**Before any rollback, salvage partial work:**
Use **Read** on the checkpoint file from Step 4 item 1 -> parse `git_ref:` -> `CHECKPOINT_REF`
SALVAGE_PATH=$(${CLAUDE_PLUGIN_ROOT}/hooks/scripts/salvage-partial-work.sh \
"$CHECKPOINT_REF" "[story-name]" [chunk_number] "${CRAFT_PROJECT_ROOT:-.}")${CLAUDE_PLUGIN_ROOT}/hooks/scripts/append-recovery-log.sh \
"${CRAFT_PROJECT_ROOT:-.}" "[story-name]" [chunk_number] \
"[failure_type]" "$SALVAGE_PATH" "$CHECKPOINT_REF" "[error_details]"When chunk-validator output contains CLI/infrastructure error patterns, capture as learnings. This does NOT change the verdict.
**Detection patterns:**
**When detected:** Read `.craft/.learnings.yaml`, add/merge enforcement entry:
enforcements:
- pattern: "[generalized pattern]"
evidence:
- source: cli_error
quote: "[raw error message]"
story: "[story name]"
date: [today's date]
occurrences: 1
status: pending
type: infrastructure##
Stop Vibing. Start Crafting. A Claude Code plugin that acts as an intelligent harness for your development workflow: your codebase is read-only by default, every change passes through a Write Gate as planned and approved work, and craft tracks your project's
Repo: drobins25/craft
Post-cycle analysis — QA, UX, Creative, and Style audits using MCP browser tools.
Consult a craft agent. Routes your question to the best mind in the workshop - not a menu, a recommendation.
Agent crystallization command. Studies a tool, role, or person and produces a portable 9-section agent that inhabits the domain - with beliefs, scar tissue,…
Complete a cycle. Triggers reflection if pending learnings, then archives.
Design a cycle — create new cycles with planned stories, detail existing planning cycles, or quick-sketch a roadmap. Detects planning docs in .craft/planning/…