Service debugging

From c0x12c/ai-toolkit · View interactive version

Service debugging is an AI agent skill from the GitHub repository c0x12c/ai-toolkit. Structured debugging runbook for backend services. Use when investigating production issues, API errors, performance problems, or when something broke and you need to find why.

How to use this skill

Skill file

Service Debugging

Structured approach to investigating and fixing service issues. Symptoms in, root cause out.

When to Use

Process

1. Gather Symptoms

Before touching code, collect:

2. Check the Obvious

Run these first — they catch 80% of issues:

# Recent deploys (did someone push something?)
git log --oneline -10

# Service health
curl -s http://localhost:8080/health | jq .

# Recent errors in logs
grep -i "error\|exception\|fatal" logs/app.log | tail -20

# Database connectivity
psql -h $DB_HOST -U $DB_USER -d $DB_NAME -c "SELECT 1"

# Environment variables (missing or wrong?)
env | grep -i "DB_\|API_\|SECRET_" | sort

3. Narrow Down

| Symptom | Check First |

|---------|-------------|

| 500 errors | Stack trace in logs → find the throwing line |

| 404 errors | Route registration → is the controller loaded? |

| 401/403 errors | Auth config → is @Secured correct? Token valid? |

| Slow response | Database → run EXPLAIN on the slow query |

| Timeout | External service → is the downstream API responding? |

| Data missing | Soft delete → is deleted_at set? Wrong query filter? |

| Service won't start | Bean creation → check @Factory and @Singleton wiring |

4. Reproduce

5. Find Root Cause

Use git bisect if it's a regression:

git bisect start
git bisect bad HEAD
git bisect good <last-known-good-commit>
# Test each commit until you find the one that broke it

Use grep to find related code:

# Find where the error message comes from
grep -r "error message text" --include="*.kt" src/

# Find all callers of a broken function
grep -r "functionName" --include="*.kt" src/

6. Fix and Verify

  1. Write a test that reproduces the bug (red)
  2. Fix the code (green)
  3. Run full test suite
  4. Test manually if it's a user-facing issue

See common-issues.md for a catalog of frequently seen bugs and their fixes.

Gotchas

Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.