A step-by-step guide to building an email agent in the Code tab of the Claude desktop app: a folder as its workspace, connectors with tight permissions, three plain-language files written by Claude, a week or two of supervised runs, and finally a private GitHub repo and an hourly cloud routine.
Reading map
- What an agent is and the five levels you will climb (section 1).
- Part I — The workspace: one folder, opened in the Code tab, holding markdown files (sections 2 and 3).
- Part II — Tools and permissions: connect Gmail, decide what Claude may read and do, and test the connection (sections 4 to 6).
- Part III — Build the agent: a reusable agent-builder prompt, the interview, and the three files it creates (sections 7 to 11).
- Part IV — Test it by hand: run the slash command, read every draft, and turn corrections into memory (sections 12 and 13).
- Part V — Move it to the cloud: a private GitHub repo and an hourly routine with phone notifications (sections 14 to 16).
- Comparison tables, Final Perspective, a quick reference and an FAQ at the end.
What You Are Building
1. An agent that does the work, not one that answers
A normal chat gives you an answer and leaves the work to you. An agent takes a task and carries it out with your own apps and tools. The example in this guide is an email agent: you type one slash command, and about a minute later every unread thread in Gmail has a label and most of them have a reply draft written in your voice. Nothing is sent. You read the drafts and press send yourself.

No code is involved; every step is a plain-language request to Claude. The build climbs five levels:
| Level | What you do | What you get |
|---|---|---|
| 0 · Workspace | Make a folder and open it in the Code tab | A home where the agent keeps everything |
| 1 · Tools | Connect Gmail and set tool permissions | Claude can see your inbox, but only act where you allow |
| 2 · Build | Paste the agent-builder prompt and answer an interview | Three files: CLAUDE.md, a skill, MEMORY.md |
| 3 · Test | Run the slash command by hand for one to two weeks | Corrections become memory and a better skill |
| 4 · Cloud | Push the folder to a private GitHub repo and schedule it | The agent runs every hour, even with your laptop closed |
Part I — The Workspace
2. Give the agent a folder of its own
Most AI work is scattered across random chats, so every session starts from zero, like cooking in someone else’s kitchen. The fix is a workspace: simply a folder on your computer.
- Create a new folder and name it after the job, for example
Email Agent. - Open the Claude desktop app, open the sidebar and switch to the Code tab.
- Click Choose a folder to work in, then Open folder, and pick the folder you just made.
- Click Trust workspace.
That is the whole setup. Everything the agent needs and creates now lives in that one folder.

3. Save files as markdown
Try the workspace with something small. Ask Claude to write a short note, for example a list of your favorite foods, and to save it to the folder. Claude may first produce a styled page; ask for plain text and it switches to a markdown file (.md).
Markdown matters because every file in this guide uses it. It is plain writing with a few symbols for headings and lists, so both people and AI can read it without any special software. Because the note now sits in the folder, any new chat opened in that folder can find and use it.

Part II — Tools and Permissions
4. Connect the tools the agent needs
Your email, calendar and business apps live in the cloud, and Claude cannot automate what it cannot see. Connectors fix that.
Open the sidebar, go to Settings, then Connectors. On the screen used for this guide, the list of top connectors showed 9,612 entries, including Gmail, Google Drive, Google Calendar, Microsoft 365, Slack, Stripe, Shopify, HubSpot and Salesforce. Connecting works the same way for each one:
- Pick the connector, for example Gmail.
- Click Connect to Claude, then Continue connecting.
- Sign in to the service the way you normally would.
- Back in Claude, the connector shows as connected.
Connectors belong to your Claude account, not to a folder. Once Gmail is connected, every agent workspace you create later can use it without connecting again.

5. Decide what Claude is allowed to do
This is the step that makes an email agent safe to try. Each connector has a Tool permissions section with two groups:
- Read-only tools only look and report back. Gmail had six: get draft email, get email message, get email thread, list draft emails, list labels and search email threads.
- Write/delete tools take actions in your account. Gmail had 24, such as create draft email, create label, apply a label, delete draft, move to trash, forward and send.
For every tool you pick one of three levels: always allow, needs approval (Claude asks you first) or block. In the example, forwarding, replying and sending were blocked. The result is an agent that can read, label and draft, but physically cannot send an email.

