Use an AI assistant to fix a small bug ByTask AI · https://bytaskai.com/guide/write-code/ FACTUAL 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. COPYABLE PROMPT 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. 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. ACCEPTANCE CHECKLIST [ ] 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. EDITORIAL REFERENCE 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. FAILURE HANDLING 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. 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. 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. TOOL CHOICES You want an editor with project-context and agent controls: cursor — Check 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 workflow: github-copilot — The 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 deployed: replit — Its workspace connects code and deployment, so review usage-based agent and hosting costs and keep secrets out of imported source. SOURCES Cursor current individual and team plans · https://cursor.com/pricing · reviewed 2026-10-25 Cursor Privacy Mode, data sent to providers, and model retention exceptions · https://prod.cursor.com/help/security-and-privacy/privacy · reviewed 2026-10-25 Cursor codebase indexing and security documentation · https://www.cursor.com/security · reviewed 2026-10-25 GitHub Copilot current plans, environments, and AI-credit framing · https://github.com/features/copilot/plans · reviewed 2026-10-25 GitHub Copilot personal training and privacy controls · https://docs.github.com/en/copilot/how-tos/manage-your-account/manage-policies · reviewed 2026-10-25 GitHub Copilot repository instruction files and supported scopes · https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/add-custom-instructions/add-repository-instructions · reviewed 2026-10-15 Replit Core and Pro price display and usage-control entry points · https://replit.com/pricing · reviewed 2026-10-25 Replit GitHub import, Git version control, and project checkpoints · https://docs.replit.com/learn/projects-and-artifacts/version-control · reviewed 2026-10-25