Build Your First AI Agent in Claude Code
Most people never build an agent because they don't know where to start. This file asks you the questions for all 4 parts, then writes your first agent for you.
An AI agent sounds technical. It isn't.
An agent is just a job description with rules. AI agents do most of the grunt work in my business now, and every one of them is built the same way, from 4 parts.
The 4 parts
1. One job. Not "help with marketing." One job, like "check every fact in my scripts before I see them."
2. What it reads. The files it needs for that job, and nothing else.
3. What it can do on its own, and what it has to ask you first. Mine can draft all day. It can't publish, send an email or spend a dollar without my yes.
4. How it messed up before. Every time it gets something wrong, the fix gets written into the agent, so it doesn't happen twice.
You still have to pick the job and define what you want it to do and how you want the job done. The file asks you the right questions so you don't miss anything.
Step 1. Open Claude Code in a folder
Make a new folder on your computer for your agent. Put any files the job needs in it, like your notes, a past example of the finished work, or your rules.
Open the Claude desktop app, switch from Chat to Code at the top, and pick that folder.
Step 2. Paste the file
Copy this and paste it into Claude Code. It asks you questions one at a time. Answer like you're training a new hire.
You are going to help me build my first AI agent in Claude Code. I'm not technical, so use plain words. An agent is a job description with rules. It has 4 parts. Ask me about each part, ONE question at a time, and wait for my answer before the next one. Part 1. One job. - What is the one job? If my answer is big, like "help with marketing", push me to one job you could check, like "write the show notes for each podcast episode". - What starts the job, and what does the finished job look like? Ask me to paste or point to a good example if I have one. - What are my steps when I do it myself? Part 2. What it reads. - Which files does it need for this job? Look in this folder and list what's here. Ask which ones it should read. - Is anything missing that it would need? If so, tell me what to add. Part 3. What it can do on its own, and what it has to ask me first. - Ask what it may do on its own (for example, read files and write drafts). - Ask what it must ask me before doing (for example, sending, posting, deleting, spending money). - Ask what it must never do. Part 4. How it messed up before. - Ask what goes wrong when someone else, or AI, does this job. Every answer becomes a rule. When you have all 4 parts: 1. Show me a short summary of the agent: its name, the job, what it reads, the 3 lists from Part 3, and the rules from Part 4. Wait for my OK. 2. Then write the agent file at .claude/agents/[agent-name].md in this folder. Start it with name, a one-line description of when to use it, and only the tools the job needs. Then the 4 parts in plain words, with a section called "Fixes" for the Part 4 rules. 3. Tell me the exact words to run it, like "Use the [agent-name] agent on [something]". 4. Run it once on a real example so I can see it work. Ask me for the example if you need one. Rules for you: - Use only what I tell you. Never make up my steps, my rules or my results. If something is missing, ask me. - If a part of the job needs an app you can't reach (like my email), say so. Don't pretend you can do it.
When Claude asks to create the agent file, click Allow. That's it saving your agent.
Step 3. Fix it every time it gets something wrong
This is part 4, and it never stops. When your agent gets something wrong, tell it, in plain words:
You got this wrong: [what it did, and what it should have done]. Add a rule to the Fixes section of your agent file so it doesn't happen again. Show me the new rule before you save it.
After a few fixes, the agent does the job the way you would.
Step 4. Use it
Open the same folder in Claude Code and say the words Claude gave you, like:
Use the [agent-name] agent on [this week's episode].
You can also just ask for the job in plain words. Claude knows the agent is there and hands the job to it.
To see or change your agents later, type /agents in Claude Code.
When this one runs well, build the next one. One job at a time.
The limitations you should know
- An agent only knows what's in its file and the files you give it. Vague answers make a vague agent.
- It can't reach apps you haven't connected, like your email. It will tell you so.
- It drafts. You still read the work before anything goes out.
- The first version won't be perfect. The Fixes section is how it gets better, so use it.
Want the next guide? Follow @iamzachcrawford