6. Test the connection before you build
Before building anything, check that Claude can really see your data. A good first request is: “check my email and give me my five most recent emails, and black out any sensitive information.” Claude calls the Gmail tools and returns a short summary table in the chat.
Claude can now read the inbox, but it has no idea how you would answer any of it. That is what the agent adds.

Part III — Build the Agent
7. The agent-builder prompt
An agent in Claude Code is three plain-language files in a folder, and Claude writes them for you if you ask in the right way. The method uses one long prompt, pasted into a new session inside the workspace folder. Here is the structure as a reusable template, in our own words:
I want to build an AI agent in this folder.
The job I want to hand off: [one or two sentences, e.g. "label my emails and
write replies in my voice"].
I'm not technical: explain anything technical in plain words, and do the setup for me.
Work through these steps in order:
1. Interview me. One question at a time; wait for each answer. Learn what a good
result looks like, how I do the job today, what I always and never do, and
when you should stop and ask me. Usually 8 to 12 questions.
2. Gather examples. Look through my connected tools for past examples of this
job done well. Tell me what you found and ask before saving the best ones
into an "examples" folder here.
3. Ask for files. Tell me which files would help (prices, policies, FAQs,
templates). I will drop them into this folder. Tell me when you have enough.
4. Build the agent as three files in this folder:
- CLAUDE.md (main folder): who I am, the job, my rules, when to ask me first,
where the examples and files are, plus two lines:
"Read MEMORY.md before every job" and "Use the skill for this job."
- A skill: .claude/skills/[short-name]/SKILL.md, the step-by-step for doing
the job my way (what to read first, the steps, what good looks like, how to
use the examples), with a short slash name such as /email-agent.
- MEMORY.md (main folder): lessons from my feedback. Start it with the note
"Only save feedback that applies to future jobs, not one-off edits."
5. Explain what you made: what each file does, in plain words, and how to run
the agent with its slash command.
Change only the job sentence. The same prompt builds a sales follow-up agent, a support agent or a reporting agent.

8. Answer the interview
When you send the prompt, Claude starts asking questions, one at a time. In the example, the first message announced the plan (questions first, then looking through sent mail to learn the voice, then building the agent) and asked question 1 of about 10: which email account should the agent work in, and roughly what lands in that inbox?
Answer in detail, like onboarding a new employee, and drag in any files it asks for. The example agent was given a voice guide, product facts, a course outline, transcripts of course modules and real replies the owner had sent, all as markdown.

9. File one: CLAUDE.md, the briefing sheet
CLAUDE.md sits in the main folder, and Claude reads it first every time it works there. It is the agent’s identity and rule book. In the example, Claude described it as a briefing sheet covering:
- Who you are and what your business does.
- The job: label every unread email and write reply drafts; never send anything.
- The labels: eight topic labels that all start with
AI/so they sit together in Gmail, such asAI/MembersandAI/Sponsors, plus two status labels, one for “draft ready” and one for “needs me”. - Your voice: replies of two to five sentences, a “Hey [name],” opening, a short sign-off, no business filler.
- Always and never rules: for example, never delete, archive, or promise refunds or dates.
- When to ask you first: anything about money, legal matters, press, upset people, personal topics or commitments.
- Where your files are, plus the two lines from the prompt: read MEMORY.md before every job, and use the skill.

10. File two: the skill
A skill is a saved set of instructions you start by typing its name after a slash. It lives in its own folder inside a hidden .claude folder: .claude/skills/email-agent/SKILL.md. On a Mac, press Command + Shift + period in Finder to show hidden folders.
The example skill opens with a short header: a name (email-agent) and a description that tells Claude when to use it, including phrases like “do my email” or “sort my inbox”, and the reminder “Drafts only, never sends.” Then come the sections:
- Read first, every time, in this order: CLAUDE.md; MEMORY.md, whose lessons override the general rules when they conflict; the voice guide, then the file names in
examples/; and the product facts and course outline, which are the only source for facts about products, prices and policies. - Get the emails (the last 24 hours of unread mail).
- Label every thread.
- Write the drafts in the same thread, using the examples as a pattern.
- Report back with a short summary and tables of what is waiting on you and which drafts are ready.
- Learn from feedback.
Because the steps are written down, the agent works the same way every time. Typing a slash in a Code-tab chat lists all your skills.

11. File three: MEMORY.md
MEMORY.md sits next to CLAUDE.md and starts almost empty, with one rule at the top: only save feedback that applies to future jobs, not one-off edits. Every time you correct the agent and say “remember this”, a lesson lands here, and the skill tells Claude to read it before every run, so the same mistake does not happen twice.
CLAUDE.md, skills and a memory file are conventions Claude already understands, which is why plain-language files are enough.

Part IV — Test It by Hand
12. Run the agent with its slash command
Don’t put a new agent on autopilot on day one. Treat the first weeks like teaching someone to drive: you sit in the passenger seat and correct, and running the agent locally, only when you ask, is that seat.
Open a new session in the same folder, type /email-agent and send. The builder normally creates the slash command for you; if it is missing, ask Claude in the same chat to set it up. The example run worked through a visible checklist (read memory, voice guide and references; fetch unread threads; label every thread; write draft replies; report a summary) and finished in about 60 seconds with:
| Result | Count |
|---|---|
| Threads processed | 8 |
| Drafts written | 7 |
| Need the owner | 2 |
| Labeled only | 1 |
The “needs you” table explained why each item was held back, for example a discount request with a suggested limit for the owner to decide. Run it like this, by hand, for at least a week or two.

13. Read every draft and teach it
Open Gmail and read the drafts the way you would read a new assistant’s work. In the example, a podcast invitation got an enthusiastic yes, but the owner did not want any podcasts for the rest of 2026. So he told Claude exactly that: change this draft, and add it to my memory.
Claude rewrote the reply as a short, friendly decline and added a rule to MEMORY.md: until the end of the year, podcast and interview invites get a polite decline marked as draft ready instead of being held for review. Future runs read that rule first.
There are two kinds of correction, and they go to different files:
- A judgment the agent got wrong (tone, a policy, a one-off preference that will come up again) goes into memory.
- A step the agent keeps skipping or doing in the wrong order goes into the skill. Ask Claude to update the skill file so the workflow itself improves.

Part V — Move It to the Cloud
14. Put the folder in a private GitHub repo
A local agent only works when you remember to run it, and never while the laptop is closed. Like a coffee maker with a timer, the machine stays the same; you just stop pressing the button.
The first step is GitHub, which gives the folder a home in the cloud. You do not need to use the terminal yourself. In the workspace, ask Claude: “is GitHub installed, and if not, can you install it for me?” Claude can run the commands in the background. In the example, Git and the GitHub command line tool were already installed and signed in, so the next request was simply: “put this in a private GitHub repo.”
Before pushing, Claude checked the folder for API keys, passwords and tokens, then added a .gitignore file that keeps three things off GitHub: Mac .DS_Store files, any future .env secrets files and the local Claude permission settings. All 32 files went up in one commit, with the same folder structure as on the computer. Keep it private: the examples hold real replies. After local changes, ask Claude to push again.

15. Schedule a routine
The second step is a scheduled routine: a cloud agent that runs your skill on a timer. Ask for it in plain words, for example: “create a scheduled routine that runs my email agent skill every hour, from this repository, whether my computer is on or not.” You can ask for hourly, daily, weekday or monthly schedules.
Claude set up the routine, ran it once as a test and summarized the setup:
- Schedule: 11 minutes past every hour (the system picked the minute).
- Where it runs: a fresh copy of the repository each time, in a cloud environment, following the same skill, CLAUDE.md and MEMORY.md as the local version.
- Model: Sonnet 5.5, with the option to switch to Opus 5.5 for sharper drafts at a higher cost per run.
- Gmail access: search and read email, add labels and create drafts only. No tools for sending, trashing, archiving, marking spam, deleting or creating labels, so it cannot do those things even if an email tries to trick it.
- Test run: it found seven unread emails that were already labeled, skipped them and reported “No new email”, so hourly runs do not create duplicate drafts.

16. Turn on notifications
The routine appears under Scheduled in the sidebar, with its history and next run time. Open it to change the schedule, the model or the connectors. Under Advanced settings → Notifications, switch on “Notify me when this scheduled task finishes” and tick Push notification; with the Claude phone app installed, your phone tells you when new drafts are waiting.
Whether it ever sends on its own is your choice, made in the permission settings from section 5.

The Three Files and Two Ways to Run, Side by Side
| File | Where | What it holds | When Claude reads it |
|---|---|---|---|
| CLAUDE.md | Main folder | Who you are, the job, rules, labels, voice, when to ask first, where files are | First, every time it works in the folder |
| SKILL.md | .claude/skills/<name>/ |
The step-by-step workflow and its slash name | When you type the slash command or the job matches its description |
| MEMORY.md | Main folder | Lessons from your feedback | Before every job (the skill and CLAUDE.md say so) |
| Permission level | Effect | Good for |
|---|---|---|
| Always allow | Claude uses the tool without asking | Read-only tools; safe actions like creating drafts or labels |
| Needs approval | Claude asks you each time | Actions you want to watch at first |
| Block | Claude cannot use the tool at all | Send, forward, delete: anything you would not want by mistake |
| Local (Level 3) | Cloud routine (Level 4) | |
|---|---|---|
| Runs when | You type the slash command | On a schedule, e.g. every hour |
| Needs your computer | Yes, open and awake | No |
| You see every step | Yes | You get a summary and a notification |
| Best for | The first one to two weeks of testing and teaching | An agent you already trust |
| Where the files live | Your workspace folder | A fresh copy of the private GitHub repo |
Final Perspective
An agent in Claude Code is less mysterious than it sounds: a folder of plain instructions plus permission to use your tools. The hard part is not technical. It is deciding what the job really is, writing down how you do it, and being patient enough to supervise the first few weeks.
The order of the levels is the safety model: permissions limit what can go wrong, the files capture your judgment, testing turns corrections into rules, and only then does a schedule take you out of the loop.
Start with one boring, repetitive job you understand well. Teach it like a new hire. When the drafts stop needing your edits, give it a timer.
Quick Reference
| Task | Where / what to say |
|---|---|
| Create the workspace | New folder named after the job; Code tab → Choose a folder to work in → Open folder → Trust workspace |
| Save a file | Ask Claude to save it to the folder; ask for markdown for plain text |
| Connect a tool | Sidebar → Settings → Connectors → pick it → Connect to Claude → sign in |
| Set permissions | The connector’s page → Tool permissions → allow / needs approval / block per tool |
| Test the connection | “Give me my five most recent emails, with sensitive details blacked out” |
| Build the agent | Paste the agent-builder prompt (section 7) in a new session in the folder |
| Show hidden folders (Mac) | Command + Shift + period in Finder |
| Run the agent | /email-agent in a new session in the same folder |
| Teach it | “Change this draft and add this to my memory” |
| Fix a skipped step | “Update the skill so it always does X” |
| Back it up | “Is GitHub installed? If not, install it” → “Put this in a private GitHub repo” |
| Schedule it | “Create a scheduled routine that runs my skill every hour from this repository” |
| Get alerts | Scheduled → the routine → Advanced settings → Notifications → Push notification |
FAQ
Do I need to know how to code?
No. Every step is a plain-language request to Claude. Claude writes the files, runs any terminal commands and sets up GitHub and the routine for you.
Is it safe to give an AI agent access to my email?
Start with the least access that does the job. Connect only the tools this agent needs, keep read-only tools on, and block sending, forwarding and deleting. The example agent can only label and draft, so a person still presses send on every email.
What is the difference between CLAUDE.md, a skill and MEMORY.md?
CLAUDE.md says who you are and what the rules are. The skill says how to do this one job, step by step, and gives it a slash command. MEMORY.md collects lessons from your corrections so they apply to every future run.
How long should I test before scheduling the agent?
Run it by hand for at least one to two weeks, reading every result. Schedule it only when the output rarely needs changes and you have fixed any step it kept skipping.
Does the cloud routine need my computer to be on?
No. The routine runs from a fresh copy of your private GitHub repository in a cloud environment, so it works while your laptop is closed. Remember to push local changes to the repository so the cloud copy stays current.
Further Reading and Notes
- Claude’s help center covers the Code tab in the desktop app, connectors and their tool permissions, skills and scheduled routines; check it for the current menus and plan requirements.
- GitHub’s documentation explains private repositories and the GitHub command line tool (
gh).
Menus, connector counts, model names and plan features are as of November 2026. Claude changes often, so check each step against your own screen, and only give an agent the access it needs.
