Skip to main content
Section 2

Prompt patterns for real tasks

Reusable structures for writing, code, and analysis.

4 lessons25-question quiz
2.1

Patterns for writing and editing

6 min read

Most writing requests you will make of an AI tool boil down to four repeatable moves: draft, rewrite, summarize, and change tone or length. Once you recognize which move you need, you stop starting from a blank prompt and start from a pattern that already works.

The four moves

  • Draft: generate new text from a description, when you are starting from nothing.
  • Rewrite: improve existing text while keeping its meaning the same.
  • Summarize: compress a longer piece down to its essential points.
  • Change tone or length: keep the same content but reshape it for a different audience or space.
PatternWhat to sayWhen to use it
Draft"Write a [type] about [topic] for [audience], in a [tone] tone, about [length] long."You are starting from a blank page.
Rewrite"Rewrite this to be more [clear / concise / formal]. Keep the meaning the same." (paste the text)You have a draft that needs polish.
Summarize"Summarize this in [3 bullets / 2 sentences] for [audience]." (paste the source)The source is long and you need the short version.
Change tone or length"Make this more [casual / formal] and [shorter / longer]. Keep the facts the same." (paste the text)The content is right but the audience or channel changed.
Writing patterns

Paste the text, don't describe it

For rewrite, summarize, and tone or length changes, paste the actual text into the prompt instead of describing it. "Make my email more polite" gives the model nothing to work with. Pasting the email and adding "make this more polite, keep the meaning the same" gives it the exact material to edit.

Key idea
Name the move (draft, rewrite, summarize, or tone/length), then paste the real text when one exists. "Keep the meaning the same" or "keep the facts the same" stops the model from quietly changing what you said while it changes how you said it.
These four moves combine. A common sequence is draft, then rewrite for clarity, then change the length for a different channel, like turning a long email into a short social post.
Key terms
Rewrite
Asking the model to improve existing text while keeping its meaning the same.
2.2

Patterns for working with code

7 min read

Code tasks follow the same idea as writing tasks: a handful of moves cover most requests. The four common ones are explain, generate, debug, and refactor. What separates a fast, correct answer from a frustrating back-and-forth is not the wording of the request. It is the context you give it.

The four moves

  • Explain: paste a function or block and ask what it does and why, or what a specific line is for.
  • Generate: describe the inputs, outputs, and edge cases you need, not just the goal.
  • Debug: paste the code, the exact error message or wrong output, and what you expected instead.
  • Refactor: paste the code and say what must stay the same (the behavior) and what should change (readability, speed, structure).

The key move: precise context

The single biggest lever in a code prompt is precision. "My function isn't working" tells the model almost nothing; it has to guess at the language, the bug, and what "not working" even means. Pasting the real code and the real error removes the guessing entirely.

A debug prompt with precise context
This Python function should return the average of a list, but it
returns the wrong number.

def average(nums):
    total = 0
    for n in nums:
        total = n
    return total / len(nums)

average([2, 4, 6]) returns 2.0. I expected 4.0.

What is the bug, and what is the fix?
PatternWhat to pasteWhen to use it
ExplainThe code you want explainedYou are reading unfamiliar code.
GenerateThe function signature, inputs, outputs, and edge casesYou are starting a new function or script.
DebugThe code, the exact error text or wrong output, and what you expectedSomething is broken and you do not know why.
RefactorThe code, plus what must stay the same and what should improveThe code works but needs to be cleaner, faster, or clearer.
Code patterns
Key idea
Paste the actual code and the actual error text. A vague description forces the model to guess; the real code and the real error let it work the problem the same way you would.
For a large file, paste only the relevant function or section, not the whole codebase. The model can only work with what is in front of it, and a shorter, focused paste is easier for it to reason about than an enormous one.
Key terms
Refactor
Changing how code is written without changing what it does.
2.3

Patterns for analysis and structured output

6 min read

Beyond writing and code, AI is useful for turning messy text into something structured you can actually use. Three moves cover most of this work: extraction, classification, and structured output.

The three moves

  • Extraction: pull specific fields out of unstructured text, like names, dates, or amounts, into a list.
  • Classification: sort items into categories you define, such as urgent versus not urgent.
  • Structured output: ask for the answer in an exact shape, like bullets, a table, or JSON, so it slots into whatever comes next.

Naming the shape you want

The output format matters as much as the content. If you just ask for "the info," you get a paragraph you have to pick apart by hand. If you ask for a table with named columns, or JSON with named keys, you get something you can paste straight into a spreadsheet or another program.

A structured-output prompt
Extract the following fields from the text below and return them
as JSON with exactly these keys: name, date, amount.

Text: "Invoice #4421, billed to Sarah Chen on March 3, 2026,
for $1,250."

Return only the JSON object, no other text.
PatternWhat to sayWhen to use it
Extraction"Pull out [fields] from this text and list them."You have messy text and need specific facts out of it.
Classification"Sort these into [categories]. Say which one and why."You need to triage or group a batch of items.
Structured output"Return this as a table / bulleted list / JSON with fields [...]."The result needs to feed into a spreadsheet, another tool, or code.
Analysis patterns
Key idea
Name the exact shape you want, bullets, a table, or JSON with specific keys, and say it before the model starts writing. Asking for a format after the fact means redoing the work.
Extracted facts still come from a model that can be wrong. Spot-check extracted numbers and dates against the source before you use them for anything that matters.
Key terms
Structured output
A response shaped to a specific, predictable format, such as JSON or a table, instead of free-form prose.
2.4

Iterating: change one thing at a time

6 min read

The first result you get from a prompt is rarely the final one. Good prompting is not a spell you get right on the first try. It is a short loop you run a few times.

The refine loop

  1. 1DraftWrite a prompt and get a first result.
  2. 2TestCheck the result against what you actually needed.
  3. 3Change one thingAdjust a single variable: tone, length, an example, the format.
  4. 4RepeatRun it again and compare to the last version.
The refine loop

Why one thing at a time

If you change the tone, the length, and the format all in the same edit and the new result is better, you do not actually know which change fixed it. Change one variable, compare the two outputs side by side, and you learn what that one thing controls. Do this a few times and you build real intuition for how a model responds to your prompts, instead of guessing at a new prompt from scratch every time.

What counts as "one thing"

  • Adding one example of the output you want.
  • Making the audience or purpose more specific.
  • Asking for a different format, bullets instead of prose, or a table.
  • Removing an instruction the model keeps ignoring.
  • Shortening or lengthening the ask.
Key idea
Treat a prompt like a small experiment: change one variable, compare the result to the last one, and keep the change only if it helped. That is how you learn what a prompt actually controls.
This loop is a smaller version of the build loop used when you go from a single prompt to something that takes multiple steps on its own. See Building with AI in AI Foundations.
Key terms
Iteration
Repeating a prompt with one deliberate change to see what that change does.

Section 2 quiz

25 questions. Pass at 75% to master this section. Retakes are unlimited, and the quiz is where the learning sticks.

Section 2 quiz · Prompt patterns for real tasksQuestion 1 of 25

Which four moves does the lesson say cover most writing tasks?