AI Automation t ≈ 16 min

CLAUDE.md Cheatsheet for Marketers: Templates, Hooks, and File Structure

Copy-paste CLAUDE.md templates, hook configs, and file structures for marketing teams using Claude Code.

yfx(m)

yfxmarketer

February 15, 2026

Your CLAUDE.md file controls every output Claude Code generates. One wrong line in this file cascades into wrong research, wrong plans, and hundreds of wrong lines of generated content. Most marketers stuff their CLAUDE.md with 500+ lines of copied prompts from Twitter, then wonder why Claude ignores half their brand guidelines. The fix takes 15 minutes: cut your root file to under 100 lines, split the rest into subdirectory files, and move hard constraints into hooks.

This cheatsheet gives you copy-paste templates for every piece. A root CLAUDE.md for marketing projects. Nested files for email, ads, content, and analytics. Hook configurations for character limits and deployment blocks. Before-and-after examples showing the exact changes. Time saved: 3-5 hours per week from fewer Claude Code misfires and less manual correction.

TL;DR

Claude Code follows roughly 100-150 instructions reliably per session. Its system prompt consumes ~50 of those before your CLAUDE.md loads. Keep your root file under 100 lines. Move domain rules into nested CLAUDE.md files in subdirectories. Move binary constraints (character limits, blocked commands) into hooks. This post includes copy-paste templates for all of it.

Key Takeaways

  • CLAUDE.md files over 300 lines cause Claude Code to skip instructions at random
  • You get ~100 usable instruction slots after the system prompt loads
  • Root CLAUDE.md files should hold project context only, under 100 lines
  • Nested CLAUDE.md files in /email/, /ads/, /content/ folders load on demand
  • Hooks enforce character limits and blocked commands with 100% reliability
  • Explaining “why” behind each rule improves Claude’s judgment on edge cases
  • Every model upgrade means removing instructions, not adding them

What Happens When Your CLAUDE.md File Gets Too Long?

CLAUDE.md bloat is the #1 cause of inconsistent Claude Code output for marketing teams. Anthropic confirmed this in their best practices documentation: “If Claude keeps doing something you don’t want despite having a rule against it, the file is too long and the rule is getting lost.”

HumanLayer analyzed over 1,000 public CLAUDE.md files on GitHub. Roughly 10% exceeded 500 lines. Their recommendation: keep root files under 300 lines. Their own production file stays under 60.

The research backs this up. The IFScale paper (arXiv:2507.11538, July 2025) tested 20 LLMs and found accuracy drops steadily as instruction count rises. At 500 instructions, the best frontier models hit only 68% accuracy. Claude Sonnet 4 specifically loses accuracy in a linear pattern, meaning every instruction you add makes every other instruction slightly less reliable.

Here is the math for marketing teams. Claude Code’s system prompt contains ~50 instructions. The reliable instruction ceiling sits around 150-200 total. After the system prompt loads, you have ~100-150 slots for your CLAUDE.md, your prompt, and any reference files. A 500-line CLAUDE.md blows past this budget before you type a single command.

Before and After: Bloated vs Optimized

A bloated CLAUDE.md for a marketing project looks like this:

Use TypeScript for all files
Follow ESLint rules strictly
Use Prettier for formatting
Always use async/await instead of promises
Handle all errors with try/catch blocks
Use meaningful variable names
Comment complex logic
Follow Git commit message conventions
Use feature branches for all changes
Run tests before committing
Use encryption for all sensitive data
Never store API keys in code
Follow OWASP security guidelines
Use semantic HTML elements
Follow WCAG accessibility guidelines
Optimize images for web
Use lazy loading for images
Minimize CSS and JavaScript bundles
Use CDN for static assets
Cache API responses when appropriate
... (continues for 400+ more lines)

Claude already knows all of this. Every line wastes instruction budget. An optimized version for the same project:

Project: yfxmarketer.com marketing site
Stack: WP + HubSpot CRM + GA4
Brand voice: @docs/brand-voice.md

Commands:
- npm run dev (local)
- npm run build (production)

Rules:
- UTM format: ?utm_source=yfxmarketer.com (all external links)
- Alt text required on every image
- Blog posts follow @docs/blog-formatting.md

Twelve lines. Everything Claude needs to understand the project context. Everything else lives in @import files or nested CLAUDE.md files loaded on demand.

Action item: Open your CLAUDE.md file right now and count the lines. If it exceeds 100, delete every instruction where Claude already produces correct output without being told. Commit to git before and after so you have a rollback point.

