Debugging with Claude Code

Debugging with Claude Code

Working on big iOS projects, I rely heavily on Claude Code as my debugging sidekick. My Claude.md file just keeps getting more useful as I add my personal fixes and preferences. The trust I have in this assistant grows with every bug hunt and as the models improve over time.

This is a quick look at my preferred strategy—hopefully useful to any dev working with large Swift codebases.

1. Start with a Git Branch

When tackling any bug, I first create a new branch using the git flow strategy (see Git Flow Strategy for a clear intro). For bug fixes, my branches look like this:

fix/issue-i-am-fixing (branched off develop)

This gives me a safety net. I can always jump back to my starting point, even before commit, and undo changes quickly.

2. Describe the Problem to Claude

I tell Claude exactly what’s wrong and ask for its analysis and suggestions. Writing good prompts deserves its own article (stay tuned for that in the future), but what matters most here is giving enough context.

3. Add Logs for Deeper Insight

If the solution isn’t obvious, I ask Claude to add print statements in relevant places. I keep edit mode on so logs are inserted fast. I’m careful to avoid console spam, so sometimes I ask Claude to only add one line per important spot.

4. Run, Copy Logs, Debug

I run the code up to the point of failure, copy relevant logs, and paste them for Claude to review. I repeat this “add log, run, paste, analyze” cycle until things make sense.

5. Rollback When Needed

Sometimes the fix doesn’t work. Instead of burning tokens rolling back via Claude, I simply use git to reset the code, which is much faster. Then I can resume debugging cleanly.

6. Clean Up and Apply Minimal Fix

After several attempts, the right solution usually emerges. Even if code is messy after “accept edits,” I reset back to the last commit in git. I let Claude know the previous fix actually worked and request only the minimal change needed—often just one line.

7. Final Test and Push

One last test. If all’s good, I push to git—done.

Happy coding!

Conclusion

This is my concise workflow for debugging with Claude Code. It mixes AI help, thoughtful version control, and a careful loop of experimenting and cleaning up. If you work with large or messy projects, hopefully this approach gives you a helpful starting point.