Setup and context
Write a focused CLAUDE.md, not a wiki CONTEXT
CLAUDE.md is the project-level context file Claude reads at the start of every session. Treat it like onboarding instructions to a new engineer — direct, terse, action-oriented.
Include: tech stack, where the entry points live, naming conventions, commands for build/test/lint, common gotchas, and team coding style preferences. Skip: marketing copy, history, philosophy. Keep it under 500 words.
Use /init to bootstrap CLAUDE.md CONTEXT
Run /init in a fresh repo and Claude will generate a starter CLAUDE.md by inspecting the codebase. Edit it down to what matters — the auto-generated version is usually too verbose.
Keep secrets out of context SECURITY
Anything in CLAUDE.md, file paths, or pasted into chat is part of the model's context. Don't paste API keys, customer data, or production credentials. For sensitive workflows, route through a gateway (Clarista, internal MCP proxy) that scrubs PII automatically.
Workflow patterns
Use plan mode before action mode WORKFLOW
For any task touching more than 2-3 files, ask Claude to plan first. Plan mode shows you what it intends to do without executing. Approve the plan, then say "go." This catches misinterpretations before they become expensive bad code.
Compact aggressively WORKFLOW
Long sessions accumulate context that crowds out new information. Use /compact after major milestones to summarize the conversation and reset the context budget. The trade-off: you lose detail, but you regain reasoning quality.
Use sub-agents for noisy tasks WORKFLOW
For codebase searches, test suite runs, or multi-file refactors, spawn a sub-agent via the Task tool. The sub-agent does the work in its own context, returns a summary, and your main session stays clean.
Good sub-agent prompts: "Run the entire test suite. Report only failing tests with the relevant assertion message. Under 200 words." Bad sub-agent prompts: "Help me with my codebase."
Tell Claude what success looks like WORKFLOW
"Fix the bug" is a worse prompt than "Fix the bug. Verify by running pytest tests/test_billing.py. The test should print '5 passed'." Concrete success criteria make Claude verify its own work and stop earlier.
Use slash commands for repetitive workflows WORKFLOW
If you run the same task more than twice, codify it as a custom slash command in ~/.claude/commands/. Examples: /release, /runbook, /migrate. The command lives in version control and the team uses the same workflow.
Hooks (automation)
Use PreToolUse hooks to block dangerous operations SAFETY
A PreToolUse hook fires before Claude runs a tool. Use it to block rm -rf, prevent writes to /etc, require confirmation for destructive Bash. Critical for teams letting Claude run with bash access.
Use PostToolUse hooks for auto-format and lint QUALITY
After every file write, run Prettier / Black / Rustfmt. After every commit, run the linter. PostToolUse hooks make this automatic. Result: AI-generated code matches your codebase style without manual cleanup.
MCP and integrations
Use scoped credentials for every MCP server SECURITY
github-mcp gets a read-only PAT. Postgres MCP gets a read-only DB user. If a server gets compromised, blast radius is limited.
Track MCP configuration in Git REPRODUCIBILITY
Commit your ~/.claude/settings.json as a dotfile. When you onboard a new engineer or set up a new machine, they pull the file and they're configured. More on MCP servers and plugins →
Prefer plugins to one-off MCP installs REPRODUCIBILITY
Plugins are versioned bundles. Easier to roll back, easier to share. A team-published plugin beats every engineer wiring MCP servers separately.
Cost and performance
Use the right model for the task COST
Haiku for routine work (formatting, simple refactors, boilerplate). Sonnet for most everyday engineering. Opus for complex reasoning, system design, architecture decisions. Don't pay Opus prices for tasks Haiku can do.
Set session budgets in CI COST
When running Claude Code in CI (auto-PR-review, auto-doc-generation), cap each run with --max-budget. A runaway agent can spend $50 in a single PR if uncapped.
Cache long-lived context COST
When calling the API directly (not the CLI), use prompt caching for content that doesn't change between calls — your CLAUDE.md, large reference files, system prompts. Cuts costs by 90%+ on cached portions.
Production and enterprise
Don't ship Claude Code output direct to prod SAFETY
Even with hooks and scanning, AI-generated code should go through your normal review pipeline: PR, CI, security scan, human review, staged deploy. 14-point production checklist →
For regulated work, run through a gateway COMPLIANCE
If your CISO has to sign off on what AI sees: route Claude Code through a governance layer (Clarista or similar) that enforces BYO LLM, scrubs PII, logs every prompt + diff, and applies policy. Native Claude Code is great for engineering productivity but doesn't include compliance infrastructure out of the box.
Run Claude Code with enterprise guardrails
Clarista is the production layer for Claude Code: BYO LLM, audit log on every prompt, SAST/SCA on every output, deploy gates that catch what hooks miss. Use Claude Code as your interface, Clarista as the governance.
See Claude Code for Enterprise →Claude Code skills, code review, plan mode, agent teams
Three more high-value patterns worth calling out:
- Claude Code skills — SKILL.md files that activate based on user intent. Best for codifying complex multi-step workflows your team uses regularly (release process, incident response, migration runbooks). Package them into plugins for distribution.
- Claude Code review — using Claude Code as an automated PR reviewer. Hook it into your CI to run on every PR, surface issues, suggest improvements. Quality is consistently above mid-level human reviewer when prompted well.
- Claude Code plan mode — for any task touching 3+ files, ask for a plan first. The plan surfaces misinterpretations before they become wasted execution. Approve, then say "go."
- Claude Code agent teams / Claude Code agents — running multiple Claude Code sessions in parallel via the SDK, each as a specialist agent (test runner, doc writer, refactorer). The orchestrator coordinates. Pattern works well for large codebase migrations.
FAQ
What's the most under-used Claude Code feature?
Hooks. They turn Claude Code from a tool you babysit into one that enforces your standards automatically.
Should every engineer have their own CLAUDE.md?
The project-level CLAUDE.md is team-shared and committed. Engineers can layer a personal ~/.claude/CLAUDE.md for their own style preferences. Both work together.
How do I keep team-wide MCP server config consistent?
Publish an internal plugin that bundles your approved MCP servers. Every engineer installs the plugin and they're aligned. Full MCP guide →