How Does the CLAUDE.md File Hierarchy Work?

CLAUDE.md file hierarchy uses five tiers, with child files loading only when Claude reads files in their directory. This is documented at code.claude.com/docs/en/memory.

The five tiers from broadest to narrowest:

  1. ~/.claude/CLAUDE.md for global preferences across all projects
  2. ./CLAUDE.md at project root for shared team instructions (committed to git)
  3. ./CLAUDE.local.md for personal preferences (auto-gitignored)
  4. Parent directory files for monorepos (loaded at session start)
  5. Child directory files (loaded on demand when Claude reads nearby files)

Specificity wins. A CLAUDE.md in /campaigns/email/ overrides the root file for email tasks. A file in /campaigns/ads/ overrides for ad tasks. Root instructions apply everywhere; nested instructions apply only in their directory.

The @import syntax references external files without loading them upfront. Write See @docs/brand-voice.md for tone guidelines in your root CLAUDE.md. Claude reads it only when the task requires tone guidance. First use triggers a one-time approval dialog.

Marketing Project File Structure

Here is the exact file structure for a marketing automation project:

your-project/
  CLAUDE.md                         (root: 50-100 lines)
  CLAUDE.local.md                   (personal prefs, gitignored)
  .claude/settings.json             (hooks config)
  docs/
    brand-voice.md                  (referenced via @import)
    blog-formatting.md              (referenced via @import)
    ad-copy-guidelines.md           (referenced via @import)
  content/
    CLAUDE.md                       (blog/SEO rules: 20-40 lines)
    blog/
    landing-pages/
  campaigns/
    email/
      CLAUDE.md                     (email rules: 20-30 lines)
    ads/
      CLAUDE.md                     (ad copy rules: 20-30 lines)
    social/
      CLAUDE.md                     (social rules: 15-25 lines)
  analytics/
    CLAUDE.md                       (GA4/reporting rules: 15-25 lines)

Each nested CLAUDE.md holds 15-40 lines of domain-specific instructions. Claude sees them only when working in the relevant directory. Your root file stays under 100 lines. Total instruction surface across all files: 150-250 lines, but Claude loads only 50-100 at any given time.

Action item: Create the folder structure above in your project. Move domain-specific instructions from your root CLAUDE.md into the matching subdirectory file.

What Goes in the Root CLAUDE.md? (Copy-Paste Template)

Root CLAUDE.md for marketing teams needs three sections: project context, commands, and proven-necessary rules. LLMs weigh instructions near the beginning and end of context more heavily, so project context goes first.

Paste this template into your root CLAUDE.md and replace the variables:

Project: {{BRAND_NAME}} marketing automation
Stack: {{FRAMEWORK}} + {{CRM}} + {{ANALYTICS_PLATFORM}}
Domain: {{YOUR_DOMAIN}}
Brand voice: @docs/brand-voice.md
Blog formatting: @docs/blog-formatting.md

Commands:
- {{DEV_COMMAND}} (local development)
- {{BUILD_COMMAND}} (production build)
- {{DEPLOY_COMMAND}} (deployment, requires manual approval)

Rules (add ONLY after Claude makes a specific mistake):
- UTM format: ?utm_source={{YOUR_DOMAIN}} on all external links
- Alt text required on every image
- No em dashes anywhere in content
- Include readTime estimate in all blog frontmatter

Here is a filled-in example:

Project: yfxmarketer.com marketing automation
Stack: Astro + HubSpot + GA4
Domain: yfxmarketer.com
Brand voice: @docs/brand-voice.md
Blog formatting: @docs/blog-formatting.md

Commands:
- npm run dev (local development)
- npm run build (production build)
- npm run deploy (deployment, requires manual approval)

Rules (add ONLY after Claude makes a specific mistake):
- UTM format: ?utm_source=yfxmarketer.com on all external links
- Alt text required on every image
- No em dashes anywhere in content
- Include readTime estimate in all blog frontmatter

Fourteen lines. Claude gets the full project context, knows the tech stack, and has references to detailed docs it loads only when needed.

One critical principle from Anthropic: explain why each rule exists. “Include UTM parameters because we track campaign attribution in HubSpot” outperforms “Include UTM parameters.” Claude uses the reasoning to handle edge cases you did not anticipate.

Action item: Replace your root CLAUDE.md with this template. Fill in your project details. Add rules only as Claude makes mistakes over the next week.

