en un clic
maestrodebugging
// Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
// Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
Use when bootstrapping, updating, or reviewing AGENTS.md — teaches what makes effective agent memory, how to structure sections, signal vs noise filtering, and when to prune stale entries
Use before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.
Deep discovery and specification for ambitious features. Full BMAD-inspired interview with classification, vision, journeys, domain analysis, and FR synthesis. Same output contract (spec.md + plan.md) as a standard feature but far richer. Use for multi-component systems, regulated domains, or unclear requirements.
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
Use when working with Docker containers — debugging container failures, writing Dockerfiles, docker-compose for integration tests, image optimization, or deploying containerized applications
Execute feature tasks following TDD workflow. Single-agent by default, --team for parallel Agent Teams, Sub Agent Parallels. Use when ready to implement a planned feature.
| name | maestro:debugging |
| description | Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes |
| stage | execution |
| audience | worker |
Random fixes waste time and create new bugs. Quick patches mask underlying issues.
Core principle: ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
Violating the letter of this process is violating the spirit of debugging.
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
If you haven't completed Phase 1, you cannot propose fixes.
Use for ANY technical issue:
Use this ESPECIALLY when:
Don't skip when:
Given a symptom, start with the highest-probability approach:
| Symptom | First Move | Tool |
|---|---|---|
| Runtime error / exception | Read full stack trace backward | bun test <file> 2>&1 | tail -80 |
| Type error (compile-time) | Find "expected X, got Y" mismatch source | rg 'type Y\b|interface Y\b' --type ts |
| Test passes alone, fails in suite | Shared state pollution | Run pairs: bun test a.test.ts b.test.ts |
| Flaky / intermittent | Reproduce in loop, add timestamps | for i in {1..50}; do bun test <file> || break; done |
| Performance issue | Measure before guessing | time bun run script.ts + instrumentation |
| Integration failure | Verify each boundary in isolation | curl each endpoint, check env vars |
| Build failure | Read the FIRST error only | bun run build 2>&1 | head -30 |
See reference/debugging-patterns.md for detailed workflows per symptom type.
You MUST complete each phase before proceeding to the next.
BEFORE attempting ANY fix, get a single command that triggers the bug.
Read Error Messages Carefully
# Get full error with context
bun test path/to/failing.test.ts 2>&1 | tail -80
# For deep stack traces
NODE_OPTIONS='--stack-trace-limit=50' bun run script.ts
Reproduce Consistently
# Run the specific failing test in isolation
bun test path/to/failing.test.ts --bail
# Reproduce with clean state
rm -rf node_modules/.cache dist/
bun install && bun test path/to/failing.test.ts
Check Recent Changes
# What changed since last green state?
git log --oneline -20
git diff HEAD~3 -- src/
# Binary search for breaking commit
git bisect start && git bisect bad HEAD && git bisect good <good-commit>
git bisect run bun test path/to/failing.test.ts
Narrow from "something broke" to "THIS line is the cause."
Trace Data Flow
# Find all assignments to the suspect variable
rg 'myVariable\s*=' --type ts -n
# Find all callers of the broken function
sg run -p 'brokenFunction($$$ARGS)' --lang typescript
# Find where an error is thrown
rg 'throw new.*ErrorMessage' --type ts -n -C 3
See root-cause-tracing.md for the complete backward tracing technique.
Gather Evidence at Boundaries (multi-component systems)
When system has multiple components (CI --> build --> signing, API --> service --> database):
For EACH component boundary:
- Log what data enters
- Log what data exits
- Verify environment/config propagation
Run once --> read output --> identify failing boundary
# Example: identify which layer fails
echo "=== Layer 1: Workflow ==="
echo "IDENTITY: ${IDENTITY:+SET}${IDENTITY:-UNSET}"
echo "=== Layer 2: Build script ==="
env | grep IDENTITY || echo "IDENTITY not in environment"
echo "=== Layer 3: Signing ==="
security find-identity -v
Find Working Examples and Compare
# Find working examples of the same pattern
sg run -p 'workingPattern($$$ARGS)' --lang typescript
rg 'similarFunction\(' --type ts --files-with-matches
Scientific method -- one variable at a time.
Form Single Hypothesis
Test Minimally
Evaluate
When You Don't Know
Fix the root cause, not the symptom.
Create Failing Test Case
# Write the test
# (use maestro skill maestro:tdd for proper TDD technique)
# MUST fail before you fix
bun test path/to/module.test.ts --bail
# Expected: FAIL
Implement Single Fix
Verify Completely
# Regression test passes
bun test path/to/module.test.ts --bail
# Full suite passes
bun test
# Build succeeds
bun run build
# For flaky bugs: run multiple times
for i in {1..20}; do bun test path/to/module.test.ts || break; done
# Check for sibling bugs (same broken pattern elsewhere)
rg 'the-broken-pattern' --type ts --files-with-matches
If Fix Doesn't Work
If 3+ Fixes Failed: Question Architecture
Pattern indicating architectural problem:
STOP and question fundamentals:
Discuss with your human partner before attempting more fixes.
This is NOT a failed hypothesis -- this is a wrong architecture.
as any, @ts-ignore, or // eslint-disable to silence errors| Pattern in Diff | What It Means |
|---|---|
as any or as unknown as X | Silencing the type system, not fixing the mismatch |
?. chains added defensively | Hiding null propagation instead of fixing the source |
try { } catch { } with empty catch | Swallowing errors that need handling |
setTimeout / sleep added | Papering over a race condition |
// TODO: fix later | You know it's wrong and you're shipping it anyway |
| Multiple files changed for "one fix" | You're doing shotgun debugging |
ALL of these mean: STOP. Return to Phase 1.
If 3+ fixes failed: Question the architecture (see Phase 4, step 5).
Watch for these redirections:
When you see these: STOP. Return to Phase 1.
| Excuse | Reality |
|---|---|
| "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
| "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
| "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
| "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
| Phase | Key Activities | Success Criteria |
|---|---|---|
| 1. Root Cause | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |
| 2. Pattern | Find working examples, compare | Identify differences |
| 3. Hypothesis | Form theory, test minimally | Confirmed or new hypothesis |
| 4. Implementation | Create test, fix, verify | Bug resolved, tests pass |
If systematic investigation reveals issue is truly environmental, timing-dependent, or external:
But: 95% of "no root cause" cases are incomplete investigation.
In this directory:
reference/debugging-patterns.md - Concrete workflows per symptom type: runtime errors, type errors, test failures, performance, integration. Decision tree, tool commands, anti-patterns.root-cause-tracing.md - Trace bugs backward through call stack to find original triggerdefense-in-depth.md - Add validation at multiple layers after finding root causecondition-based-waiting.md - Replace arbitrary timeouts with condition pollingRelated skills:
From debugging sessions: