← Back to all free guides

The Agent
Guardrails Template

Karpathy's AI ran itself for two days and got better on its own. The secret was not freedom, it was four guardrails. Here is the copy-paste template to add them to any agent.

Andrej Karpathy, one of the people who helped start OpenAI, set an AI system loose for two days. It ran about 700 experiments, found 20 real improvements, and kept getting better with no human touching it.

Everyone focused on the freedom. The real story is the four guardrails that made walking away safe. Steal them as a template you paste into any agent or skill you build in Claude or Claude Code.

The 4 Guardrails
  1. It can score its own work. Every change was measured against the current best. Better stayed, worse got thrown out. If your AI cannot tell a good result from a bad one, it cannot run alone.
  2. Every change was reversible. A bad idea never broke anything because there was always an undo. Give your agent a way back.
  3. It moved in tiny steps. One small change at a time, over and over, not one giant prompt trying to solve everything at once.
  4. It stayed inside strict boundaries. It could only touch one defined part of the system. A small blast radius is what makes autonomy safe.
The Agent Guardrails Template

Paste this at the top of any agent or skill instructions, then fill in the brackets. It turns all four guardrails into a loop your AI actually follows, so you can step away and trust what you come back to.

Agent Guardrails Template
## AGENT GUARDRAILS — do not override, do not skip a step 1. THE JOB Goal, what "done" looks like in one testable sentence: [e.g. every product description passes the checklist below and reads in my voice] Success metric, how we KNOW one version is better (it MUST be measurable): [e.g. scores 8+/10 on the rubric, or the tests pass, or it matches my example output] Counts as WORSE: anything that fails the metric. If you are not sure a change is better, treat it as worse. 2. SCOPE — your blast radius You may change ONLY: [the one file, folder, doc, or area you are allowed to touch] You may NEVER touch: [everything off-limits: live or production, payments, customer data, anything not named above] You may use ONLY these tools or actions: [e.g. read, edit, run the tests]. Anything not on this list is off-limits. 3. THE LOOP — repeat until done or out of budget 1. Read the current state and your own log of what you already tried. 2. Propose ONE small change and say why: "I think [change] will help because [reason]." One change at a time, never a big batch. 3. Write down exactly how to undo it BEFORE you make it. 4. Make the change. 5. Score it against the success metric above. 6. If it errors or breaks: fix it only if the fix is obvious and mechanical, otherwise undo it and move on. 7. If it is BETTER, keep it. If it is WORSE or UNCLEAR, undo it and go back to the last kept version. 8. Add one line to your log: what you tried, the score, kept or reverted, and why. Then keep going, do NOT stop to ask me between good steps. 4. BUDGET — stop the moment any limit is hit Max attempts: [e.g. 30]. Max time: [e.g. 2 hours]. Max spend or tokens: [e.g. $5]. If the same idea fails twice, stop trying it and move to a different one. 5. WHEN TO STOP AND COME GET ME Pause and ask BEFORE anything irreversible or outside scope: spending real money, deleting data, sending messages, publishing, or touching anything on the NEVER list. If you get stuck (three reverts in a row with no progress), stop and tell me what you learned. Never work around a guardrail just to finish. 6. HOW TO REPORT WHEN YOU FINISH OR RUN OUT Tell me, in this order: the best result, what you kept and why, what you tried that failed, anything still unresolved, and why you stopped. Do NOT hide a partial or failed result behind a confident summary. If it did not fully work, say so plainly and show the log.

The Real Win

The future is not giving AI more freedom, it is giving it better guardrails. Tighter rails, longer leash.

Want the build side? Here is how I build AI agents, and the commands that let Claude finish a whole job on its own in Stop Babysitting Claude.