Finding and Fixing Bugs: Describing Errors the Right Way
Finding and Fixing Bugs: Describing Errors the Right Way
~6 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026
No feature is guaranteed to be bug-free on the first try - and the new search feature from the last chapter actually has a small bug. While testing, you notice: recipes with the ingredient " tomato" (with a leading space, because a space was accidentally typed in while adding it) don't show up when searching for "tomato", even though they should. This chapter shows how to describe such a bug so Claude Code can pinpoint it reliably.
Why the bug description matters so much
Just like with a feature prompt: the more specific the description, the more targeted the debugging. A bug report especially benefits from four pieces of information: what you expected, what actually happened, how to reproduce it, and - if available - the exact error message.
A poor bug description
> The search doesn't work right.This description forces Claude Code to hunt down the bug itself before fixing can even begin - that costs time and might target the wrong issue if there are several small rough edges in the code.
A good bug description
> Bug in the ingredient search: a recipe with the ingredient " tomato" (with a leading space) is NOT found when searching for "tomato", even though it should be. Expected: the search should ignore leading/trailing spaces on ingredients. Likely affected: the GET /api/recipes route in server.js.This version names the exact reproduction case (which ingredient, which search term), the expected behaviour, and even a guess at where the bug might be. Claude Code can then look straight at server.js, understand the bug, and fix it in a targeted way.
The fix
The cause: the comparison ingredient.toLowerCase().includes(searchTerm) handles case, but not extra whitespace. The fix is a small, targeted Edit change:
const filtered = recipes.filter((recipe) =>
recipe.ingredients.some((ingredient) =>
ingredient.trim().toLowerCase().includes(searchTerm)
)
);
A single extra method (.trim()), in exactly the right spot - possible because the bug description was precise enough to find the cause without detours.
Making a bug reproducible for Claude Code
For more complex bugs, it also helps to have Claude Code reproduce the bug itself before fixing it - for example with a targeted curl call or a small test script. That way the bug is first confirmed objectively, and after the fix the same call can immediately verify whether it's actually gone.
Tipp: After a fix, feel free to also ask Claude Code to briefly check whether similar bugs might exist elsewhere in the project - in this case, for example, whether a title search (if one existed) would have the same whitespace problem. One found bug is often a good hint at related bugs elsewhere.
The next chapter takes this one step further: instead of waiting for a concrete bug, you'll have Claude Code actively review existing code and improve it - a code review.