Bug fixer: reproduce the error, find the cause, prove the fix
A stack trace tells you where it broke, not why. Send your todo.is agent the error message, the code and what you expected. It reproduces the bug in its workspace where it can, explains the root cause in plain words, makes the smallest fix that solves it and shows a test that failed before and passes after.
The prompt
- Fix this bug. Error or wrong behaviour: [ERROR MESSAGE OR WHAT GOES WRONG]. Expected: [WHAT SHOULD HAPPEN]. Code: [CODE OR ATTACHED FILES]. Environment: [LANGUAGE, VERSION AND LIBRARIES]. Steps to reproduce: [HOW TO TRIGGER IT]. Reproduce it in your workspace if possible, explain the root cause in plain words, make the smallest change that fixes it (show a diff), and add a test that fails before the fix and passes after. Tell me if the same mistake appears anywhere else in the code.
What to change
- [ERROR MESSAGE OR WHAT GOES WRONG]: Paste the full error and stack trace, e.g. "TypeError: Cannot read properties of undefined (reading 'map')", or describe the wrong result.
- [WHAT SHOULD HAPPEN]: E.g. "the cart total should include the discount".
- [CODE OR ATTACHED FILES]: Paste the relevant files or attach them. Include the function that fails and what calls it.
- [LANGUAGE, VERSION AND LIBRARIES]: E.g. "Node 20, React 18, Vite" or "Python 3.11, pandas 2.2".
- [HOW TO TRIGGER IT]: E.g. "add two items, apply code SAVE10, open the cart".
Example result
- The bug
- "TypeError: Cannot read properties of undefined (reading 'map')" in OrderList.jsx, line 18, right after the page loads.
- Reproduced
- Yes. With a fake API that answers after 300 ms, the error appears on every first render.
- Root cause
- The component starts with const [orders, setOrders] = useState(), so orders is undefined on the first render. Line 18 runs orders.map(...) before the fetch has finished. It worked on your machine because the local API answered almost instantly from cache.
- The fix
- • const [orders, setOrders] = useState();
- + const [orders, setOrders] = useState([]);
- • setOrders(data.orders);
- + setOrders(Array.isArray(data.orders) ? data.orders : []);
- Starting with an empty list means the first render shows nothing instead of crashing, and the second line protects against an API reply without orders.
- Test that proves it
- it("renders without crashing before orders load", async () => {
- mockFetch({ orders: [{ id: 1, total: 20 }] }, { delay: 300 });
- render(<OrderList />);
- expect(screen.getByText(/loading/i)).toBeInTheDocument();
- expect(await screen.findByText("Order #1")).toBeInTheDocument();
- });
- • Before the fix: fails with the same TypeError
- • After the fix: passes, plus your 14 existing tests still pass
- Same pattern elsewhere
- • CustomerList.jsx line 11 also starts with useState() and calls .map. Same fix applies
- • Dashboard.jsx already uses useState([]), no change needed
- Worth adding later
- A loading and error state, so users see "Couldn't load orders" instead of an empty list when the API is down.
How to do it with todo.is
- Copy the prompt and fill in the error, the expected behaviour, the code and your setup.
- Attach the files (or a zip of the small project) in todo.is, or send them to your agent.
- Your agent tries to reproduce the bug, then sends the cause, a diff and a test.
- Apply the diff in your project and run your own tests.
- If it still fails, paste the new error and it keeps going from there.
Tips for a better result
- Paste the whole stack trace, not just the last line. The first line inside your own code is usually the important one.
- Say what changed recently: a new library version, a new data source or a refactor often explains the bug.
- Give exact steps to reproduce. Bugs that only happen sometimes are often timing, caching or data issues.
- Ask for the smallest fix first, then a separate clean-up. It keeps the change easy to review.
- Never paste real API keys or passwords; replace them with placeholders.
bug fixer: FAQ
- Can it fix bugs without running my code? Often, from the error and the code alone. When the setup allows, it reproduces the bug in its workspace with sample data, which makes the fix much more reliable.
- Does it change files in my repository? No. It sends you a diff or the corrected files. You apply them in your own project.
- What if the bug depends on my database or server? It can mock those parts in its workspace. Share the relevant schema, config (without secrets) and logs so the mock matches reality.
- Which languages does it handle? Mainstream ones like Python, JavaScript/TypeScript, Java, C#, PHP, Go, Ruby, SQL and bash. It runs Python, Node and bash directly in its workspace.
JavaScript is required to use the todo.is app.