Use an AI assistant to fix a small bug

A small, testable failure beats “improve this file.” Keep the repository as the source of truth, ask for a narrow diff, and run the checks yourself.

Work the method in order — reproduce, review the diff, run the checks, then check the real caller. Try it on the code repair workbench: run the fixed totalCents example and record your own repair notes. Your code is never executed on this site.

Workflow guideEditorial update 2026-10-25

Tools for this workflow

Cursor, Github Copilot, Replit

Start with this input

Fictional bug ticket — no repository or coding assistant was run.

function totalCents(rows) {
  return rows.reduce((sum, row) => sum + row.amountCents);
}

Bug: an empty month throws, and a two-row example does not produce a number.
Acceptance: totalCents([]) === 0; totalCents([{amountCents: 200}, {amountCents: 300}]) === 500.
Constraint: preserve the public function name, add no dependency, and change only this function unless a test requires a separate file.

Follow the process

  1. Reproduce the failure with a minimal test on a clean branch. Remove tokens, private customer data, and unrelated files from any context you share.
  2. Give the assistant the function, exact failing input, expected result, and explicit scope. Ask it to explain the smallest change before editing.
  3. Review the diff for changed files, dependencies, network calls, altered behavior, and any assumption about invalid input.
  4. Run the empty and two-row acceptance cases, then the relevant existing test suite and a real caller. Inspect the output rather than relying on an explanation.
  5. Keep or revert the change based on the checks. Record the final test command and commit only the reviewed files.

Reference output and acceptance criteria

Editorial reference patch intent — not an output from Cursor, GitHub Copilot, or Replit.

Initialize the reducer with numeric zero:

function totalCents(rows) {
  return rows.reduce((sum, row) => sum + row.amountCents, 0);
}

Expected checks: [] → 0; [{amountCents: 200}, {amountCents: 300}] → 500. Invalid input behavior remains a separate decision.

If it goes wrong

If the patch only handles [] but still concatenates objects or strings, run both acceptance cases and request the smallest correction. If the assistant changes unrelated files, revert those hunks and restate the one-function boundary. If tests pass but a caller still fails, inspect that caller's actual input shape before broadening the API.

Time, cost and evidence

Use a compatible existing plan where possible. Check the current limits, billing cycle and any extra usage before starting. This guide has no measured vendor runtime, token cost or completion-time promise.

Editorial workflow and fictional reference patch intent based on official Cursor privacy/pricing documentation, current GitHub Copilot plan and instruction documentation, and Replit version-control documentation reviewed on 2026-10-15. No authenticated coding-agent run is claimed. The editorial reference function was checked separately on Oracle with Node.js: empty input, the supplied two-row input, zero amount and offsetting numeric amounts passed. This does not establish a coding product result or define invalid-input handling.

Choose a tool for the part you need

These are workflow starting points based on published capabilities. They are not a quality ranking.

Your situationStarting pointWhy / what to check
You want an editor with project-context and agent controlsCursorCheck the current plan's agent usage and decide whether your project can be sent as context; review Privacy Mode and model exceptions before using private code.
You prefer to keep your current IDE and GitHub workflowGithub CopilotThe current plan page lists supported editors and GitHub features; repository instructions can be stored as reviewed files rather than relying on a chat to remember project rules.
The task is part of a hosted prototype that must be previewed or deployedReplitIts workspace connects code and deployment, so review usage-based agent and hosting costs and keep secrets out of imported source.

A prompt you can copy

Use this instruction with the factual input above. Replace the fictional brief with facts you can verify.

Inspect the bug and propose the smallest change that passes these acceptance tests. Do not edit unrelated files, add dependencies, send network requests, or alter the function's public name. Explain the change first. Then show the focused diff and the exact tests to run. Treat null or missing input as outside this ticket; do not silently broaden behavior. Code: function totalCents(rows) { return rows.reduce((sum, row) => sum + row.amountCents); } Required: totalCents([]) === 0 and totalCents([{amountCents:200},{amountCents:300}]) === 500.

Before you use the result

  • A clean branch or reversible checkpoint exists before an agent edits files.
  • The brief contains a minimal reproduction, expected results, and explicit scope.
  • The assistant's explanation matches the actual code and tests.
  • The diff changes only reviewed files and adds no unapproved dependency, credential, network call, or unrelated refactor.
  • Both acceptance cases pass, and relevant project tests plus a real caller have been checked.
  • Private code, credentials, and customer data were handled under the account's current privacy and organization policy.
  • The final commit includes only the intended repair and a repeatable test command.
  • This workflow is not for a large refactor, security-critical code, or a codebase with no tests: those need a different approach, not a small-bug brief.

Repair the specific failure

The assistant fixes the empty array but the two-row test still fails
Keep both acceptance cases in the prompt and require a numeric initial accumulator; run them after every revision.
The proposed patch modifies unrelated files
Revert those files, restate the one-function boundary, and ask for a new focused diff before accepting edits.
Tests pass but the production caller still fails
Inspect the caller's actual value and type, add a separate reproduction, and agree on invalid-input behavior before expanding the patch.
Code context contains secrets or private records
Stop sharing that context, remove the sensitive material from the prompt, and check the provider's current privacy and deletion controls before continuing.

Download this brief, prompt and checklist (.txt) ↓

Compare before opening a new account

Published tool information

The original procedure and fictional example are editorial work. These sources establish vendor plans and capabilities.