Use an AI assistant to fix a small bug

A reproducible failing case is a better starting point than “make this code better.”

Workflow guideEditorial update 2026-10-13

Tools for this workflow

Cursor, Github Copilot, Claude

Start with this input

Function: total(items) returns the sum of item.price.
Bug: total([]) throws instead of returning 0.
Acceptance: total([]) == 0; total([{price:2},{price:3}]) == 5.
Constraint: do not add dependencies or change other files.

Follow the process

  1. Create a branch or isolated project and remove credentials from the shared context.
  2. Run the empty-input test and record the failure before asking for a fix.
  3. Provide the smallest relevant function, error and acceptance tests to the coding assistant.
  4. Inspect the proposed diff. Reject unrelated edits, network calls or new dependencies.
  5. Run both cases and a real caller. Review the output, then commit only the relevant change.

Reference output and acceptance criteria

Expected acceptance results:
empty input → 0
two prices 2 and 3 → 5
No dependency changes.
This is the expected behavior, not a recorded output from an external coding assistant.

If it goes wrong

If the change only handles the empty case but breaks valid inputs, preserve the failing example and ask for a minimal correction. Never treat passing syntax checks as proof of correct behavior.

Time, cost and evidence

Planning estimate: allow 15–30 minutes for a short first run and manual review. This is not a measured provider runtime. Use an eligible free allowance or review the linked plan before continuing; no guaranteed dollar cost.

Workflow design and an editorial reference output. No authenticated provider run is claimed. Product screens, available models and quotas can change.