Claude Code Examples: 12 Real Prompts & CLAUDE.md Templates (2026)
Production-tested examples from 3 months of running a company on Claude Code agents. Not toy demos — these patterns handle real workflows daily.
Most Claude Code tutorials show you hello world examples. This isn’t that. Every example here runs in production at our company — handling deployments, content pipelines, email sequences, and monitoring.
Use these as copy-paste starting points. Adapt the prompts and CLAUDE.md files to your actual use case.
The 3 things that make Claude Code examples actually work
Before the examples: three principles that separate toy demos from production agents.
- Explicit scope limits — Tell the agent exactly what it can and cannot touch. Vague prompts create scope creep and unintended changes.
- Commit checkpoints — Every 3–5 file changes should trigger a commit. Crashes happen. Uncommitted work is lost work.
- Escalation thresholds — Define when the agent stops and asks a human vs. proceeds autonomously. Most agents fail because this line is blurry.
12 Claude Code examples by use case
1 Autonomous blog post writer
Prompt pattern:
Terminalclaude -p "Write a comprehensive blog post about [TOPIC] targeting the keyword '[KEYWORD]'. Requirements: - 1200-1800 words - H1, H2, H3 structure - Include a comparison table - Add JSON-LD Article schema in <head> - CTA section at the end linking to /signup/ - Save as /var/www/site/blog/[slug].html using the existing template at /var/www/site/blog/claude-code-vs-cursor-2026.html - Commit with message: [marketing] blog: add [slug] Do not touch any other files." --max-turns 15
Key detail: Point to an existing file as a template. The agent copies the design system correctly instead of inventing new CSS.
2 Deployment agent with rollback
CLAUDE.md (deployment agent)# Deployment Agent ## What you can do - Run: git pull, npm run build, systemctl restart [service] - Write to: /var/www/app/ only - Read: any config file to verify state ## What you CANNOT do - Modify /etc/caddy/Caddyfile without explicit instruction - Delete files (use git revert instead) - Touch .env files ## On failure If any deployment step returns non-zero: 1. Run: git revert HEAD --no-edit 2. Run: systemctl restart [service] 3. Report: DEPLOYMENT FAILED — rolled back to [commit hash] 4. Stop. Do not retry.
Why the “stop on failure” rule matters: Without it, agents retry failed deployments in loops, compounding errors.
3 Multi-file refactor agent
Terminalclaude -p "Rename the function 'processUserData' to 'transformUserRecord' across the entire codebase. Steps: 1. First: grep -r 'processUserData' src/ to find all occurrences 2. List every file you will change before making any changes 3. Make changes one file at a time 4. After each file: run the test suite (npm test) 5. If any test fails: revert that file, report which test failed, stop 6. Final commit: '[refactor] rename processUserData to transformUserRecord (N files)' Scope: src/ directory only. Do not touch node_modules, dist, or .env" --max-turns 30
Pattern: List files before changing them. This forces the agent to plan, not just act.
4 KPI monitoring agent
CLAUDE.md (monitoring agent)# Monitoring Agent — Hourly KPI Check ## Data sources - Supabase: SELECT count(*) FROM trial_signups WHERE created_at > now() - interval '24h' - Supabase: SELECT sum(amount) FROM payments WHERE created_at > now() - interval '7d' - Server health: curl -s -o /dev/null -w "%{http_code}" https://example.com/ ## Thresholds (escalate to human if breached) - Signup rate: 0 signups in last 48h AND runway < 10 days → ESCALATE - Revenue: weekly MRR drops >20% → ESCALATE - Site health: HTTP status != 200 → ESCALATE IMMEDIATELY ## Escalation format Send message: "[MONITORING] ALERT: [metric] = [value]. Threshold: [threshold]. Action needed." ## Normal operation Log to /logs/monitoring.log with format: [2026-05-01 10:00] signups_24h=3 mrr_7d=€87 site_status=200 STATUS=OK
5 Email sequence writer
Terminalclaude -p "Write a 6-email trial onboarding sequence for [PRODUCT]. User profile: signed up for a free trial, technical background, wants to automate workflows. Email specs: - Email 1 (day 0): Welcome + first win in <10 minutes - Email 2 (day 2): Key feature spotlight + tutorial link - Email 3 (day 4): Social proof (case study or testimonial) - Email 4 (day 6): Upgrade CTA with specific offer (€29/mo or €49/mo) - Email 5 (day 10): FAQ + objection handling - Email 6 (day 14): Final offer + what they lose at trial end Format each email as: Subject: [subject line] Preview text: [50 char preview] Body: [plain text, scannable, max 200 words] CTA: [button text] → [URL] Save to: /deliverables/email-sequence-[date].md Do not send anything. Only write and save." --max-turns 10
6 Hierarchical agent system (CEO → Worker)
CEO-level CLAUDE.md# CEO Agent ## Your mandate Coordinate department agents to achieve the weekly goal. You do NOT write code or content yourself. ## How to delegate Spawn worker agents using the Agent() tool: - coder subagent for: code changes, deployments, config - researcher subagent for: market research, competitive analysis - general-purpose subagent for: content, reports, planning ## Escalate to human (Daniel) when: - Any spend decision > €50 - External communications to customers/partners - Irreversible infrastructure changes (database drops, DNS changes) - Runway < 10 days with zero revenue ## Never do yourself - Write or commit code - Deploy to production - Send emails or messages externally - Make purchasing decisions
See the complete CLAUDE.md guide for the full hierarchy pattern.
7 Sitemap generator
Terminalclaude -p "Generate a sitemap.xml for the site at /var/www/agentic-movers/. Steps: 1. Find all .html files: find /var/www/agentic-movers -name '*.html' -not -path '*/node_modules/*' 2. Convert file paths to URLs: replace /var/www/agentic-movers with https://agentic-movers.com 3. For blog posts: set <changefreq>monthly</changefreq> and <priority>0.7</priority> 4. For main pages (/, /about/, /pricing/, /signup/): priority 0.9, changefreq weekly 5. Set <lastmod> to today's date for all URLs 6. Save to /var/www/agentic-movers/sitemap.xml 7. Verify: curl https://agentic-movers.com/sitemap.xml | head -20 Commit: '[seo] regenerate sitemap with [N] URLs'" --max-turns 8
8 Database migration agent
CLAUDE.md (database agent)# Database Migration Agent ## Allowed operations - SELECT queries: any table, any time - INSERT/UPDATE: only on tables listed in current task - CREATE TABLE: only with explicit instruction naming the table - Migrations: run only the file specified in current task ## Forbidden - DROP TABLE or DROP COLUMN (ever) - DELETE without WHERE clause - Modifying production data without explicit approval ## Migration protocol 1. Run migration on staging first (DB_URL_STAGING) 2. Verify: run the verification query specified in migration file 3. If staging passes: ask for explicit GO before running on production 4. After production: re-run verification query, log result 5. If production fails: DO NOT attempt rollback yourself. Report and stop.
9 Social media scheduler
Terminalclaude -p "Create a 7-day Telegram post calendar for the [COMMUNITY_NAME] channel. Theme: practical Claude Code tips for developers and indie hackers. Post format: - Day 1 (Mon): Quick tip (<100 words) with code snippet - Day 2 (Tue): Community question to drive replies - Day 3 (Wed): Link to best blog post this week + 2-sentence summary - Day 4 (Thu): Behind-the-scenes update from our company - Day 5 (Fri): Weekend project idea (actionable, doable in 2h) Tone: direct, no fluff, no emojis except 1-2 relevant ones per post. Save each post to: /deliverables/telegram-kw[WEEK]-[day].txt Do NOT publish anything. Just write and save." --max-turns 12
10 Code review agent
Terminalclaude -p "Review the git diff below for: (1) bugs, (2) security issues, (3) style violations. $(git diff main..feature-branch) Output format: ## Bugs (must fix before merge) - [file:line] Description of bug ## Security (must fix before merge) - [file:line] Description of issue ## Style (optional, non-blocking) - [file:line] Suggestion ## Summary APPROVE / REQUEST CHANGES / BLOCK Do not modify any files. Only analyze and report." --max-turns 5
Critical: “Do not modify any files” — code review agents should never auto-fix. That’s a separate agent with a separate scope.
11 Incident response agent
Terminalclaude -p "The site at https://example.com returned 502 at 14:30 UTC. Diagnose and report. Investigate in this order: 1. systemctl status caddy nginx (whichever is used) 2. journalctl -u caddy -n 50 --no-pager 3. curl -v https://example.com 2>&1 | tail -20 4. Check disk space: df -h 5. Check memory: free -m 6. Check processes: ps aux | grep node | head -10 Do NOT restart anything. Do NOT modify any config. Only diagnose and report. Output: ## Root cause [1-2 sentences] ## Evidence [key log lines] ## Recommended fix [specific command to run — but do not run it yourself]" --max-turns 8
12 Full company agent stack (production CLAUDE.md)
Strategy Dept CLAUDE.md (production)# Strategy Department Agent ## Role Weekly KPI tracking, competitive intelligence, revenue planning. ## Outputs (weekly, autonomous) - KPI report: /shared-memory/strategy_status.md (append, don't overwrite) - Weekly brief: /deliverables/kw[N]-weekly-brief-[date].md - Content calendar: /deliverables/telegram-kw[N]-calendar.md ## Data sources - Supabase: trial_signups, payments tables - /var/www/agentic-movers/ (blog post count, new pages) - shared-memory/ (cross-agent state) ## Escalate to CEO when - Runway < 10 days AND MRR = 0 → P0 escalation - Revenue event (any payment) → alert immediately - Competitive threat (new product targeting our exact niche) → within 24h ## Do NOT - Post on social media directly - Send emails - Make financial decisions - Modify production infrastructure
Full case study with all department CLAUDE.md files: Running a Company with 20+ Claude Code Agents
Which Claude model for which example?
| Use case | Model | Why |
|---|---|---|
| CEO / orchestrator agent | claude-opus-4-6 | Complex multi-step planning |
| Department lead agent | claude-sonnet-4-6 | Good reasoning, lower cost |
| Worker agents (code, deploy, write) | claude-haiku-4-5 | Fast, cheap, enough for scoped tasks |
| Code review, security audit | claude-sonnet-4-6 | Needs careful reasoning |
| Simple formatting / templating | claude-haiku-4-5 | Overkill to use Opus here |
Cost reality: Running 4 department agents + 1 CEO agent, 8h/day, our actual Claude API cost is ~€30–40/month. Most of the work is Haiku-tier. Only orchestration and strategy tasks need Sonnet+.
3 mistakes that break every Claude Code example
1. No file scope limit
Without explicit scope, agents helpfully “improve” things they weren’t asked to touch. Always add: “Only modify files in [directory]. Do not touch [other directories].”
2. No commit cadence
Agents that run 40 steps without committing will lose everything if the session crashes. Force commits every 3–5 file changes with explicit instructions.
3. Escalation threshold is “never”
Agents without escalation rules will autonomously make decisions they shouldn’t. Define exactly when the agent must stop and report instead of proceed.
Get 30+ more templates & patterns
The Claude Code Mastery course includes production CLAUDE.md files, n8n workflow templates, and the complete multi-agent architecture we use daily.
Start free trial → No credit card · Instant access · Cancel anytime