.claude/skills/bugs/SKILL.md
Bug hunting with Codex CLI Use when: (1) /bugs is invoked, (2) task relates to bugs functionality.
npx skillsauth add alfredolopez80/multi-agent-ralph-loop bugsInstall 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.
Deep bug analysis using Codex gpt-5.2-codex with the bug-hunter skill and TLDR context optimization.
~/.claude/settings.json or CLI/env varsANTHROPIC_DEFAULT_*_MODEL env varsOptimal Scenario: Pure Custom Subagents
This skill uses Pure Custom Subagents (no Agent Teams) for specialized, focused bug analysis.
Task(subagent_type="ralph-reviewer", prompt="Analyze $TARGET for bugs...")
→ Agent executes with restricted tools (no Write/Edit)
→ Returns structured bug findings
→ Complete (no team cleanup needed)
When analyzing directories with many files:
# Spawn multiple reviewers in parallel (no team needed)
Task(subagent_type="ralph-reviewer", prompt="Analyze files 1-10...")
Task(subagent_type="ralph-reviewer", prompt="Analyze files 11-20...")
Task(subagent_type="ralph-reviewer", prompt="Analyze files 21-30...")
# Aggregate results manually or via simple script
AUTOMATIC - Before bug hunting, gather context with 95% token savings:
# Get function signatures and call flow
tldr context "$TARGET_FILE" . > /tmp/bugs-context.md
# Get dependency graph for tracking bug propagation
tldr deps "$TARGET_FILE" . > /tmp/bugs-deps.md
# Get codebase structure for understanding module relationships
tldr structure . > /tmp/bugs-structure.md
# Semantic search for error handling patterns
tldr semantic "try catch error exception throw" .
The /bugs command performs comprehensive static analysis using TLDR-compressed context to identify potential bugs, logic errors, race conditions, edge cases, and other code issues that could cause runtime failures or unexpected behavior. It uses Codex GPT-5.2 model with specialized bug-hunting capabilities to analyze code paths, detect anti-patterns, and suggest fixes.
Unlike traditional linters, Codex bug hunting performs deep semantic analysis:
Use /bugs when:
Codex bug hunting follows a systematic approach:
| Category | Examples | Severity | |----------|----------|----------| | Logic Errors | Off-by-one, incorrect conditions, wrong operators | HIGH | | Race Conditions | Unprotected shared state, TOCTOU bugs | HIGH | | Memory Issues | Leaks, use-after-free, buffer overflows | CRITICAL | | Type Errors | Implicit conversions, type coercion bugs | MEDIUM | | Error Handling | Uncaught exceptions, missing null checks | HIGH | | Edge Cases | Empty arrays, boundary values, overflow | MEDIUM | | Async Issues | Unhandled promises, callback hell, deadlocks | HIGH | | Security Bugs | Injection, XSS, CSRF (see /security for full audit) | CRITICAL |
# Bug hunt on specific file
ralph bugs src/auth/login.ts
# Bug hunt on directory
ralph bugs src/components/
# Bug hunt on entire codebase
ralph bugs .
# Background execution with logging
ralph bugs src/ > bugs-report.json 2>&1 &
Use the Task tool to invoke Codex bug hunting with TLDR context:
Task:
subagent_type: "debugger"
model: "sonnet"
run_in_background: true
description: "Codex bug hunting analysis"
prompt: |
# Context (95% token savings via tldr)
Structure: $(tldr structure .)
File Context: $(tldr context $ARGUMENTS .)
Dependencies: $(tldr deps $ARGUMENTS .)
Execute Codex bug hunting via CLI:
cd ~/Documents/GitHub/multi-agent-ralph-loop && \
codex exec --yolo --enable-skills -m gpt-5.2-codex \
"Use bug-hunter skill. Find bugs in: $ARGUMENTS
Output JSON: {
bugs: [
{
severity: 'CRITICAL|HIGH|MEDIUM|LOW',
type: 'logic|race|memory|type|error-handling|edge-case|async|security',
file: 'path/to/file.ts',
line: 42,
description: 'Clear bug description',
fix: 'Concrete remediation steps'
}
],
summary: {
total: 5,
high: 2,
medium: 2,
low: 1,
approved: false
}
}"
Apply Ralph Loop: iterate until all HIGH+ bugs are resolved or approved.
For immediate results without Task orchestration:
codex exec --yolo --enable-skills -m gpt-5.2-codex \
"Use bug-hunter skill. Find bugs in: src/
Focus on:
- Race conditions in async code
- Uncaught promise rejections
- Type coercion issues
- Edge case handling
Output JSON with severity, type, file, line, description, fix"
The bug hunting analysis returns structured JSON:
{
"bugs": [
{
"severity": "HIGH",
"type": "race",
"file": "src/auth/session.ts",
"line": 87,
"description": "Race condition: session.user accessed before async initialization completes",
"fix": "Add await before accessing session.user, or use Promise.all() to ensure initialization"
},
{
"severity": "MEDIUM",
"type": "edge-case",
"file": "src/utils/parser.ts",
"line": 23,
"description": "Empty array not handled: arr[0] will throw if arr is empty",
"fix": "Add guard: if (arr.length === 0) return null; before accessing arr[0]"
}
],
"summary": {
"total": 2,
"high": 1,
"medium": 1,
"low": 0,
"approved": false
}
}
| Severity | Meaning | Action | |----------|---------|--------| | CRITICAL | Production-breaking, security issues | MUST FIX before merge | | HIGH | Likely to cause failures, data corruption | SHOULD FIX before merge | | MEDIUM | Edge cases, potential issues under load | Review and decide | | LOW | Code smells, minor improvements | Optional fix |
The /bugs command integrates with other Ralph workflows:
Task:
subagent_type: "debugger"
model: "opus" # Opus for deep analysis
description: "Full debugging workflow"
prompt: |
1. Run /bugs on $TARGET
2. Analyze top 5 HIGH severity bugs
3. Trace execution paths to root cause
4. Propose fixes with test cases
5. Validate fixes pass quality gates
When a bug fix needs a clarified spec:
# Step 1: Bug hunting
ralph bugs src/payment/
# Step 2: Draft a short spec for the fix
ralph adversarial "Draft: Fix payment retry logic with idempotency"
Generate tests that specifically target discovered bugs:
Task:
subagent_type: "test-architect"
model: "sonnet"
prompt: |
Read bugs-report.json
For each HIGH/CRITICAL bug:
- Write failing test that reproduces bug
- Verify test fails before fix
- Apply fix from bug report
- Verify test passes after fix
Use TDD pattern: RED → FIX → GREEN
| Command | Purpose | When to Use |
|---------|---------|-------------|
| /security | Security-focused audit (CWE checks) | Before production deploy |
| /unit-tests | Generate test coverage | After bug fixes |
| /refactor | Improve code structure | After identifying patterns |
| /adversarial | Adversarial spec refinement | Critical code paths |
| /full-review | Comprehensive analysis (6 agents) | Major features/releases |
The /bugs command follows the Ralph Loop pattern with these hooks:
┌─────────────────────────────────────────────────────────┐
│ RALPH LOOP: Bug Hunting │
├─────────────────────────────────────────────────────────┤
│ │
│ 1. EXECUTE → codex exec bug-hunter │
│ 2. VALIDATE → Check severity counts │
│ 3. ITERATE → Fix HIGH+ bugs │
│ 4. VERIFY → Re-run until summary.approved = true │
│ │
│ Quality Gate: No HIGH+ bugs OR all explicitly approved │
│ Max Iterations: 15 (Codex GPT-5.2) │
│ │
└─────────────────────────────────────────────────────────┘
The bug hunting loop continues until:
Full bug hunting and remediation workflow:
# 1. Initial bug scan
ralph bugs src/
# 2. Review report
cat .claude/tmp/codex_bugs.json | jq '.summary'
# 3. Fix HIGH severity bugs
# (manual or via /refactor)
# 4. Verify fixes
ralph bugs src/ # Should show reduced bug count
# 5. Generate regression tests
ralph unit-tests src/
# 6. Run quality gates
ralph gates
# 7. Final approval (if LOW bugs remain)
# Add to bugs-report.json: "approved": true, "justification": "Low risk edge cases"
--model opus for payment/auth/crypto code| Model | Cost | Speed | When to Use | |-------|------|-------|-------------| | GPT-5.2-Codex | ~15% | Fast | Default for bug hunting | | Opus | 100% | Slow | Critical code paths | | Sonnet | 60% | Medium | Task orchestration only |
Recommended: Codex GPT-5.2 for bug hunting (optimized for code analysis)
Esta skill genera reportes automáticos completos para trazabilidad:
Cuando esta skill completa, se genera automáticamente:
docs/actions/bugs/{timestamp}.md.claude/metadata/actions/bugs/{timestamp}.jsonCada reporte incluye:
# Listar todos los reportes de esta skill
ls -lt docs/actions/bugs/
# Ver el reporte más reciente
cat $(ls -t docs/actions/bugs/*.md | head -1)
# Buscar reportes fallidos
grep -l "Status: FAILED" docs/actions/bugs/*.md
source .claude/lib/action-report-lib.sh
start_action_report "bugs" "Task description"
# ... ejecución ...
complete_action_report "success" "Summary" "Recommendations"
development
Living knowledge base management. Actions: search (query vault), save (store learning), index (update indices), compile (raw->wiki->rules graduation), init (create vault structure). Follows Karpathy pipeline: ingest->compile->query. Use when: (1) searching accumulated knowledge, (2) saving learnings, (3) compiling raw notes into wiki, (4) initializing a new vault. Triggers: /vault, 'vault search', 'knowledge base', 'save learning'.
testing
Produce a verifiable technical specification before coding. 6 mandatory sections: Interfaces, Behaviors, Invariants (from Aristotle Phase 2), File Plan, Test Plan, Exit Criteria (executable bash commands + expected results). Use when: (1) before implementing features with complexity > 4, (2) as Step 1.5 in orchestrator workflow, (3) when requirements need formalization. Triggers: /spec, 'create spec', 'write specification', 'technical spec'.
testing
Pre-launch shipping checklist orchestrating /gates, /security, /browser-test, /perf. Ensures nothing ships without passing all quality checks. Use when: (1) before deploying, (2) before merging to main, (3) before release. Triggers: /ship, 'ship it', 'ready to deploy', 'pre-launch check'.
development
Performance optimization skill. Core Web Vitals via Lighthouse, bundle size analysis, metrics tracking over time. Use when: (1) optimizing frontend performance, (2) analyzing bundle size, (3) tracking metrics regression. Triggers: /perf, 'performance audit', 'core web vitals', 'bundle size'.