.claude/skills/dan-apply/SKILL.md
Execute plan tasks with optional E/Q qualification loop
npx skillsauth add RavBogard/DAN dan:applyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Execute plan tasks. Default mode is in-session execution. For plans requiring qualification, spawns a dan-qualifier agent to independently verify each task output.
wave frontmatter)Default: in-session execution. Spawns dan-qualifier subagent for E/Q protocol when plan specifies it.
State, config, and commit operations use the DAN CLI:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd $PROJECT_DIR state set "Plan" "2 of 4 in current phase"
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd $PROJECT_DIR commit "feat(01-03): implement skill entry points" --files .claude/skills/dan-plan/SKILL.md
<execution_flow>
<step name="load_plan" priority="first"> ## Step 1: Load PlanAccept argument: either a file path to a PLAN.md, or a phase number (e.g., 2).
If phase number: Find the first actionable plan in the phase directory:
PHASE_DIR=".planning/phases/$(ls .planning/phases/ | grep "^0${PHASE_NUM}-" | head -1)"
For each *-PLAN.md in $PHASE_DIR, parse frontmatter:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" frontmatter parse "$PLAN_FILE"
Select the first plan with status: APPROVED (or status: IN_PROGRESS for resume).
If file path: Use the path directly.
Parse the plan file:
phase, plan, status, depends_on, files_modified, requirements<objective> text<task> element: name, type, files, action, verify, done, tdd attributeTOTAL_TASKSStatus check:
status is APPROVED: proceed to step 2 (fresh start)status is IN_PROGRESS: read STATE.md for checkpoint:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state get "Last activity"
Parse the last completed task number from the state activity text (e.g., "Task 2 of 5 complete" means resume from task 3).status is COMPLETED or ABANDONED: report "Plan already finished" and stop.status is DRAFT: report "Plan not yet approved. Run /dan:plan to review." and stop.Load persisted retry counts from STATE.md:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state get "retry_counts"
If the field exists, parse the JSON map (e.g., {"task1": 1, "task3": 2}). Otherwise initialize RETRY_COUNTS = {}.
Transition plan status from APPROVED to IN_PROGRESS:
# Validate the transition is allowed
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" lifecycle validate APPROVED IN_PROGRESS
# Apply the transition
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" frontmatter set "$PLAN_PATH" status IN_PROGRESS
If the plan is already IN_PROGRESS (resume case), skip this step.
Update STATE.md with execution start:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state set "Last activity" "$(date +%Y-%m-%d) -- Plan ${PHASE}-${PLAN} in progress, Task 0 of ${TOTAL_TASKS}"
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state set "Status" "In progress"
Initialize retry tracking:
RETRY_COUNTS = {}Set starting task index:
CURRENT_TASK = 1CURRENT_TASK = last_completed + 1
</step>
Loop from CURRENT_TASK to TOTAL_TASKS:
<action> instructions from the plan.<files> list to know which files to create or modify.tdd="true":
<behavior> spec, run them, confirm they fail<verify> command:
# Execute the automated verification from the task
${VERIFY_COMMAND}
If verification fails, diagnose and fix (deviation Rule 1: auto-fix bugs).node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" commit "${TYPE}(${PHASE}-${PLAN}): ${TASK_NAME}" --files ${FILE_LIST}
Record the commit hash: TASK_COMMIT=$(git rev-parse --short HEAD)Spawn dan-qualifier agent with this context:
<done> criteria textParse qualifier output using parseQualifierOutput() logic:
status, task, criteria, evidence, issues from the qualifier's markdown response**Status:** <VALUE> with one of: PASS, PASS_WITH_CONCERNS, NEEDS_REVISION, FAILRoute based on status:
PASS:
PASS_WITH_CONCERNS:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state set "Last activity" "$(date +%Y-%m-%d) -- Task ${N}: PASS_WITH_CONCERNS - ${CONCERNS_SUMMARY}"
NEEDS_REVISION:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" qualify should-retry NEEDS_REVISION ${RETRY_COUNTS[taskN]} 3
retry: true (retries < 3):
issues listfix(${PHASE}-${PLAN}): revise task ${N} - attempt ${RETRY_COUNT}RETRY_COUNTS[taskN] += 1node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state patch '{"retry_counts": ${JSON.stringify(RETRY_COUNTS)}}'
retry: false (retries >= 3):
FAIL:
Update STATE.md with progress:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state set "Last activity" "$(date +%Y-%m-%d) -- Plan ${PHASE}-${PLAN} in progress, Task ${N} of ${TOTAL_TASKS} complete"
Persist current retry_counts map to STATE.md:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state patch '{"retry_counts": ${JSON.stringify(RETRY_COUNTS)}}'
This ensures retry state survives session restarts.
Increment CURRENT_TASK and continue to next task.
Gather evidence:
<task> XML element from the planevidence and issues fields from qualifier output<objective> text from the planClassify the failure using classifyFailure() logic:
# Write task spec and evidence to temp files, then classify
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" qualify classify "$TASK_SPEC_FILE" "$EVIDENCE_FILE" "$OBJECTIVE_TEXT"
Returns { classification: "intent"|"spec"|"code", reasoning: string }
Route based on classification:
INTENT (wrong goal -- the plan targets the wrong thing):
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state set "Last activity" "$(date +%Y-%m-%d) -- Task ${N} FAIL: intent mismatch. Plan objective needs revision."
SPEC (wrong plan -- the task description is incorrect or incomplete):
RETRY_COUNTS[taskN] = 0CODE (wrong implementation -- the code does not match the spec):
Log classification in STATE.md decisions:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state set "Last activity" "$(date +%Y-%m-%d) -- Diagnostic: Task ${N} classified as ${CLASSIFICATION}: ${REASONING}"
Transition plan status to COMPLETED:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" lifecycle validate IN_PROGRESS COMPLETED
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" frontmatter set "$PLAN_PATH" status COMPLETED
Clear retry_counts from STATE.md (loop is complete):
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state patch '{"retry_counts": null}'
Update STATE.md with completion:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state set "Last activity" "$(date +%Y-%m-%d) -- Plan ${PHASE}-${PLAN} complete, ready for unify"
Offer next action: Report: "Plan ${PHASE}-${PLAN} complete. All ${TOTAL_TASKS} tasks passed qualification. Run /dan:unify to close the loop and produce SUMMARY.md."
Leave plan as IN_PROGRESS -- do not transition to COMPLETED or ABANDONED.
Persist checkpoint with last completed task:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state set "Last activity" "$(date +%Y-%m-%d) -- Plan ${PHASE}-${PLAN} paused at Task ${LAST_COMPLETED} of ${TOTAL_TASKS}"
Persist retry_counts to STATE.md so next session can resume:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state patch '{"retry_counts": ${JSON.stringify(RETRY_COUNTS)}}'
Log reason for interruption in STATE.md.
</step></execution_flow>
Default: in-session execution. Tasks are executed directly in the current session with full tool access (Read, Write, Edit, Bash, Glob, Grep). This preserves maximum context for best implementation quality.
Qualification: always via dan-qualifier subagent. After each task, a dan-qualifier agent is spawned in a separate context to independently grade the output. The qualifier has read-only tools (Read, Grep, Glob, Bash for verification only). The executor and qualifier NEVER share context -- this separation is the core quality guarantee.
Why in-session? Research shows subagent execution loses approximately 30% quality due to context loss. The executor operates in-session by default. The dan-executor agent definition exists as future-prep for Phase 5 wave parallelization, where multiple tasks may need to execute in parallel subagents.
data-ai
Core DAN workflow protocol and conventions injected into all agent contexts
testing
Spawn verifier agent to validate phase outputs against requirements and success criteria
tools
Close the loop on a completed plan by writing SUMMARY.md and updating state
tools
Show current project progress, blockers, and suggest the next action