← 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 four guardrails, not more freedom. Here is the copy-paste template to add them to any agent.

Andrej Karpathy, a founding member of OpenAI, let an AI agent run on its own for two days. It ran about 700 experiments on his model training code and found 20 changes that made training faster. When he applied those changes to a bigger model, training time dropped 11%.

Everyone focused on the freedom. The real story is the guardrails in his autoresearch setup that made walking away safe. I turned them into a template you can paste into any agent or skill you build in Claude or Claude Code.

The 4 Guardrails

01

It can score its own work

Every run was measured on one number against the current best. Better stayed, worse got thrown out. If your AI can’t tell a good result from a bad one, it can’t run alone.

02

Every change is reversible

Each try was saved as a git commit. If it didn’t beat the best score, the agent reset back to where it started. A bad idea never broke anything. Give your agent a way back.

03

It moves in small, timed steps

One change, one 5-minute test run, then a decision. Any run that went past 10 minutes got killed and counted as a failure. Small steps beat one giant prompt trying to fix everything at once.

04

It stays inside strict boundaries

The agent could edit exactly one file. Everything else was off-limits. 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 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 per attempt: [e.g. 5 minutes]. Max total time: [e.g. 2 hours]. Max spend or tokens: [e.g. $5]. If one attempt runs past its time limit, kill it, count it as a failure and undo it. 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.

Where to put it. In Claude Code, paste it into the top of a subagent file (.claude/agents/<name>.md) or a skill’s SKILL.md. In the Claude app, paste it into a Project’s instructions.

Fill It In With Claude

The hardest bracket is the success metric. This prompt interviews you until every bracket is filled and the metric is something a machine can check.

Fill My Guardrails
You are going to help me fill in the Agent Guardrails Template below for one specific agent, so it can run on its own without me babysitting it. The agent I want to run: [one or two sentences, e.g. "rewrite the product descriptions in /products so they match my brand voice"] Where it will run: [Claude Code in my project folder / a Claude Project / another tool] Anything I already know is off-limits: [e.g. the live store, pricing, customer emails] Steps: 1. Interview me one question at a time to fill in every [bracket] in the template. Start with the success metric, because without a measurable metric the agent cannot judge its own work. 2. If my metric is vague ("make it better"), push back and offer me 2 or 3 measurable options to pick from, like a scored rubric, a test that passes or fails, or a match to an example I give you. 3. Keep the scope as small as possible. If I name more than one file, folder or area, ask whether it can start with just one. 4. When every bracket is filled, show me the finished template in one copyable block, ready to paste at the top of the agent's instructions. 5. Under it, list anything that still looks risky, like a tool it could misuse or an action that cannot be undone, and suggest how to tighten it. Rules: - Don't invent my numbers, files or limits. Ask. - Don't remove any section of the template. - Keep your questions short. THE TEMPLATE: [paste the Agent Guardrails Template here]

The Real Win

The future is giving AI better guardrails, not more freedom. 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.