My Story AI Challenge Free Guides Get the free kitFree kit
← All free guides
ChecklistPut agents to workFree guide

The 3 Back End Rules Under My AI Agents

The demo videos show the dashboard. They don't show what keeps an agent from doing something dumb while you sleep. These are the 3 back end rules under my agents, and the Claude Code prompt that sets up each one in your own folder.

8 to copy3 steps16 min read
Zach CrawfordA free guide by Zach Crawford
Claude Code
Set up the block list for this folder. You are my AI agent here: Claude Code, working in this folder. I want you blocked from exactly three groups of things, and nothing else:
1. API keys and other secret keys.
2. Credit card and bank data.
3. Private data: passwords, logins and private messages.
The whole prompt is in this guide. One click copies it.

This is the start of a real prompt from this guide. It is not a result.

The demo videos show the dashboard. They don't show what keeps an agent from doing something dumb while you sleep.

So people build the screen first. Then they leave an agent running with no idea what it can open, what it did overnight, or if it quit halfway.

Here are the 3 things under mine:

None of it is flashy. It's what lets me leave them running.

Each rule below has what I do, a short checklist, the prompt that sets it up for you, and a test so you know it works. Do them in order, in the same folder.

Before you start

In this guide your agent is Claude Code, working in one folder on your computer: your business folder.

Download the Claude desktop app from claude.ai/download and sign in. Switch from Chat to Code at the top. When it asks for a folder, pick your business folder, or make a new one called my-business.

All 3 prompts get pasted in that same folder.

1What's blocked

My rule for my agents: block three things. API keys, credit cards and private data.

Block much more than that and they can't do the work. I found that out the hard way. My early blocks stopped my agents from doing real work, so I cut the list down to those three.

In your folder, the three groups look like this:

Asking an agent in a chat to stay away from your keys is a request, and a request can get lost halfway through a long job.

Claude Code has a settings file in your folder, at .claude/settings.json, with a list in it called deny. Claude Code checks that list itself every time the agent goes to open a file, and a deny rule holds in every mode. So the block doesn't depend on the agent remembering it.

It's a strong block with two limits. Both are in the last section, so read it before you put anything real in those places.

The checklist

The prompt. There's nothing to fill in. Paste it in, and it asks you 3 short questions first. Claude Code will ask before it saves the settings file, because .claude is a protected folder. Say yes.

Copy and paste this
Set up the block list for this folder. You are my AI agent here: Claude Code, working in this folder. I want you blocked from exactly three groups of things, and nothing else:

1. API keys and other secret keys.
2. Credit card and bank data.
3. Private data: passwords, logins and private messages.

Don't open any file to look for these. First ask me these 3 questions in one message, and wait for my answers:
1. Besides a .env file, is there any file or folder in here that holds API keys or other secret keys? Where?
2. Is there any file or folder in here with card or bank data, like statements or payout reports? Where?
3. Is there any file or folder in here with passwords, logins or private messages? Where?
If I answer "not sure" to one, list the file and folder names in here that look like they belong in that group, by name only, without opening them, and ask me which ones to block.

After I answer, do this, in order:

1. If there's no .env file at the top of this folder, make one with just this line: TEST_KEY=not-a-real-key
   It's fake. It's there so I can test the block. If there is a .env already, leave it alone and don't open it.
2. Make two empty folders if they aren't there: private/money (for card and bank data) and private/personal (for passwords, logins and private messages).
3. Write the block list in this folder's Claude Code settings file, .claude/settings.json, under "permissions", in the "deny" list. If the file is already there, keep everything in it and add to it. Start with these 3 rules, exactly as written:
   "Read(.env)", "Read(.env.*)", "Read(private/**)"
   Then add one rule for each place I named in my answers, written like "Read(./bank-statements/**)" for a folder or "Read(./passwords.txt)" for a file. Put nothing else in "deny", and nothing in "ask". If I didn't name a place, don't guess one.
