Chapter 17
Twelve templates.
Copy these into your own folder and edit them. The names in angle brackets are for you to fill in. Copy the code from the web version, fableinlead.com/playbooks/ai-sales-automation, because a PDF drops the spaces at the start of each line.
A. CLAUDE.md starter
# Sales system: rules Claude reads first
## HARD rules (Claude reads these first. Back rule 1
## with a permission and a hook, see template I.)
1. Nothing is sent, posted, connected or booked without a named
person's OK on the exact text.
2. Never invent a fact, price, result, client name or quote.
Every prospect fact needs a source link and a date.
3. Facts about our business come only from brain/. If missing, ask.
4. The AI is set up never to open LinkedIn. If a LinkedIn page,
captcha or login prompt ever appears, stop and write it in
state/LOOP-STATE.md.
5. Never type or store passwords or two-factor codes.
6. Never contact anyone on data/do-not-contact.csv, a current
client or a competitor.
## How to run
/sales-loop runs one batch of 5, checks its work, writes the state
file and stops. Start each run in a fresh session.
B. Research file
# <Company> (<website>)
Researched: <date> | Person: <name>, <title> | Fit: fit / maybe
## Signals (newest first)
- <date> <fact> [source] [second source or UNCONFIRMED]
## Angle
Signal: ... | Problem it creates: ... | Offer line: ... [offer.md heading]
## Do not use
- anything stale, unconfirmed, private or awkward
C. Gate helper (.claude/agents/gate.md)
---
name: gate
description: Scores a finished draft 0 to 10 without seeing how it
was written. Use after the copy check, before the queue.
model: sonnet
tools: Read
---
You did not write this draft. Judge it cold.
Read only: the draft, its research file, brain/voice.md, brain/offer.md.
Two points each:
1. Every fact is in the research file with a date and a source.
2. It is written for this person. Swappable name = 0 here.
3. It matches the voice file.
4. It asks one thing a busy buyer can answer in a line, or none.
5. It promises nothing offer.md does not state.
Reply only: SCORE n/10, FAILS, FIX (one line per fail).
Pass is 8 or more. Do not rewrite the draft.
D. Queue entry
## <Name>, <title>, <company> | <channel> | PASSED <n>/10
Why now: <signal, date> [research file]
Draft:
<message>
Approve / edit / reject:
E. Friday report
# Week of <date>
Results: <n> replies, <n> meetings booked, <n> deals moved
Sent: <n> first messages, <n> follow-ups, <n> skipped (reasons in data)
What worked: <one line, with a number>
What did not: <one line, with a number>
Changes for next week:
1. <change> because <number>
2. <change> because <number>
F. The sales loop skill (.claude/skills/sales-loop/SKILL.md)
Type /sales-loop in Claude Code to run it. This is a shortened version of the template file.
---
name: sales-loop
description: Runs one batch: ready check, pick 5 contacts, fit
check, research, draft and gate, nurture plan, record, stop.
---
# One batch, then stop. Gather, act, check, record, stop.
0. Ready check. Read state/loop-state.json. Stop with one short
message at the first gap: brain files not built, no
data/contacts.csv, more than 20% of rows missing a required
field, or "blocked": true.
1. Pick the batch. python3 scripts/check_contacts.py
data/contacts.csv --next 5 returns
rows with status new or nurture_due, minus do-not-contact.
2. Fit check (researcher). Fit, maybe or no fit against
brain/customer.md and brain/company.md. No fit: one-line
reason, status skip, no research.
3. Research (researcher). Fit and maybe rows only. Skip any
company researched in the last 30 days.
4. Draft and gate (writer, then gate). One message per contact.
Writer runs on sonnet; use opus for replies to warm leads.
A gate fail goes back once. A second fail goes to the queue
marked NEEDS A PERSON.
5. Nurture plan (writer). Posts to like, one comment draft if a
post is worth it, pages to follow. Same queue file.
6. Record and stop. Write messaging/queue/<date>.md, update
each row's status and next date, update state/loop-state.json,
add 3 lines to state/LOOP-STATE.md, reply in one line.
Hard stop: if a LinkedIn page, captcha or login prompt appears,
set blocked: true and end the run. This skill is set up never to send.
G. The other three helpers (.claude/agents/)
The gate helper is template C. Each helper is a short file with its own model.
--- .claude/agents/researcher.md ---
---
name: researcher
description: Fit-checks contacts and gathers dated company signals.
model: haiku
tools: Read, Grep, Glob, WebSearch, WebFetch, Write
---
You check fit and gather facts. You do not write messages.
Every fact gets a date and a source link. A fact without a second
source is marked UNCONFIRMED. Never guess a date, name or number.
Write only to research/accounts/. If the angle needs judgement,
say "angle needed" and stop. The main session
(Sonnet) then picks the angle.
--- .claude/agents/writer.md ---
---
name: writer
description: Writes messages, follow-ups, replies and comments in
the owner's voice from a research file.
model: sonnet
tools: Read, Write, Bash
---
Read brain/voice.md first. Use only facts in the research file and
claims in brain/offer.md. Run scripts/copy_gate.py on your draft
and fix every FAIL. Use Bash only for that one script. One draft per contact, one question at most.
You never send anything.
--- .claude/agents/reporter.md ---
---
name: reporter
description: Counts results from the sales files and writes the
Friday report.
model: haiku
tools: Read, Grep, Glob, Write
---
Count from files only. No estimates, no research, no messages.
Write the report to deliverables/reports/ and reply in one line.
If you add a research connector such as Exa or Firecrawl, also add its tool names to the researcher’s tools line, for example mcp__exa__web_search_exa. A helper can only use the tools listed there.
| Helper | Model | Writes to | Never does |
| researcher | haiku | research/accounts/ | Writes a message or guesses a date |
| writer | sonnet | messaging/queue/ | Sends, or runs any Bash command other than the copy check |
| gate (template C) | sonnet | Its verdict only | Edits the draft it is judging |
| reporter | haiku | deliverables/reports/ | Estimates a number it cannot count |
Check each file against this table before the first run. If a helper can write somewhere the table does not list, take Write and Edit out of its tools line. The tools line works on whole tools, so it cannot limit a helper to one folder.
H. Copy check script (scripts/copy_gate.py)
A starter version that runs for free before any AI check. It prints shorter labels than the full script in chapter 10, and has fewer banned phrases. It also fails empty drafts, mail-merge placeholders such as {{first_name}}, and activity numbers used as proof. Add your own banned words from voice.md.
#!/usr/bin/env python3
"""Free first check for any draft. Runs before any AI check.
python3 scripts/copy_gate.py draft.txt --channel dm"""
import argparse, re, sys
STOCK = ["i hope this finds you well", "just following up",
"just checking in", "touching base", "quick question",
"game-changer", "leverage", "synergy", "seamless"]
LIMITS = {"note": (4, 200, 0), "dm": (6, 600, 1),
"email": (8, 900, 1), "comment": (3, 350, 1)}
# Effort counted as proof, e.g. "we sent 7,000 invites".
ACTIVITY = r"\b\d[\d,.]*\+?\s*(?:k\s+)?(?:messages|emails|invites|invitations|connections|calls|dials|touches|dms|follow-?ups|sequences|requests)\b"
ap = argparse.ArgumentParser()
ap.add_argument("draft"); ap.add_argument("--channel", default="dm", choices=list(LIMITS))
a = ap.parse_args()
text = open(a.draft, encoding="utf-8").read().strip()
max_lines, max_chars, max_q = LIMITS[a.channel]
fails = [] if text else ["empty draft"]
lines = [l for l in text.splitlines() if l.strip()]
if len(lines) > max_lines: fails.append(f"{len(lines)} lines")
if len(text) > max_chars: fails.append(f"{len(text)} characters")
if text.count("?") > max_q: fails.append("too many questions")
if re.search(r"https?://|www\.|\b[\w-]+\.(com|net|org|io|co|ai|app|example)\b", text, re.I): fails.append("link")
if "\u2014" in text or "\u2013" in text: fails.append("long dash")
if re.search(r"\{\{[^}]*\}\}|\{[^}]*\}|<[^>]*>|\[[^\]]*\]", text): fails.append("placeholder")
if re.search(ACTIVITY, text, re.I): fails.append("activity number")
for s in re.split(r"(?<=[.!?])\s+|\n", text):
if len(s.split()) > 16: fails.append(f"long sentence: {s[:40]}")
low = text.lower()
fails += [f"banned: {w}" for w in STOCK if w in low]
print("PASS" if not fails else "FAIL")
for f in fails: print(" -", f)
sys.exit(1 if fails else 0)
I. The send lock (.claude/settings.json and a hook)
CLAUDE.md asks Claude not to send. This file makes sending much harder. Anthropic’s permissions page puts it plainly: “Permission rules are enforced by Claude Code, not by the model.” A PreToolUse hook can also block a call whatever Claude decides. S17 S18
Do this first. During the drafts-only weeks, deny your bulk-send tools in full, as the first two entries below do. Run /mcp to see the exact tool names your connectors use.
The hook works the other way round from a block list. A connector tool runs only if its first word is get, list, search, read or find, and no later word is on the write list. Any other name stops until you add it to EXTRA_ALLOW, so a new tool is blocked by default. Any call whose input names linkedin.com stops too, even for a tool on EXTRA_ALLOW, and so does an action name with a second __ inside it. Research tools often have other names, such as web_search_exa or firecrawl_scrape. Add the ones you use to EXTRA_ALLOW on day one, or the research step stops. Add the same names to the researcher’s tools line in template G, for example mcp__exa__web_search_exa, because a helper can only use the tools listed there. “onFailure”: “block” stops the call if the hook itself fails to run. It needs Claude Code v2.1.295 or later. S18 One limit stays: a Bash deny rule for curl does not catch the same program run by its full path or inside sh -c. Turn on the sandbox network allowlist when the block must hold. S17
{
"permissions": {
"deny": [
"mcp__smartlead__*", "mcp__instantly__*",
"mcp__claude-in-chrome__*",
"WebFetch(domain:linkedin.com)", "WebFetch(domain:*.linkedin.com)",
"Bash(curl *)", "Bash(wget *)"
],
"allow": [ "Bash(python3 scripts/copy_gate.py *)" ]
},
"hooks": {
"PreToolUse": [
{
"matcher": "mcp__.*",
"hooks": [
{ "type": "command",
"command": "\"${CLAUDE_PROJECT_DIR}\"/.claude/hooks/block-send.sh",
"onFailure": "block" }
]
}
]
}
}
#!/bin/bash
# .claude/hooks/block-send.sh (chmod +x, needs jq)
# A connector tool runs only if its first word is a read verb
# (get, list, search, read, find) and no later word is on the
# write list below. Any call that names linkedin.com stops.
# Research tools often have other names. Add yours, for example:
# EXTRA_ALLOW="web_search_exa web_fetch_exa firecrawl_scrape
# firecrawl_search people_search domain_search"
EXTRA_ALLOW=""
IN=$(cat) || exit 2
TOOL=$(printf '%s' "$IN" | jq -er '.tool_name') || exit 2
block() { echo "Blocked: $TOOL. A person does this step." >&2; exit 2; }
# Never let a tool reach LinkedIn, whatever its name.
printf '%s' "$IN" | jq -c '.tool_input // {}' | grep -qi 'linkedin\.com' && block
# Expect mcp__server__action, with no extra __ inside the action.
case "$TOOL" in mcp__?*__?*) ;; *) block ;; esac
ACTION=${TOOL#mcp__*__}
case "$ACTION" in *__*) block ;; esac
for t in $EXTRA_ALLOW; do [ "$ACTION" = "$t" ] && exit 0; done
# Split snake, camel, kebab and UPPER case into lower-case words.
W=$(echo "$ACTION" | sed -E 's/([a-z0-9])([A-Z])/\1_\2/g;
s/([A-Z]+)([A-Z][a-z])/\1_\2/g; s/-/_/g' | tr 'A-Z' 'a-z')
case "${W%%_*}" in get|list|search|read|find) ;; *) block ;; esac
REST="_${W#*_}_"; [ "$W" = "${W%%_*}" ] && REST=""
# The write list: any of these words after the first one blocks.
for w in and then or send create update delete reply forward \
start activate schedule book add upload publish invite connect \
resume modify move archive write remove set put submit execute \
trigger dispatch enroll approve merge upsert share like follow; do
case "$REST" in *"_${w}_"*) block ;; esac
done
# These can name a thing (get_post, read_email). They block
# unless they are the last word.
for w in post message email call comment; do
case "$REST" in *"_${w}_"?*) block ;; esac
done
exit 0
We tested it on 74 tool names and 11 calls with real inputs. It let through 18 plain read tools, such as get_post, read_email and searchContacts. It blocked the other 56: every send, post, campaign and data-change tool, mixed names such as get_or_create_contact, getAndSend and get_upsert, and names with a second __. Empty or broken input is blocked too. With six research tools on EXTRA_ALLOW, a firecrawl_scrape of a company website ran, and the same call on a linkedin.com page was blocked. It is careful by design: get_call_log, get_email_draft and create_draft are blocked as well, so add any you need to EXTRA_ALLOW.
The “allow” line above runs the copy check without asking. In the default permission mode, any other command that could change something waits for a person to approve it.
J. The data files
Put one export of your contacts in data/contacts.csv, with column names in the first row.
| Column | Needed? | What goes in it |
| name, company | Yes | Full name and company name |
| website or linkedin_url | At least one | The company website, or the person’s LinkedIn link |
| title, email, country | Advised | Job title, work email if you send email, where they are |
| last_touch, notes | If you have them | Date you last spoke (YYYY-MM-DD) and anything you already know |
| status, next_action_date, last_step | The setup fills them | new, skip, researched, queued, messaged, connected, replied, replied_not_now, meeting, client or nurture_due |
--- data/contacts.csv (first two lines) ---
name,company,website,linkedin_url,title,email,country,status,last_touch,notes,next_action_date,last_step
Ana Example,Northwind Advisory,northwind.example,,Founder,,Portugal,new,,,,
--- data/do-not-contact.csv (same folder; clients, partners, competitors, anyone who asked you to stop) ---
name,company,email,linkedin_url,domain,reason
--- state/loop-state.json ---
{"batch_size": 5, "last_run": null, "cursor": 0, "blocked": false,
"blocked_reason": "", "counts": {"fit_checked": 0, "researched": 0,
"drafted": 0, "passed_gate": 0, "needs_a_person": 0, "skipped": 0}}
#!/usr/bin/env python3
"""scripts/check_contacts.py: check the contact file and pick the next batch.
python3 scripts/check_contacts.py data/contacts.csv # field report
python3 scripts/check_contacts.py data/contacts.csv --next 5 # next batch"""
import argparse, csv, datetime as dt, json, os, sys
REQUIRED = ["name", "company"]
ONE_OF = [("website", "linkedin_url")]
READY = {"new", "nurture_due", ""}
# A personal address blocks that address only, never the whole provider.
FREE = {"gmail.com", "googlemail.com", "outlook.com", "hotmail.com", "live.com",
"yahoo.com", "icloud.com", "me.com", "proton.me", "protonmail.com"}
def load(path):
with open(path, newline="", encoding="utf-8-sig") as f:
return list(csv.DictReader(f))
def norm(s): return (s or "").strip().lower()
def dom(s):
s = norm(s)
if "@" in s: s = s.split("@")[-1]
s = s.split("://")[-1].split("/")[0].split("?")[0].split("#")[0].split(":")[0]
return s[4:] if s.startswith("www.") else s
def li(s):
# One form for every LinkedIn link: linkedin.com/in/name.
# Drops scheme, www, country (uk.), query, end slash and locale (/en).
s = norm(s).split("?")[0].split("#")[0].split("://")[-1].rstrip("/")
if "linkedin.com/" in s:
return "linkedin.com/" + "/".join(s.split("linkedin.com/", 1)[1].split("/")[:2])
return s
def blocked(path):
# The do-not-contact file sits next to the contacts file.
if not os.path.exists(path):
print(json.dumps({"ok": False, "ask": "Create " + path + " first, even if it only has the header row."}))
sys.exit(1)
names, doms, links = set(), set(), set()
for r in load(path):
names |= {norm(r.get(k)) for k in ("name", "company", "email") if norm(r.get(k))}
doms |= {dom(r.get(k)) for k in ("domain", "email") if dom(r.get(k))} - FREE
if li(r.get("linkedin_url")): links.add(li(r.get("linkedin_url")))
return names, doms, links
def hit(d, doms):
# Blocks the domain itself and any subdomain, e.g. sales.northwind.example.
return any(d == b or d.endswith("." + b) for b in doms)
ap = argparse.ArgumentParser()
ap.add_argument("csv"); ap.add_argument("--next", type=int, default=0)
a = ap.parse_args()
if not os.path.exists(a.csv):
print(json.dumps({"ok": False, "ask": "Export your contacts to data/contacts.csv."})); sys.exit(1)
rows = load(a.csv)
gaps = {}
for i, r in enumerate(rows, start=2):
for c in REQUIRED:
if not norm(r.get(c)): gaps.setdefault(c, []).append(i)
for p in ONE_OF:
if not any(norm(r.get(c)) for c in p): gaps.setdefault("/".join(p), []).append(i)
report = {"rows": len(rows), "ok": bool(rows) and all(len(v) <= 0.2 * len(rows) for v in gaps.values()),
"rows_missing": {k: len(v) for k, v in gaps.items()}}
if not rows: report["ask"] = "The contact file has no rows. Add your export first."
if a.next and rows:
dnc = os.path.join(os.path.dirname(os.path.abspath(a.csv)), "do-not-contact.csv")
(bl_names, bl_doms, bl_links), today, pick = blocked(dnc), dt.date.today().isoformat(), []
for i, r in enumerate(rows, start=2):
due = (r.get("next_action_date") or "").strip()
if norm(r.get("status")) not in READY or (due and due > today): continue
if not norm(r.get("name")) or not norm(r.get("company")): continue
if not norm(r.get("website")) and not norm(r.get("linkedin_url")): continue
keys = {norm(r.get(k)) for k in ("name", "company", "email")} - {""}
doms = {dom(r.get(k)) for k in ("website", "email")} - {""}
if keys & bl_names or li(r.get("linkedin_url")) in bl_links - {""}: continue
if any(hit(d, bl_doms) for d in doms): continue
pick.append({"row": i, **r})
if len(pick) >= a.next: break
report["batch"] = pick
print(json.dumps(report, indent=2))
sys.exit(0 if report["ok"] else 1)
K. Brain file starters (brain/)
Each file starts with these headings. Fill them from your own evidence: posts, emails, call notes, proposals. If a heading has no evidence, write NOT IN THE EVIDENCE under it, a device from Charlie Hills’ Company Brain prompts. S14 The other skills read these exact headings.
--- brain/voice.md ---
# How we write
## Numbers (lines per message, words per sentence, sign-off)
## Words we use (with the source of each)
## Never list (phrases we never write)
--- brain/customer.md ---
# Who buys from us
## Who they are (role, company size, market)
## Who is not a fit (who we skip, and why)
## What they are stuck on
## The words they use (quoted from real messages)
## Signs they need us now (events with a date)
## What I got wrong (assumptions the evidence did not back)
--- brain/offer.md ---
# What we sell
## In and out of scope
## Price rules (or "price only on a call")
## Proof we may quote (results the client allowed us to share)
--- brain/company.md ---
# Who we are
## What we do, for whom
## Who we turn away
## How we work (the steps a client sees)
L. The other four skills (.claude/skills/)
The sales loop calls these. Each is one SKILL.md file. Here is what each one reads, does and writes.
| Skill | Reads | Does | Writes |
| signal-research | customer.md “Signs they need us now”, the company website, public news | Finds dated events from the last two years, checks each fact against a second source, picks one angle (the judgement step runs on Sonnet) | research/accounts/<company>.md, under 300 words, reused for 30 days |
| message-draft | The research file, voice.md, the matching part of offer.md | Writes one message, runs the copy check, then the gate helper. Has a reply mode for stuck deals | One entry in messaging/queue/<date>.md, marked PASSED or NEEDS A PERSON |
| nurture | Contacts marked messaged, connected or replied_not_now | Plans up to 10 light touches from posts a person pastes in: a page to follow, a post to like, a comment draft. A person does each one | A “Nurture” list in the same queue file, and next_action_date in contacts.csv |
| sales-report | contacts.csv, the queue, loop-state.json | Counts the week from files only, with no estimates | deliverables/reports/<date>.md for Friday |