What Goes in Nested CLAUDE.md Files? (Copy-Paste Templates)

Nested CLAUDE.md files hold domain-specific rules for each marketing channel. These load only when Claude reads files in the same directory, saving instruction budget for the actual task.

Content Directory CLAUDE.md

Place this in /content/CLAUDE.md:

Content Rules:
- Every paragraph under 80 words (hard limit)
- First sentence states the main point directly
- No hedging language (might, could, perhaps)
- Primary keyword within first 10 words of each paragraph
- One idea per paragraph (split if multiple concepts)
- Question-style H2 headings for AEO optimization

Blog Post Structure:
- Opening paragraphs (no H1, title in frontmatter)
- TL;DR section after opening
- Key Takeaways (5-7 bullets)
- Main content sections with action items
- Final Takeaways (short paragraphs, not bullets)
- SEO Meta Description (155-160 chars)
- Filename (lowercase, hyphens, 3-6 words)

Banned Words:
delve, landscape, game-changer, unlock, discover, leverage,
furthermore, however, moreover, in conclusion, boost, harness

Email Campaign CLAUDE.md

Place this in /campaigns/email/CLAUDE.md:

Email Rules:
- Subject lines under 50 characters
- Preview text under 90 characters
- Single CTA per email (one clear action)
- Personalization tokens: {{first_name}}, {{company_name}}
- Unsubscribe link required in footer
- Mobile-first design (600px max width)

Tone for emails:
- Direct, conversational, no corporate speak
- Second person (you/your) throughout
- Short paragraphs (2-3 sentences max)

HubSpot-specific:
- Use HubSpot personalization token format
- Include UTM parameters on all links
- Test rendering in Litmus before sending

Ad Copy CLAUDE.md

Place this in /campaigns/ads/CLAUDE.md:

Google Ads RSA Limits:
- Headlines: 30 characters max (15 variations)
- Descriptions: 90 characters max (4 variations)
- Display URL paths: 15 characters each

Meta Ads:
- Primary text: 125 characters (before truncation)
- Headlines: 40 characters max
- Link descriptions: 30 characters max

All ad copy rules:
- Lead with benefit, not feature
- Include one number or statistic when possible
- No trademark symbols unless legally required
- CTA verbs: Get, Start, Try, See, Compare
- Because we A/B test everything, generate 5+ variations minimum

Analytics CLAUDE.md

Place this in /analytics/CLAUDE.md:

GA4 Event Naming:
- Snake_case for all event names
- Format: category_action (e.g., form_submit, cta_click)
- Event parameters: 100 character limit per value
- Custom dimensions must be registered before use

Reporting:
- All date ranges default to last 30 days
- Compare against previous period
- Include sample size in all percentage claims
- Round percentages to one decimal place

Gotchas:
- DebugView has 30-minute delay for some events
- Enhanced measurement conflicts with GTM triggers
- Custom dimensions take 24-48 hours to appear

Each file stays under 40 lines. Claude loads them only when working in the relevant directory. Your instruction budget stays clean.

Action item: Create the four nested CLAUDE.md files above in your project. Customize the rules for your specific tools and brand requirements.

How Do Hooks Replace CLAUDE.md Instructions for Hard Constraints?

Claude Code hooks enforce constraints with 100% reliability because they run as shell commands, not as probabilistic instructions. CLAUDE.md instructions get ignored roughly 1 in 30 to 1 in 50 times during long sessions. Hooks never get ignored.

Hooks are documented at docs.anthropic.com/en/docs/claude-code/hooks. Three types matter for marketers:

  • PreToolUse: Runs before Claude executes a tool (blocks or modifies actions)
  • PostToolUse: Runs after execution (validates output)
  • Stop: Runs when Claude finishes responding (quality checks)

HumanLayer’s guidance: “Never send an LLM to do a linter’s job.” If a constraint is binary pass/fail, it belongs in a hook. If it requires judgment (tone, creativity, strategy), it belongs in CLAUDE.md.

Copy-Paste Hook Configuration

