Skip to content

Instantly share code, notes, and snippets.

@angelo-swe
Created July 21, 2026 00:58
Show Gist options
  • Select an option

  • Save angelo-swe/e585ee7fc1ea1e9edf001ee79546f19f to your computer and use it in GitHub Desktop.

Select an option

Save angelo-swe/e585ee7fc1ea1e9edf001ee79546f19f to your computer and use it in GitHub Desktop.
The 4 AI Loops Cheat Sheet — stop prompting Claude Code one message at a time

The 4 AI Loops Cheat Sheet

How to stop prompting Claude Code one message at a time

Most people use an AI agent like a chatbot: prompt, wait, prompt again. Claude Code has four kinds of loops — each one hands off more of the babysitting. Here's all four, with a copy-paste example for each.

(Based on Anthropic's "Loop engineering: Getting started with loops" — claude.com/blog/getting-started-with-loops)


1. Turn-based — the loop you're already using

Every prompt starts a loop: gather context → act → check → repeat → respond. YOU are the scheduler — it stops when the task is done and waits for you.

Level it up: put your verification steps in the prompt so it checks its own work before coming back to you:

Fix the failing checkout test. Before you report back: run the full test
suite, run the linter, and confirm zero regressions. If anything fails,
keep fixing until it passes.

2. Goal-based — /goal (runs until a condition is TRUE)

Give it a verifiable finish line instead of a task. It keeps working — trying, checking, adjusting — until the goal is met or it hits the try limit.

/goal get the homepage Lighthouse score to 90 or above, stop after 5 tries
/goal all 47 TypeScript errors in this repo are fixed and the build passes

The trick: the goal must be CHECKABLE (a score, a passing build, a green test suite). "Make it better" is not a goal. "Score 90+" is.

3. Time-based — /loop (runs on an interval, up to 3 days)

For anything you'd otherwise re-check manually. It wakes up on your interval, does the work, goes back to sleep.

/loop 5m check my PR, address review comments, and fix failing CI
/loop 30m check the deploy status and alert me if anything errors

4. Proactive — /schedule (runs with NO human involved)

Scheduled cloud agents that trigger on their own — even while your computer is closed. Best for recurring streams of well-defined work: daily research, issue triage, dependency upgrades, monitoring.

/schedule every morning at 8am: scan for what's new in [your niche],
score the top 10 topics, and commit a report to my project

Combine with /goal + skills + auto mode and the agent handles the whole stream end to end.


Which loop when?

You want... Use
One task, done right Turn-based + verification in the prompt
A measurable outcome, hands-off /goal with a checkable finish line
Something babysat on a timer /loop with an interval
Work done while you sleep /schedule (proactive)

Start simple: pick ONE task where you're the bottleneck and hand off just that piece.

— Angelo (@angelotrifanoff.ai)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment