LibraryLearning
Back to course

Foundations • Lesson 2

How to Get Better First Drafts from AI

20 minute lesson

Learning objectives

  • Improve prompting for structured work
  • Get cleaner first passes
  • Reduce noisy iteration loops

What Is It?

A first draft from an AI coding tool is the initial implementation it produces before you start correcting it. Good first drafts matter because they determine whether AI saves you time or creates cleanup work.

The goal is not perfection on the first try. It is to get a draft that is directionally correct, consistent with the codebase, and small enough to review safely.

How It Actually Works

Models produce better drafts when the task is bounded, the target pattern is visible, and the success criteria are concrete. If the AI sees similar code nearby, it can extend that pattern. If there is no nearby pattern, it will reach for generic framework defaults, which may not match your app.

Three things improve first-draft quality disproportionately. One, show the pattern to copy. Point to the existing route, component, service, or test that should serve as a template. Two, define the smallest acceptable slice. Ask for the minimal working version first, not the fully polished system with optional enhancements. Three, require the model to explain assumptions and list files it intends to change before editing.

You can also improve the draft by asking for a plan or scaffold first. That forces the model to externalize its understanding before it starts spraying code. It is the AI equivalent of “talk me through it before you touch production.”

The Jargon Decoded

  • First draft — The model’s initial attempt at the implementation.
  • Reference pattern — Existing code the model should imitate.
  • Scaffold — Minimal structure that gets the feature running.
  • Acceptance test — A practical check that the feature works as intended.
  • Overgeneration — The model adding too much code or complexity beyond the task.

Why This Matters When You're Building

Bad first drafts cost review time, introduce hidden bugs, and make you distrust the tool. Better first drafts keep the human focused on judgment rather than janitorial cleanup.

This is especially valuable when you are moving fast. Speed only compounds if the output is reviewable.

What To Tell The AI

  • “Use the existing article folder you point me to as the implementation pattern. Match file structure, naming, validation, and error handling.”
  • “Build the narrowest working version first. No optimizations, no extra abstractions, no UI redesign unless required.”
  • “Before editing, list the files you expect to touch and the assumptions you are making.”
  • “After the draft, give me a quick manual test checklist for verifying the happy path and the main failure path.”

Common Misconceptions

“Just ask for the full polished version.” That often invites unnecessary abstraction and extra moving parts.

“The AI should be creative.” For production code, consistency usually matters more than creativity.

“Review happens after generation.” Good review starts before generation by shaping the task correctly.

Sources

  • Anthropic, Prompt engineering overview
  • OpenAI, Prompting best practices
  • GitHub Copilot best practices
  • Martin Fowler, YAGNI

Checkpoint questions

  • Why do weak prompts create expensive downstream work?
  • What makes a spec usable for an AI agent?

Exercise

Rewrite one weak prompt you recently used into a stronger build spec.

Memory recall

Quick quiz

Use retrieval, not rereading. Answer from memory, then check the feedback.

1. Why do weak prompts create expensive downstream work?

2. What makes a spec usable for an AI coding agent?

3. Why improve first drafts instead of relying on later fixes?

Progress

Mark this lesson complete when done

Next lesson