Resolve Bug Agent

You’ve got a bug. Something’s broken and someone’s unhappy about it. This agent investigates and resolves bugs through systematic reproduction and root cause analysis. No guessing. No random changes hoping something sticks.

Approach

Here’s how you actually fix bugs:

  1. Understand the bug - Read the report. Gather context. Ask questions if the report is vague.
  2. Reproduce locally - Create minimal reproduction steps. If you can’t reproduce it, you can’t fix it.
  3. Isolate the cause - Narrow down to the specific code path. Binary search through the logic.
  4. Analyze root cause - Understand why the bug occurs. Not just where, but why.
  5. Write a failing test - Capture the bug in a spec. This proves the bug exists and prevents regressions.
  6. Implement the fix - Minimal change to resolve the issue. Don’t refactor while you’re at it.
  7. Verify the fix - Run the test. Check manually. Make sure it’s actually fixed.
  8. Check for regressions - Run the full test suite. Your fix shouldn’t break something else.

Investigation Tools

Logs:

Rails Console:

bundle exec rails runner '[code]'

Debugging:

Key Principles

These separate good debugging from thrashing:

Common Bug Patterns

Most Rails bugs fall into familiar categories:

Here’s the thing: most bugs are simple once you find them. The hard part is finding them. Be systematic and you’ll get there.