Practical guide · 3 min read

Give a coding agent a first task it can finish

Start with a small change, a clear check and a way to undo it.

What you’ll finish with One reviewable code change with evidence that it works.

AI-generated guide · Content revised · Allow about 20 minutes for the exercise

The walkthrough

  1. Choose a bounded change

    Start with a reproducible bug, a small form validation change or a missing test. Write down the current behavior and the behavior you want. Avoid combining a redesign, dependency upgrade and database migration in the same first task.

  2. Give the agent a map

    Point it to the relevant files, project instructions and test command. Ask it to inspect the existing approach before editing. Keep credentials out of prompts and give only the permissions needed for the task.

  3. Ask for a small patch

    Work on a branch or a recoverable copy. Request the smallest change that fixes the issue. Let the agent explain assumptions before it introduces new dependencies or changes a public interface.

  4. Verify the result yourself

    Read the diff and run a check that would fail with the original bug. Try the changed behavior in the application. A confident explanation and a passing test that merely repeats the implementation are not enough.

Text to start with

Replace the bracketed sections with your own details.

Investigate [bug] in [files]. Expected behavior: [result]. First explain the cause. Make the smallest appropriate change using the project conventions. Run [test command] and add a regression check if needed. Summarize what changed, the checks you actually ran and anything still unverified.

A complete worked example

A self-contained JavaScript exercise: zero items should cost zero. The example is independent of a framework and uses no credentials, dependencies or database.

The reproducible bug

function total(unitPrice, quantity) {
  return unitPrice * (quantity || 1);
}
// total(12, 0) returns 12. Expected: 0.

A bounded brief

Fix zero-quantity handling in total(). Accept finite, nonnegative numeric prices and quantities. Reject invalid inputs with RangeError. Keep the function name and argument order. Do not change unrelated files. Report the checks actually run.

The corrected function

function total(unitPrice, quantity) {
  if (!Number.isFinite(unitPrice) || !Number.isFinite(quantity)
      || unitPrice < 0 || quantity < 0) {
    throw new RangeError('Use finite, nonnegative numbers');
  }
  return unitPrice * quantity;
}

A regression check

// Save the corrected function above and these checks in check-total.cjs.
const assert = require('node:assert/strict');
assert.equal(total(12, 0), 0);
assert.equal(total(12, 3), 36);
assert.equal(total(0, 3), 0);
for (const quantity of [-1, NaN, Infinity, '3']) {
  assert.throws(() => total(12, quantity), RangeError);
}
console.log('PASS');
// Run: node check-total.cjs

Read the change and keep a way back

The important change removes the fallback that treated zero as missing. In this exercise, omitted quantities are invalid rather than silently becoming one; that is an explicit requirement, not a universally correct API choice. In a real project, inspect all callers before changing that contract. Keep a recoverable original and revert only this patch if verification fails. Do not discard unrelated local edits.

When it goes wrong

The agent fixes zero but silently allows numeric strings or changes the function's defaults.

How to correct it

Restate the accepted input types and compatibility requirements. Run a check for the edge case that originally failed and inspect the diff.

Finished when

The original zero-quantity case fails against the old function and passes against the corrected one; invalid inputs are rejected.

Check the result

  • Does the test reproduce the original failure?
  • Are unrelated files or dependencies changed?
  • Can you explain and undo the patch?

Before paying

Compare total cost for a finished task, including retries. Check agent usage, GitHub AI credits, the shared Cursor and Grok usage pool and hosting charges where they apply; a monthly subscription may not cover every action.

Official references

References checked October 22, 2026. Feature access, sharing and plan limits can change; check the linked documentation before committing.

Tools to consider

Choose around the task and access you have. These are options to try, not a measured ranking.

See 4 more options for this workflow

Try another workflow