A Claude Code setup for agencies: CLAUDE.md, subagents, hooks and commands
How to configure Claude Code so every developer and freelancer on every client project gets the same, safe behaviour, with copy-ready examples for each layer.
By ProvenCart6 min read#claude-code#agencies#workflow#hooks
A good Claude Code setup for an agency has four layers: a CLAUDE.md per project that states the stack, commands and client rules; a small set of subagents for recurring reviews (SEO, accessibility, security, performance); hooks that enforce what must never be left to chance (formatting, protected files, dangerous commands); and slash commands for the routines you run every week (client updates, changelogs, QA passes). Put all of it in the repository under .claude/ so every developer, freelancer and CI job gets the same behaviour. This guide shows how we structure each layer, with copy-ready examples.
Why agencies need more than defaults
An agency is not one codebase. It is twenty client projects on five stacks, with different hosting, languages, legal requirements and tone of voice. Without shared configuration, every developer re-explains the project to Claude in every session, and quality depends on who is typing.
The fix is to treat AI configuration like code: versioned, reviewed, and identical for everyone who opens the repository.
client-project/
├── CLAUDE.md # project memory: stack, commands, rules
├── .mcp.json # project MCP servers (no secrets)
└── .claude/
├── settings.json # permissions + hooks (shared)
├── settings.local.json # personal overrides (git-ignored)
├── agents/ # subagents
├── commands/ # slash commands
├── hooks/ # hook scripts
└── skills/ # project skills
Layer 1: CLAUDE.md, the project brief Claude reads every time
Claude Code loads CLAUDE.md from the project root at the start of every session. Additional CLAUDE.md files in subdirectories are read when Claude works in those folders, and a personal ~/.claude/CLAUDE.md holds your own preferences across projects. You can import other files with @path/to/file.
Write it for a new senior developer who has ten minutes. What we put in every client project:
# Müller Bikes: WooCommerce shop
## Stack
WordPress 6.x, WooCommerce, child theme in wp-content/themes/mueller-child, PHP 8.2.
Staging: staging.mueller-bikes.de · Production deploy only via GitHub Actions.
## Commands
- composer lint · npm run build (theme assets) · wp cli via `ddev wp`
## Rules
- Never edit parent theme or plugin files; use hooks in the child theme.
- Client language is German, formal "Sie" in all customer-facing text.
- Legal pages (Impressum, Datenschutz, AGB) are owned by the client's lawyer: do not edit.
- Prices are gross; never hard-code VAT rates.
Keep it short and concrete. Every line should change behaviour; "write clean code" does not. If a rule keeps being ignored, it is probably buried in prose: move it into a bullet under Rules, or enforce it with a hook.
Layer 2: Subagents for specialised reviews
Subagents are Markdown files in .claude/agents/ with frontmatter that defines a name, a description (when to use it), the tools it may use and optionally the model. Each runs in its own context window, so a long SEO or accessibility review does not flood the main conversation.
---
name: seo-auditor
description: Technical SEO review of templates and routes. Use before launch, after migrations, or when pages do not index. Read-only.
tools: Read, Grep, Glob, WebFetch
---
You audit what the code and rendered pages output: titles, meta descriptions,
canonicals, hreflang, structured data, robots, sitemaps, redirects.
Report findings as a table: severity, file:line, issue, fix. Do not edit files.
The subagents we find worth having in an agency:
| Subagent | Job | Tools |
|---|---|---|
code-reviewer |
Reviews a diff against the project's CLAUDE.md rules | Read-only |
seo-auditor |
Metadata, canonicals, hreflang, structured data | Read-only + fetch |
accessibility-auditor |
Semantics, focus, contrast, labels | Read-only |
security-reviewer |
Secrets, injection, auth, dependency risks | Read-only |
performance-auditor |
Bundle size, images, render-blocking, Core Web Vitals | Read-only + Bash for builds |
client-report-writer |
Turns git history into plain-language updates | Read-only |
Make reviewers read-only. A reviewer that can also edit tends to "fix" things nobody asked it to.
Layer 3: Hooks for what must always happen
Instructions are suggestions; hooks are guarantees. Hooks are shell commands configured in .claude/settings.json that run on events such as PreToolUse, PostToolUse, UserPromptSubmit, SessionStart and Stop. A PreToolUse hook that exits with code 2 blocks the tool call and tells Claude why.
{
"hooks": {
"PreToolUse": [
{ "matcher": "Edit|Write", "hooks": [{ "type": "command", "command": "node .claude/hooks/protect-files.mjs" }] },
{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "node .claude/hooks/guard-bash.mjs" }] }
],
"PostToolUse": [
{ "matcher": "Edit|Write", "hooks": [{ "type": "command", "command": ".claude/hooks/format-on-edit.sh" }] }
]
}
}
Hooks that pay for themselves within a week:
- Protect files: block edits to
.env, lock files, legal pages, vendor directories. - Guard Bash: block
rm -rfoutside the project, force pushes, production database commands. - Format on edit: run Prettier, PHP-CS-Fixer or the project's formatter after every edit.
- Check on stop: run the linter or type checker when Claude finishes, so problems surface before you review.
- Session context: print the current branch, open tickets or staging URL at session start.
Combine hooks with permissions in the same file: allow read-only git and test commands so Claude does not ask every time, and deny what should never run.
Layer 4: Slash commands for weekly routines
Custom commands are Markdown prompts in .claude/commands/; the file name becomes the command. $ARGUMENTS inserts what you type after it. In recent Claude Code versions skills can be invoked the same way, so pick whichever format suits the task: a command for a single prompt, a skill when you need bundled scripts and references.
---
description: Draft a client status update from git history.
argument-hint: "[since: 7d | 2026-11-01] [de|en]"
---
Draft a client status update for: $ARGUMENTS
1. Collect commits in the period, group by feature, ignore chores.
2. Write in the client's language and form of address from CLAUDE.md.
3. Max 150 words, no internal ticket numbers, end with next steps.
Commands that agencies use constantly: /kickoff (set up CLAUDE.md for a new project), /client-update, /changelog, /qa-pass, /estimate, /handover.
Rolling it out across 20 projects
- Start with one template repository that contains the
.claude/folder, then copy it into projects. Keep project-specific facts only inCLAUDE.md. - Stack-specific CLAUDE.md templates (WordPress, Shopify, Next.js, landing pages) save the most time.
- Share MCP config without secrets.
.mcp.jsonlists servers; credentials come from environment variables. - Review AI config changes in pull requests like any other code.
- Measure with simple signals: fewer review comments about conventions, faster onboarding of freelancers.
Get the complete kit
Building all of this from scratch takes days of trial and error. The Claude Code Agency Kit contains stack templates for CLAUDE.md, ten subagents, the hooks above, eight agency commands, skills for site launches, release notes and client handovers, and an installer that merges into existing settings. For consistent rules across Cursor, Copilot and Claude in mixed teams, add Ship Rules; the trade-offs are explained in Cursor rules vs CLAUDE.md vs AGENTS.md. For delivery documents (briefs, estimates, reports) outside the code, see the Agency Delivery Pack.
FAQ
Should CLAUDE.md be committed to git?
Yes, for shared project rules. Personal preferences belong in ~/.claude/CLAUDE.md, and machine-specific settings in .claude/settings.local.json, which should be git-ignored.
Do subagents cost more tokens?
Each subagent has its own context, so a delegated task uses tokens there instead of in the main thread. For long reviews this often saves tokens overall, because the main conversation stays small.
Can hooks break my session?
A buggy blocking hook can stop Claude from editing anything. Keep hook scripts small, test them with sample input, and log what they block.
How do freelancers get the same setup?
They clone the repository like everyone else. Because CLAUDE.md, .claude/settings.json, subagents, commands and hooks are committed, a freelancer's Claude Code behaves exactly like yours from the first session. Only credentials and personal preferences stay on their machine.
Tools from this article
Agent kit
Claude Code Agency Kit
Subagents, slash commands, hooks and guard rails for client web projects.
Agent kit
Ship Rules
Production rules for Next.js + TypeScript, generated for every AI coding tool.
Prompt pack
Agency Delivery Prompt Pack
120 prompts for the whole client lifecycle, from discovery to renewal.
Bundle· 6 products
Developer Bundle
MCP servers, Claude Code setup and production rules for client web projects.