bug-hunter-agent
Specialist bug and weakness hunter for any codebase: logic errors, edge cases, error handling, races, data integrity, config bugs, performance, integration gaps, and security surface triage. Fixes iso
SKILL.md.copilot/skills/bug-hunter-agent/SKILL.md
GitHubBug Hunter Agent
Purpose: Find any bug, potential bug, or weakness in the project codebase — then fix (when safe) or suggest fixes with evidence and tests.
Cache is king: load manifest + CONCERNS + CONVENTIONS + TESTING before deep source reads.
Complements (do not duplicate):
| Skill | Role in bug hunting |
|---|---|
| security-audit-agent | Deep auth/secrets/OWASP after your surface triage |
| cyber-security-essentials | UK NCSC Cyber Essentials five-control mapping before hunt |
| schema-audit-agent / model-schema-check | Schema and migration drift |
| project-drift-guardian | Scope, CI, deploy, requirements drift |
| test-safety-agent | Gate before any test run |
| test-specialist-agent | Tests for findings and regressions |
| laravel-expert-agent | Framework-specific fixes (Laravel/Filament) |
Phase 0 — Load context (required)
.github/project-manifest.yamlor.claude/project-manifest.yaml— stack, paths, test commanddocs/codebase/CONCERNS.md— known risksdocs/codebase/CONVENTIONS.md+docs/codebase/TESTING.md- Latest
TODO/*.md— in-scope work - User scope from
$ARGUMENTS(module, path, PR, orwhole codebase)
Phase 1 — Mode
Parse argument for mode (default scan):
| Mode | Keywords | Output |
|---|---|---|
| scan | scan, review, audit bugs | Report only |
| deep | deep, thorough, comprehensive | Full taxonomy pass |
| fix | fix, repair, patch | Report + safe fixes + tests |
| pre-deploy | pre-deploy, release, ship | Regressions, config, idempotency |
Emit: Bug hunter: mode=<mode> scope=<scope>
Phase 2 — Static scan (fast signals)
Run via script (never inline heredoc — .github/skills/script-not-shell/SKILL.md):
mkdir -p reports/bugs
bash .github/skills/bug-hunter-agent/scripts/bug-hunter-scan.sh . reports/bugs/scan-$(date +%Y%m%d).txt
Triage scan hits; confirm in source before reporting.
Phase 3 — Deep hunt (taxonomy)
Read and apply every applicable category in references/bug-taxonomy.md.
Hunt method (token-efficient):
- Grep for risk patterns in scope (errors, null, raw SQL, TODO, catch blocks)
- Read hot paths: controllers/services, jobs, webhooks, payment/auth flows
- Trace happy path + one failure path per critical feature
- Check tests exist for critical paths; note gaps as weaknesses
- Cross-check cache ARCHITECTURE vs actual entrypoints
Embody full agent contract: .github/agents/bug-hunter-agent.md
Phase 4 — Report
Write reports/bugs/YYYY-MM-DD-bug-hunt[-scope].md using references/report-template.md.
Severity: critical | high | medium | low | info
Status: open | fixed | suggested | delegated
Include code citations for every finding.
Phase 5 — Fix (mode=fix or user approves)
Rollback is mandatory. No patch without a backup session. See references/rollback.md.
Init backup (before any file write):
BACKUP_ID=$(python3 .github/skills/bug-hunter-agent/scripts/bug-hunt-backup.py init --scope "<scope>" --mode fix)Confirm branch scope (
/branch-context-agentif large change)For each file about to change:
bug-hunt-backup.py backup --backup-id "$BACKUP_ID" <rel/path>Apply low/medium isolated fixes only
Critical security fixes (critical + security category): if applied,
mark-exempt— these survive rollbackcritical/high (non-security) — suggest only unless user explicitly approves
Run
/test-safety-agentbefore testsRun project test command (DDEV if manifest says so)
Update report with fix log,
backup_id, androllback_cmdbug-hunt-backup.py finalize --backup-id "$BACKUP_ID" --report <report-path>
Phase 6 — Handoffs (chain or follow-up)
Emit ≤80 token handoff for chains:
bug_hunt: N findings (C/H/M/L); fixed=X; tests=pass|fail|skipped
security_pending: [IDs or none]
test_gaps: [cases or none]
drift_flags: [yes/no]
Fix policy (chains and direct invoke)
| Severity / area | Action |
|---|---|
| low / medium (isolated) | Auto-fix in fix mode; run tests after |
| critical / high | Suggest patch only — unless user explicitly approves in args |
| auth, payment, crypto, permissions | Never auto-fix without explicit approval (fix_policy.require_approval_for) |
| Report | Always write report; append fix log when patches applied |
| Rollback | Required backup before fixes; rollback restores all except critical security exempt |
Set handoff fixes_applied: true and backup_id: <id> when any file changed.
Rollback after fix:
python3 .github/skills/bug-hunter-agent/scripts/bug-hunt-backup.py rollback --backup-id <id>
Critical security patches listed in report as rollback_exempt: true are not reverted.
Chain invocation
| Chain | Mode | Use when |
|---|---|---|
.github/skills/chain/SKILL.md bug-hunt |
scan | Report only — quick hunt |
.github/skills/chain/SKILL.md bug-hunt-fix |
fix | Hunt + safe fixes + test safety + tests |
.github/skills/chain/SKILL.md bug-hunt-deep |
deep | Full report + security + schema + test gaps |
.github/skills/chain/SKILL.md bug-hunt-fix-deep |
deep fix | Hunt/fix + security + mandatory test verification |
.github/skills/chain/SKILL.md bug-hunt-pre-deploy |
pre-deploy | Report before release |
.github/skills/chain/SKILL.md bug-hunt-pre-deploy-fix |
pre-deploy fix | Drift gate + fixes before ship |
Append scope to any chain: .github/skills/chain/SKILL.md bug-hunt-fix auth module
Direct: /bug-hunter-agent payments module fix
Anti-patterns
- "LGTM" without source evidence
- Style-only nitpicks as high severity
- Full security audit instead of handoff
- Tests on live database
- Auto-fixing auth/payment/crypto without approval
- Skipping report artifact
- Applying fixes without
bug-hunt-backup.pysession - Rolling back critical security exempt fixes
Related
- Taxonomy:
references/bug-taxonomy.md - Report template:
references/report-template.md - Scan script:
scripts/bug-hunter-scan.sh - Registry chains:
chains/registry.yaml→bug-hunt*