Guides

Guide · AI Workflows · 4 min read

Prompt, Loop or Graph: Which One Your Task Needs

There are three ways to give AI work, and picking the wrong one is why most AI output needs babysitting. A one-off task needs a prompt, a job you can grade pass or fail needs a loop, and a process with several steps needs a graph.

The 10-second test

Ask yourself If yes, use Example
Do I need one answer, once? Prompt Write an email to my boss. Explain this error.
Can I say exactly what "done" looks like, and check it? Loop Keep going until every test passes. Fix lint until there are 0 errors.
Are there several steps, some at the same time, with decisions along the way? Graph Pull from my inbox, calendar and notes, write my weekly update, and only send it to me when it's good.

Start at the top and stop at the first yes. Most people jump straight to the fancy option; a prompt is still the right call for most quick tasks.

1. Prompt: one ask, one answer

You type, the AI answers once, and you're done. It doesn't check its own work, and it doesn't keep going. That's fine when you're the one judging the result and the job is small.

A better prompt is mostly about context. Use this shape:

AI · prompt template
Task: [what you want, in one sentence]
Context: [who it's for, what it's about, anything it can't know on its own]
Format: [length, tone, structure]
Good looks like: [one example or one rule, e.g. "under 120 words, no apologies"]

When a prompt stops working: you keep sending "no, fix this" over and over. That's a sign the job has a finish line, and it wants a loop.

2. Loop: keep going until it passes

A loop has four moves: look around, plan, do the work, then check it. If the check fails, it goes again. You set the finish line once instead of prompting every step.

The whole thing depends on one sentence: what done looks like. It has to be a state you can check, not a task.

Weak finish line Strong finish line
Fix the tests npm test passes with 0 failures
Make the page look right The page matches mockup.png on desktop and mobile
Clean up the code eslint returns 0 errors and no file is over 300 lines
Write a good summary Summary is under 150 words and names every decision in the notes

In Claude Code, the /goal command turns this into a loop for you. Type /goal plus your finish line, and after every turn a separate model checks whether it's been met. Claude keeps working until it has.

Claude Code · /goal command
/goal npm test passes with 0 failures and the page matches mockup.png on desktop and mobile

One catch: the checker reads the chat; it doesn't run anything itself. So tell Claude to paste the real test output every time, or the checker has nothing to judge.

Always add a cap. "Stop after 5 tries and tell me what's blocking you" keeps a stuck loop from burning through your usage.

3. Graph: several steps, with exits

A graph is for a process, not a single job. Some steps run at the same time, one step feeds the next, and there's a check at the end with more than one way out.

Example: your weekly update.

  1. Start. Pull from your inbox, calendar and notes, all at the same time.
  2. Draft. Combine what came back into one update.
  3. Check. Is it good to go?
  4. Exits. Yes → stop and hand it to you. No, quality issue → retry the draft. No, missing something only you know → stop and ask you.

The last step is the one everyone skips, and it's the most important. Without clear exits a graph either loops forever or guesses on things it should have asked you about.

Copy this and fill in the brackets:

AI · multi-step graph prompt
You're running a multi-step process. Follow these steps exactly.

Start (run these at the same time):
- Pull [source 1, e.g. last 7 days of email from my team]
- Pull [source 2, e.g. this week's calendar]
- Pull [source 3, e.g. my notes folder]

Then: write [the output, e.g. a weekly update for my manager] using only what you pulled.

Check it against these rules:
- [rule 1, e.g. under 200 words]
- [rule 2, e.g. every project has a status and a next step]
- [rule 3, e.g. no project mentioned that isn't in the sources]

Exits:
- All rules pass: stop and give me the final version.
- A rule fails on wording, length or format: fix it and check again. Max 3 retries.
- Something is missing that only I would know: stop and ask me one clear question. Don't guess.
- Still failing after 3 retries: stop and show me what's failing and why.

Mistakes I'd avoid

  • Building a graph for a one-off. If you'll only do it once, prompt it.
  • A loop with no finish line. "Make it better" can run forever. Name the check.
  • A graph with no "ask me" exit. It'll make things up instead of stopping.
  • No retry cap. Pick a number, usually 3 to 5.
  • Letting the AI grade itself with no evidence. Make it show the test output, the word count or the source, not just say "done."

Practical AI for founders & builders.

Get new guides, systems, and skills as they ship.