---
title: "Claude Code Patterns | Scott Havird"
description: "Production-tested patterns for Claude Code including hooks, CLAUDE.md configuration, MCP integrations, and enterprise team workflows."
image: "https://scotthavird.com/img/og-image.png"
---

# Claude Code Patterns

Claude Code has become the most-used AI coding tool for complex development tasks. Its terminal-native, agent-first approach enables workflows that IDE-based tools can't match — but getting the most out of it requires intentional configuration. This pillar page collects production-tested patterns from my daily use.

## Hooks: Deterministic Automation

[Claude Code Hooks](/blog/claude-code-hooks-guide/) are the foundation of a mature Claude Code workflow. They fire at specific lifecycle events and are executed by the harness, not by Claude — meaning they always run.

**Essential hook patterns:**

-   **Auto-format after edits** — Prettier, Black, or gofmt runs automatically on every file Claude touches
-   **File protection** — Block edits to `.env`, `secrets.yml`, and other sensitive files
-   **Quality gates** — Run tests and type checking before Claude stops working
-   **Desktop notifications** — Get alerted when Claude needs input
-   **Context re-injection** — Restore critical context after conversation compaction
-   **Auto-approval** — Skip permission prompts for safe, read-only operations
-   **Environment management** — Sync environment variables with direnv

See the [complete hooks guide](/blog/claude-code-hooks-guide/) for configuration syntax and working examples.

## CLAUDE.md: Project Context

CLAUDE.md is how you give Claude permanent context about your project. Unlike conversation messages that eventually get compacted, CLAUDE.md is loaded at the start of every session.

**What to include:**

-   Build and test commands (`yarn build`, `yarn test`, `yarn typecheck`)
-   Architecture overview (tech stack, key files, content structure)
-   Project conventions (naming, file organization, coding patterns)
-   SEO or content-specific guidelines

**What NOT to include:**

-   Information that changes frequently (use hooks or conversation for that)
-   Overly detailed instructions (Claude works better with constraints than scripts)
-   Security secrets (CLAUDE.md is committed to git)

The [Claude Code Template](/blog/claude-code-template/) provides a production-ready CLAUDE.md structure along with devcontainer support, custom commands, and analytics integration.

## Team Configuration

Claude Code supports three configuration scopes, each serving a different purpose:

| Scope | File | Shared? | Use For |
| --- | --- | --- | --- |
| Project | `.claude/settings.json` | Yes (git) | Team rules: formatting, file protection, quality gates |
| Local | `.claude/settings.local.json` | No (gitignored) | Personal prefs: notifications, auto-approvals |
| Global | `~/.claude/settings.json` | No | Cross-project personal config |

**Production team recommendation:**

1.  Commit `.claude/settings.json` with shared hooks (formatting, file protection)
2.  Commit `CLAUDE.md` with project context and conventions
3.  Let developers customize `.claude/settings.local.json` for personal preferences
4.  Document the setup in your project README

## MCP Server Integration

Model Context Protocol (MCP) servers extend Claude Code with external tool access — databases, APIs, documentation systems, and more. The hooks system can gate MCP tool usage for security.

## Analytics Integration

[PromptConduit](/blog/promptconduit-ai-assistant-analytics/) integrates with Claude Code via hooks to capture every prompt, tool invocation, and response. This enables:

-   Usage pattern analysis across projects and team members
-   Session replay for understanding how AI assistance flows
-   Cost tracking per session, project, and developer
-   Productivity measurement through the [measurement framework](/blog/measure-ai-coding-productivity/)

## Related Content

-   [Claude Code Hooks: A Complete Guide](/blog/claude-code-hooks-guide/)
-   [Claude Code Template: Accelerating AI-Assisted Development](/blog/claude-code-template/)
-   [PromptConduit: Building Analytics for AI Coding Assistants](/blog/promptconduit-ai-assistant-analytics/)
-   [How to Measure AI Coding Productivity](/blog/measure-ai-coding-productivity/)
-   [AI Coding Tool Comparison 2026](/blog/ai-coding-tool-comparison-2026/)

```json
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    {
      "@type": "ListItem",
      "position": 1,
      "name": "Claude Code Patterns",
      "item": "https://scotthavird.com/docs/claude-code-patterns"
    }
  ]
}
```
