.claude/skills/dan-bugsweep/SKILL.md
Spawn auditor agent in a recursive loop to find and fix bugs across a phase
npx skillsauth add RavBogard/DAN dan:bugsweepInstall 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.
Spawn a dan-auditor agent in a recursive loop to find and fix bugs across all code produced in a phase. The auditor runs until no more issues are found or the iteration limit is reached.
Spawns dan-auditor subagent. Recursive loop orchestrated from skill level.
State operations use the DAN CLI:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd $PROJECT_DIR state set "Status" "Bug sweeping"
<execution_flow>
<step name="load_phase"> ## Step 1: Load PhaseParse the phase number argument. Resolve the phase directory. Collect key files from all SUMMARY.md files.
# Resolve phase directory
PHASE_DIR=$(node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" phase find "$PHASE_NUM")
PADDED=$(printf '%02d' "$PHASE_NUM")
Read all *-SUMMARY.md files in the phase directory. Extract the key-files frontmatter from each to build the list of files the auditor should inspect.
Initialize loop state:
MAX_CYCLES = 3
cycle = 0
previous_issues = []
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state set "Status" "Bug sweeping phase $PHASE_NUM"
</step>
<step name="bugsweep_loop">
## Step 2: Bugsweep Loop (bugsweep_loop)
Core recursive loop. Runs while cycle < MAX_CYCLES:
cycle += 1
Spawn a dan-verifier agent to produce a fresh VERIFICATION.md. This ensures the auditor always works from current state, not stale results.
Task(
prompt="You are verifying Phase {PHASE_NUM} deliverables (bugsweep cycle {cycle}).
Read the plan files and run verification commands:
node \"$HOME/.claude/dan/bin/dan-tools.cjs\" --cwd \"$PROJECT_DIR\" verify artifacts {plan-path}
node \"$HOME/.claude/dan/bin/dan-tools.cjs\" --cwd \"$PROJECT_DIR\" verify key-links {plan-path}
node \"$HOME/.claude/dan/bin/dan-tools.cjs\" --cwd \"$PROJECT_DIR\" verify phase-completeness {PHASE_NUM}
node --test bin/tests/
Write results to: {PHASE_DIR}/{PADDED}-VERIFICATION.md",
subagent_type="dan-verifier",
description="verify cycle {cycle}"
)
Read the generated VERIFICATION.md. Extract:
status from frontmatterIf no issues found (status == "passed" and issues list is empty): go to complete.
If cycle > 1, compare current issues to previous cycle's issues using the CLI fingerprinting tool:
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" verify recurring \
--current '["issue 1 text", "issue 2 text"]' \
--previous '["prev issue 1", "prev issue 2"]'
Parse the JSON output: { recurring_count, total_current, ratio, should_escalate }.
If should_escalate is true (recurring ratio > 50%): go to escalate.
Set previous_issues = current_issues (the raw issue text list).
Spawn a dan-auditor agent with the issues to fix:
Task(
prompt="You are fixing issues found during Phase {PHASE_NUM} verification (bugsweep cycle {cycle}).
Read the verification report: {PHASE_DIR}/{PADDED}-VERIFICATION.md
Issues to address:
{numbered issues list}
Key files in this phase:
{key_files list from SUMMARY.md files}
For each issue:
1. Classify it first:
node \"$HOME/.claude/dan/bin/dan-tools.cjs\" --cwd \"$PROJECT_DIR\" qualify classify-failure \"<issue-description>\"
2. If classification is 'code': fix it, run tests, commit atomically:
node \"$HOME/.claude/dan/bin/dan-tools.cjs\" --cwd \"$PROJECT_DIR\" commit \"fix(phase-{N}): <description>\" --files <changed-files>
3. If classification is 'intent' or 'spec': escalate (do not fix).
After all fixes, run the test suite: node --test bin/tests/
Report what was fixed and what was escalated.",
subagent_type="dan-auditor",
description="fix cycle {cycle}"
)
If cycle == MAX_CYCLES: go to escalate.
Otherwise: go back to step 2a (next cycle).
</step>
Reached when: max cycles exhausted OR diminishing returns detected.
Update VERIFICATION.md bugsweep history table with cycle results.
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state set "Status" "Bugsweep escalated after $cycle cycles"
Report to user:
## Bugsweep Escalated
**Phase:** {PHASE_NUM}
**Cycles completed:** {cycle}
**Reason:** {max cycles reached | diminishing returns detected}
**Remaining issues:** {count}
### Issues Requiring Human Attention
{numbered list of remaining issues with classification and evidence}
### Bugsweep History
| Cycle | Issues Found | Issues Fixed | Recurring | Action |
|-------|-------------|-------------|-----------|--------|
| 1 | N | M | - | fix |
| 2 | N | M | K | fix/escalate |
</step>
<step name="complete">
## Step 4: Complete
Reached when verification passes with no issues.
Update VERIFICATION.md: set status: passed, bugsweep_cycles: {cycle}.
node "$HOME/.claude/dan/bin/dan-tools.cjs" --cwd "$PROJECT_DIR" state set "Status" "Phase $PHASE_NUM verified clean after $cycle cycles"
Report to user:
## Bugsweep Complete
**Phase:** {PHASE_NUM}
**Status:** Clean pass
**Cycles:** {cycle}
**All issues resolved.** Phase deliverables verified.
</step>
</execution_flow>
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