4. Add this to CLAUDE.md in this folder (make the file if there isn't one):

## What's blocked
- Three groups are blocked for you in this folder, on purpose: API keys and other secret keys (.env files), card and bank data (private/money), and private data like passwords, logins and private messages (private/personal). Also blocked: (the places I named, each with its group).
- Nothing else is blocked. Do the rest of the work as normal.
- If a block stops you, stop and tell me. Don't look for another way to read it.
- When you search the whole folder with a command, leave the blocked places out of the search.
- Never ask me to paste a key, a password or a card number into the chat, and never copy one into another file.

5. Show me the finished settings file. Then tell me in plain words what you can't open now, where each kind of thing goes from now on, and that nothing else is blocked. Don't offer to block more.

Don't move, rename, open or delete any of my files. If I skipped a question, write [ask me: the question] for that group in CLAUDE.md instead of guessing.

Test it. Start a new Claude Code session in the same folder and paste this:

Copy and paste this
This is a test of my block list. Try to open the .env file in this folder with your Read tool, then try again with cat. Do try both, even though you know it's blocked. Tell me what happened each time. If it opens, don't show me what's in it.

It should tell you both tries were blocked. If the file opened, check that .claude/settings.json is inside this folder and that you started Claude Code in this folder.

Now check it can still do the work. Paste this:

Copy and paste this
Make a file called block-test.md with one line in it: The block list works. Then read the file back to me, change the word "works" to "passed", and show me the file again.

It should do all of it. Claude Code may ask before it saves the file. That's its normal ask for any edit, and it has nothing to do with the block list. Delete block-test.md when you're done.

2Where they report

Every agent posts its work in one place. Mine is a Discord server. I can see what each one did, and answer right there.

If an agent works where I can't see it, I don't trust it.

You don't need a Discord server to start. One file does the same job: REPORTS.md, at the top of your folder, newest report first. Every job ends with a short entry: the date, the job, what it did, did it work, and what you do next.

The rule goes in CLAUDE.md. Claude Code reads that file at the start of every session in the folder, so you never have to ask for the report.

The checklist

The prompt. Nothing to fill in here either. It asks you 2 questions first.

Copy and paste this
Set up one place where every job done in this folder leaves a short report I can read: a file called REPORTS.md at the top of this folder, newest entry on top.

First ask me these 2 questions in one message, and wait for my answers:
1. Which jobs get done in this folder again and again, like a weekly email or daily posts? Give each one a short name.
2. Is there anything that must never be written in a report, like a client's last name?

After I answer, do this:

1. Make REPORTS.md if it isn't there, with this as its first line: # Reports (newest on top)
2. Add this to CLAUDE.md in this folder (make the file if there isn't one). Keep the words as they are, and fill in the two brackets from my answers:

## Reports (every job ends with one)
When you finish a job in this folder, add an entry to REPORTS.md before you tell me you're done. Put it right under the first line of the file, so the newest entry is on top. Do it without being asked. Do it when the job failed or stopped halfway too.

Every entry has this shape:

```
## YYYY-MM-DD HH:MM | job name
- What I did: 1 or 2 lines, with the files I made or changed.
- Did it work: yes, no or partly, and how I checked. If I didn't check, write "not checked".
- What you do next: one line, or "nothing".
```

Rules for reports:
- Get the date and time from the computer. Never guess them. If you can't get the time, write the date alone.
- These jobs repeat, so use the same name for them every time: [the job names from my answer]. A one-off job gets a short plain name.
- Answering a question in the chat, with no file made or changed, is not a job. No entry.
- Write only what really happened. Never say a job worked if you didn't check it.
- Never put a key, a password or a card number in a report. Never put these in one either: [what I said must never be in a report].
- Never change or delete an old entry.

3. Add the first entry yourself, for this setup job, in that shape.
4. Show me what you added to CLAUDE.md, and the first entry.

Use only what I told you. If I skipped a question, write [ask me: the question] in its bracket instead of guessing.

Test it. Start a new Claude Code session in the same folder. Give it a small job and don't mention reports. For example:

Copy and paste this
Write a short thank-you note to a customer who just bought from me, and save it as thank-you-note.md.

When it's done, open REPORTS.md. A new entry should be on top, with the date, the job, what it did, did it work, and what you do next. If there's no entry, check that the Reports rule is in the CLAUDE.md in this folder.

3The watchdog

A small script checks on every agent every 5 minutes. It's not another AI. It's a plain check.

It messages me only after 2 fails in a row, so one blip doesn't set it off.

Yours runs off the report file from Step 2. You give it a short list of the jobs that should run and how often each one is due. It reads REPORTS.md, finds the newest report for each job, and prints which jobs are late.

A job that's late on one check shows as LATE ONCE. Late on two checks in a row, it shows as FLAGGED.

The checklist

The prompt. It asks you 3 questions first, then it builds the script, tests it and shows you the test.

Copy and paste this
Build a watchdog for the jobs in this folder. It's a plain script, with no AI in it. It reads REPORTS.md and a short list of the jobs that should run, and it prints which jobs are late. It flags a job only when it's late two checks in a row, so one blip doesn't set it off.

First read REPORTS.md and the Reports rule in CLAUDE.md, so you know the shape of an entry and the job names in use. Then ask me these 3 questions in one message, and wait for my answers:
1. Which jobs should run on a regular basis? Show me the job names you found, so I can pick from them or add one.
2. How often is each one due, in hours or days? Like "every 1 day" or "every 7 days".
3. Once it's on a schedule, how often should the watchdog check? Like "every hour".

After I answer, build it:

1. Write the jobs list as watchdog-jobs.txt in this folder. One job per line, like this:
   weekly-email | every 7 days
   A line that starts with # is a note. Put one note line at the top that says what the file is. If I didn't tell you how often a job is due, write its line as "job name | [ask me: how often]" and have the script print NOT SET for it. Never guess how often.
2. Check what this computer already has, in this order: python3, then node. Write the script in the first one that's there, as watchdog.py or watchdog.js in this folder. Don't install anything. If neither is there, stop and tell me.
3. What the script does on each run. One run is one check.
   - It reads watchdog-jobs.txt and REPORTS.md from the folder it's told to check. With no folder given, it checks the folder the script is in.
   - For each job, it finds the newest entry in REPORTS.md by the heading line (## YYYY-MM-DD HH:MM | job name). A date with no time counts as the start of that day. Job names match when they're the same apart from capital letters and extra spaces.
   - A job is late when its newest entry is older than how often it's due, or when it has no entry at all.
   - It prints one line per job that starts with OK, LATE ONCE or FLAGGED, then the job name, when it last reported and how often it's due. LATE ONCE means late on this check but not on the check before. FLAGGED means late on this check and on the check before.
   - It remembers the last check in a small file, watchdog-state.json, next to the jobs list. A job that reports on time again goes back to OK.
   - It ends with one summary line: how many jobs are OK, late once and flagged.
   - It only reads REPORTS.md. It never changes it, never deletes anything, never goes online and never calls an AI.
   - If REPORTS.md or watchdog-jobs.txt is missing, it says so in one plain line and stops.
4. Test it before you tell me it works. Make a folder called watchdog-test with a made-up REPORTS.md and watchdog-jobs.txt in it: one job that reported on time and one that's late. Run the script on that folder twice. The first run has to show the late job as LATE ONCE. The second run has to show it as FLAGGED. The on-time job has to be OK both times. Show me the exact output of both runs. If it's wrong, fix the script and test again. Then delete the watchdog-test folder.
5. Run it once on this folder and show me the output.
6. Give me the exact line to run it myself in Terminal (PowerShell on Windows), with full paths.
7. Give me the exact line that would run it on a schedule on this computer, as often as I said: a crontab line on Mac or Linux, a schtasks line on Windows. Use full paths, and have it add each check's output to watchdog.log in this folder. Tell me in 2 lines where that line goes. Don't set the schedule up yourself, and don't change anything outside this folder.
8. Add this line to the Rules for reports in CLAUDE.md: Running the watchdog is a check. It gets no entry.

Use only the jobs and times I give you.

Test it. The prompt runs its own test and shows you both runs: the late job is LATE ONCE on the first check and FLAGGED on the second.

To see it on your own folder, open watchdog-jobs.txt and add a job that has never run:

Copy and paste this
test-job | every 1 day

Then paste this in Claude Code, two times:

Copy and paste this
Run the watchdog on this folder and show me the exact output.

The first run shows test-job as LATE ONCE. The second run shows it as FLAGGED. Then delete the test-job line.

Leave it running. The prompt gives you the schedule line but doesn't turn it on. A schedule is a change to your computer, so you turn it on yourself, when you're ready. Paste the line where Claude told you.

Mine messages me. Yours won't. Once the schedule is on, every check gets saved in watchdog.log in your folder. Open that file, or ask Claude Code what the watchdog flagged.

The limitations you should know

Want the next guide? Follow @zachcrawford.ai

More free guides