What Is Prompt Engineering

Learn what prompt engineering means for software work: writing instructions that get AI assistants to produce correct, reviewable code.

TL;DR

  1. Prompt engineering is writing instructions that get AI assistants to produce correct, reviewable code.
  2. A good prompt states the task, the context, the constraints, and the output format.
  3. Treat prompting as a loop: draft, read the output, correct, repeat.

What It Is

    Working Definition

    Shaping an AI assistant's output by controlling the instructions you give it.

    Prompt engineering (for code) =
    writing instructions precise enough
    that the output can be verified.
    Versus General Prompting

    Code has a hard correctness bar, so prompts must be specific, not just evocative.

    Chat: "explain recursion" -> fine if vague
    Code: "write a function" -> needs types,
      inputs, outputs, errors, language
    The Specification Mindset

    A prompt is a mini spec; the clearer the spec, the closer the first draft lands.

    Treat every prompt like a ticket
    you would hand to a new teammate.

Why It Matters

    Acceptance Rates

    Structured prompts with explicit task, versions, and format land usable code far more often.

    Studies report 40-55% higher code
    acceptance for structured prompts
    vs open-ended requests.
    Debugging Cost

    A bad prompt moves the work from writing code to debugging a stranger's code.

    Vague prompt -> plausible wrong code
    -> you debug logic you did not write.
    Speed With Trust

    The goal is not just fast output; it is output you can verify quickly and trust.

    Fast + unreviewable = liability
    Fast + reviewable = leverage

The Prompting Loop

    1. Draft

    Write a first prompt with the task, context, and constraints you already know.

    "Add a debounce helper in utils.ts.
    TypeScript, no deps, 300ms default."
    2. Inspect

    Read the output critically; check types, edge cases, and invented APIs.

    // Does this call exist?
    // What happens on rapid calls?
    // Is the timer cleared?
    3. Steer

    Correct in the same thread with specific feedback instead of starting over.

    "Cancel the pending timer on each call
    and expose a .cancel() method."
    4. Lock In

    Once it is right, save the prompt so the next similar task starts further ahead.

    # Saved pattern: debounce helper
    # task + lang + no-deps + API shape

Mindset Shifts

    You Are The Spec

    The model fills gaps with guesses, so unstated requirements become its assumptions.

    Unsaid = assumed.
    State the language, version, and goal.
    You Are The Reviewer

    Ownership stays with you; the assistant drafts, you approve or reject.

    Never merge code you cannot explain.
    Context Over Cleverness

    Relevant context beats clever wording; show the model what it needs to see.

    Good context > magic phrasing.

Tips

  1. Keep a personal library of prompts that worked, then reuse and refine them like code snippets.
  2. Always read generated code before you run it; the model optimizes for plausible, not correct.

Warnings

  1. AI output sounds confident even when it invents APIs or skips edge cases, so never trust it unverified.
  2. A vague prompt can cost more time than writing the code yourself, because you end up debugging someone else's guess.

In Practice

FAQ