Place this in .claude/settings.json in your project root:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "command": "bash -c 'if echo \"$TOOL_INPUT\" | grep -qE \"(npm run deploy|git push origin main|rm -rf)\"; then echo \"BLOCKED: Dangerous command requires manual execution\" >&2; exit 2; fi'"
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "command": "bash -c 'FILE=$(echo \"$TOOL_INPUT\" | grep -oP \"path.*?:\\s*\\K[^,}]+\" | tr -d \" \\\"\"); if [ -n \"$FILE\" ] && echo \"$FILE\" | grep -qE \"\\.(md|html)$\"; then LONG=$(awk \"BEGIN{p=0} /^```/{p=!p;next} !p && NF && length>0{w=split(\\$0,a,\\\" \\\"); if(w>80) print NR\\\": \\\"w\\\" words\"}\" \"$FILE\"); if [ -n \"$LONG\" ]; then echo \"WARNING: Paragraphs over 80 words: $LONG\"; fi; fi'"
      }
    ]
  }
}

This configuration blocks dangerous deployment commands before they execute and warns about paragraphs exceeding 80 words after any markdown or HTML file write.

Marketing-Specific Hook Use Cases

Constraints belonging in hooks, not CLAUDE.md:

  • Block deployment commands (npm run deploy, git push to main)
  • Validate Google Ads character limits on generated ad copy
  • Check for banned words in content files after generation
  • Prevent deletion of tracking scripts or analytics configuration
  • Enforce image alt text presence after HTML file edits

For each constraint, ask: is this pass/fail with clear criteria? If yes, write a hook. If it requires judgment, keep it in CLAUDE.md.

Action item: Copy the hook configuration above into your .claude/settings.json. Add your specific blocked commands and validation checks. Test by asking Claude Code to run a blocked command and verifying it gets stopped.

Why Does Removing Instructions Improve Output Quality?

CLAUDE.md instructions from older models actively constrain newer ones from doing better work. Vercel proved this with their d0 agent. The original used 17+ tools with heavy constraints. Success rate: 80%. They cut to 2 tools and removed most instructions. Success rate: 100%. Speed improved 3.5x. Token usage dropped 37%.

Claude Opus 4 and Sonnet 4 are 65% less likely to take shortcuts on agentic tasks compared to Sonnet 3.7. They follow instructions with higher fidelity. Many rules you wrote for Sonnet 3.7 now prevent the newer model from applying its own, often better, practices.

One test reveals what to remove. Create a fresh project with no CLAUDE.md. Run your five most common marketing tasks. Content generation, email drafts, ad copy, analytics queries, landing page edits. Note which tasks Claude handles correctly without any instructions. Those instructions waste budget in your current file.

Boris Cherny, who created Claude Code, follows this exact approach. His team maintains one shared CLAUDE.md. They add items only when Claude makes a mistake. They remove items when newer models handle the behavior natively.

The Friday CLAUDE.md Audit

Use this prompt every Friday to audit your CLAUDE.md:

SYSTEM: You are a Claude Code configuration auditor for marketing teams.

<context>
Here is my current root CLAUDE.md:

{{PASTE_YOUR_CLAUDE_MD_HERE}}

Claude Code model version: {{CURRENT_MODEL}}
</context>

Analyze this CLAUDE.md and identify:
1. Instructions Claude's current model version already follows without being told
2. Instructions conflicting with each other
3. Instructions belonging in nested subdirectory files instead of root
4. Instructions belonging in hooks (binary pass/fail constraints)
5. Instructions missing a "because" explanation

Output: Numbered list of specific changes. For each: quote the original line, state the action (remove, move, rewrite), and explain why.

Run this audit weekly. A clean CLAUDE.md accumulates drift over time as team members add instructions without removing old ones.

Action item: Schedule a recurring 15-minute Friday calendar block labeled “CLAUDE.md Audit.” Run the prompt above. Commit changes to git with the message “weekly CLAUDE.md cleanup.”

How Do You Use @Imports to Keep the Root File Lean?

The @import syntax lets your CLAUDE.md reference external documents without loading them at session start. Claude reads the referenced file only when the current task requires it. This keeps your root file under 20 lines while maintaining access to thousands of lines of reference material.

Write references in your root CLAUDE.md like this:

Brand voice: @docs/brand-voice.md
Blog formatting: @docs/blog-formatting.md
Ad copy guidelines: @docs/ad-copy-guidelines.md
Email templates: @docs/email-templates.md
Analytics setup: @docs/analytics-config.md

When Claude generates a blog post, it pulls @docs/blog-formatting.md automatically. When generating ad copy, it pulls @docs/ad-copy-guidelines.md. Your root file stays at 14 lines. Your reference documents hold the detailed rules.

The first time Claude encounters an @import, it shows an approval dialog. After approval, it loads seamlessly in future sessions.

