Lesson 4 of 6 · 12 min · 1 hands-on step

Building Features with AI Coding Agents

Work with an AI agent like a senior engineer works with a fast junior: clear specs, small steps, careful review.

Agents are fast juniors

AI coding agents can read your project, write code across several files, and run commands. They're incredibly fast. They also confidently make mistakes, miss edge cases, and sometimes change things you didn't ask for.

Treat an agent like a talented new teammate: give clear tasks, then review everything.

A workflow that works

  1. Plan first. Ask the agent for a plan before any code. Correct the plan; it's cheaper than correcting code.
  2. Small steps. One feature or fix at a time, each in its own commit.
  3. Tests define "done". Write (or have it write) tests first, then the code that passes them.
  4. Review the diff. Read every changed line like a pull request. Run it yourself.
  5. Commit when it's good. Git lets you throw away a bad attempt instantly.

A good task description

Add a "Clear completed" button to the to-do app.
- Only show it when at least one task is completed
- Clicking removes completed tasks and updates the "N left" counter
- Don't change the existing add/toggle/delete behavior
- Add tests for: button hidden with none completed, removes only completed tasks

Compare that with "add a clear button". The specific version gets you working code the first time far more often.

Where agents struggle

  • Edge cases (empty input, nulls, huge input): the practice step shows a real example
  • Your project's conventions unless you point them out
  • Security: they may skip validation or leak secrets
  • Knowing when to stop: they sometimes "fix" unrelated code

Your fundamentals are what let you catch these. That's the whole point of this program.

🧪 Practice

You asked an AI agent: "Write parseDuration(text) that turns strings like "1h 30m", "45m" or "2h" into total minutes. Return null for invalid input."

Its code passes the happy path but fails edge cases. Write tests in your head, run the provided ones, and fix it.

JavaScript
// Written by an AI agent
function parseDuration(text) {
  const h = text.match(/(\d+)h/);
  const m = text.match(/(\d+)m/);
  return Number(h[1]) * 60 + Number(m[1]);
}

Output appears here. Press Run or Ctrl/⌘ + Enter.

✅ Check your understanding

  1. What's the best way to hand a feature to an AI coding agent?

Create a free account to track your progress.