What Goes in Reference Docs vs CLAUDE.md

Apply this decision framework:

  • Project identity (name, stack, domain): Root CLAUDE.md
  • Commands and deployment steps: Root CLAUDE.md
  • Rules Claude has violated in practice: Root CLAUDE.md
  • Brand voice definitions and examples: @import reference doc
  • Formatting specifications: @import reference doc or nested CLAUDE.md
  • Character limits and platform specs: Hook or nested CLAUDE.md
  • Historical decisions and rationale: Git commit messages, not CLAUDE.md

Action item: Create a /docs/ folder in your project. Move your brand voice guide, blog formatting rules, and ad copy guidelines into separate .md files. Reference them with @imports in your root CLAUDE.md.

The Leverage Hierarchy: Where to Invest Your CLAUDE.md Time

The leverage hierarchy, developed by Dex Horthy at HumanLayer, explains why CLAUDE.md matters more than reviewing generated output. One bad line of research produces thousands of bad lines of generated content. One bad line of a plan produces hundreds. One bad line of content produces one bad line of content.

Your CLAUDE.md sits above all three levels. It shapes every research step, every plan, and every generated file. Ten minutes optimizing your CLAUDE.md saves more time than two hours reviewing generated output.

For marketing teams, this translates to concrete time savings:

  • 15 minutes writing a clear root CLAUDE.md saves 3-5 hours/week of manual corrections
  • 30 minutes creating nested files saves 2-3 hours/week of channel-specific rework
  • 20 minutes configuring hooks eliminates recurring constraint violations permanently

Anthropic’s own marketing team demonstrates the pattern. Austin Lau, an Anthropic growth marketer with zero coding background, reduced ad creative generation from 30 minutes to 30 seconds using Claude Code. His setup: separate skill files for brand voice, product accuracy, and Google Ads best practices. A lean root configuration. Rich reference documents loaded on demand.

The wrong investment: spending 2 hours writing 500 lines of micromanagement instructions. The right investment: spending 30 minutes writing 50 lines of clear project context and creating the file structure for Claude to load detailed rules on demand.

Action item: Block 45 minutes this week for CLAUDE.md setup. Spend 15 minutes on root file, 15 minutes on nested files, 15 minutes on hooks. Track time saved over the next two weeks by counting how many times you would have manually corrected Claude Code output.

CLAUDE.md Weekly Audit Checklist

Use this checklist every Friday during your audit:

  • Root file under 100 lines
  • Project description in the first 3 lines
  • Commands listed before constraints
  • Every rule includes a “because” explanation
  • No instructions Claude follows correctly without being told
  • No instructions from previous model versions you have not re-tested
  • Critical binary constraints moved to hooks
  • Domain rules in nested subdirectory files
  • Reference docs use @import syntax
  • No conflicting instructions between root and nested files

Common mistakes to remove from your CLAUDE.md:

  • Copied prompts from Twitter without testing against your project
  • History of changes (use git commit messages for this)
  • Code examples teaching Claude things it already knows
  • Obvious best practices (“use encryption,” “follow security guidelines”)
  • Instructions longer than two sentences (split or move to reference docs)

Action item: Print this checklist and tape it to your monitor. Run through it every Friday for the next month until the audit becomes a 5-minute habit.

Final Takeaways

Your CLAUDE.md instruction budget is roughly 100-150 usable slots after Claude Code’s system prompt loads. A 500-line file blows past this budget and causes random instruction skipping. Keep the root file under 100 lines.

Split domain rules into nested CLAUDE.md files in /content/, /campaigns/email/, /campaigns/ads/, and /analytics/ directories. These load on demand, so Claude sees only what matters for the current task.

Hooks enforce binary constraints (character limits, blocked commands, banned words) with 100% reliability. CLAUDE.md instructions get ignored 1 in 30 to 1 in 50 times. Every hard constraint belongs in a hook.

Every model upgrade is a signal to remove instructions. Claude Opus 4 and Sonnet 4 handle most best practices natively. Test your five most common tasks without CLAUDE.md, and delete any rule Claude already follows.

Time investment: 45 minutes of setup (root file + nested files + hooks) saves 3-5 hours per week of manual corrections. Schedule a 15-minute Friday audit to prevent instruction drift. The compounding returns make this one of the highest-ROI marketing ops tasks you do this quarter.

yfx(m)

yfxmarketer

AI Growth Operator

Writing about AI marketing, growth, and the systems behind successful campaigns.

read_next(related)