*This is Part 2 of a 3-part series on Mastering Claude Code in 2026.* * [Part 1: Foundations, Setup, and Core Concepts](/mastering-claude-code-part-1-foundations/) * **Part 2: Workflow Mastery, Plan Mode, and Custom Skills** * [Part 3: Advanced Ops, Multi-Agents, and Enterprise Workflows](/mastering-claude-code-part-3-advanced/) ## Part 8: CLAUDE.md — Your Project's Brain This is arguably the most important concept in Claude Code, and most people skip it. **CLAUDE.md** is a markdown file that Claude reads automatically at the start of every session. It's your project's persistent memory — the context that makes Claude useful instead of generic. ### What Goes in CLAUDE.md? **What** — your tech stack, directory structure, and key files. **Why** — the purpose of each module, design decisions, gotchas. **How** — build/test/lint commands, deployment workflows, coding conventions. Here's a real-world example: ```markdown # CLAUDE.md ## Tech Stack SvelteKit + TypeScript + Tauri (desktop app) ## Commands - `npm run dev` — Start dev server on port 5173 - `npm run build` — Production build - `npm test` — Run Vitest tests - `npm run lint` — ESLint + Prettier check ## Architecture - `/src/routes` — SvelteKit pages and API routes - `/src/lib` — Shared components and utilities - `/src-tauri` — Rust backend for desktop ## Conventions - Use Svelte 5 runes syntax ($state, $derived, $effect) - TypeScript strict mode, no `any` types - All components use `.svelte` extension - Commit messages: imperative mood, < 72 chars ## Gotchas - Tauri commands must be registered in `src-tauri/src/lib.rs` - CSS modules don't work with Svelte — use scoped styles - The auth token is stored in Tauri's secure storage, not localStorage ``` ### Keep It Concise Aim for 50-100 lines in the root file. For each line, ask: "Would removing this cause Claude to make a mistake?" If not, cut it. ### The CLAUDE.md Hierarchy Claude Code loads memory files in layers: **Global** (`~/.claude/CLAUDE.md`) — applies to all your projects. Put your personal preferences here: preferred languages, coding style, how you like commit messages formatted. **Project root** (`CLAUDE.md` or `.claude/CLAUDE.md`) — applies to this project. This is where your tech stack, commands, and conventions go. Commit this to version control so your team gets the same context. **Subdirectory** (`frontend/CLAUDE.md`) — applies only when working in that directory. Use for package-specific conventions in monorepos. Each level appends to the parent. Subfolder files add context; they never overwrite the root. ### Generate It Automatically Don't want to write it from scratch? Run: ``` /init ``` Claude Code analyzes your codebase and generates a starter CLAUDE.md with detected build systems, test frameworks, and code patterns. Edit it from there. ## Part 10: Skills — Your Custom Superpowers Skills are reusable prompts that show up as slash commands. They're how you teach Claude Code your specific workflows. Every skill needs a `SKILL.md` file with two parts: YAML frontmatter (the configuration) and markdown content (the instructions). ### Creating a Skill Create a file at `.claude/skills/deploy/SKILL.md`: ```markdown Deploy the application to the $ARGUMENTS environment (default: staging). Steps: 1. Run the test suite first 2. Build the production bundle 3. Deploy using the deploy script 4. Verify the deployment is healthy 5. Report the deployment URL ``` Now you can type `/deploy production` and Claude follows your playbook. ### Skill Scoping **Project skills** (`.claude/skills/`) — shared via version control, available to your whole team. **Personal skills** (`~/.claude/skills/`) — available across all your projects, just for you. ### Advanced Skill Features **`context: fork`** — runs the skill in an isolated sub-agent context. Great for skills that produce verbose output (like codebase analysis) so they don't pollute your main conversation. **`allowed-tools`** — restricts which tools the skill can use. For example, limit a read-only analysis skill to just `Read, Grep, Glob` so it can't accidentally modify files. **`model`** — run a specific skill on a different model. Use `claude-3-5-haiku-20241022` for fast, cheap skills like linting checks. ### Skills vs. CLAUDE.md Think of it this way: CLAUDE.md is always loaded (universal context). Skills are on-demand (task-specific workflows). Put your coding conventions in CLAUDE.md. Put your deployment workflow in a skill. ## Part 12: Hooks — Automation Guardrails Hooks are scripts that run automatically at specific points in Claude Code's workflow. They're deterministic callbacks — they always run, unlike prompt-based instructions that Claude might occasionally skip. ### Three Types of Hooks **PreToolUse** — runs before Claude executes a tool. Use it to validate, block, or modify tool calls. Example: block any `rm -rf` commands, or prevent refunds above a certain amount. **PostToolUse** — runs after a tool returns results. Use it to normalize data formats, log results, or trigger notifications. **Notification** — runs when Claude wants to notify you about something. ### Configuring Hooks In your `.claude/settings.json`: ```json { "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "scripts/validate-command.sh", "timeout": 5 } ] } ] } } ``` Exit codes control behavior: 0 = allow, 2 = block. ### Why Hooks Matter Prompt instructions are probabilistic — Claude will *usually* follow them. Hooks are deterministic — they *always* run. For anything safety-critical (blocking destructive commands, enforcing code style, requiring tests before commits), use hooks instead of relying on prompt instructions alone. name: security-reviewer description: Reviews code for security vulnerabilities model: claude-opus-4-6 allowed-tools: Read, Grep, Glob ## Part 14: Claude Code in CI/CD Claude Code isn't just for interactive development. You can integrate it into your automated pipelines. ### Running in Pipelines Use the `-p` flag for non-interactive mode: ```bash claude -p "Review this pull request for security issues and code quality" ``` This processes the prompt, outputs the result, and exits — no interactive input needed. Without `-p`, Claude Code will hang waiting for user input, which breaks CI/CD pipelines. ### Structured Output for Automation ```bash claude -p "List all TODO comments with file and line number" \ --output-format json \ --json-schema '{"type": "array", "items": {"type": "object", "properties": {"file": {"type": "string"}, "line": {"type": "integer"}, "comment": {"type": "string"}}}}' ``` This gives you machine-parseable output you can pipe into other tools, post as PR comments, or feed into dashboards. ### CI/CD Best Practices Use separate Claude instances for generating code and reviewing it. A model reviewing its own output in the same session is less effective than an independent review. Include prior review findings in context when re-running reviews after new commits, and instruct Claude to report only new or still-unaddressed issues to avoid duplicate comments. Document your testing standards, valuable test criteria, and available fixtures in CLAUDE.md so CI-invoked Claude Code generates high-quality, non-redundant tests. ## The Truly Deep Claude Code FAQ ## Frequently Asked Questions ### What is Claude? Claude is an AI assistant made by Anthropic. You chat with it at claude.ai or in the Claude app. It can write, analyze, brainstorm, code, and explain things — all within a conversation window. Think of it as a very smart collaborator you talk to through text. ### What is Claude Code? Claude Code is a tool that runs in your terminal (the command-line interface on your computer). Unlike the chat version, Claude Code can see your actual files, edit your code, run commands, and manage git — all through natural language. You tell it what you want, it does the work, and you approve the changes. ### What The terminal (also called command line, shell, or console) is the text-based interface on your computer where you type commands instead of clicking buttons. On Mac, it ### What is CLAUDE.md? A markdown file you put in your project folder that Claude reads automatically at the start of every session. It contains your project ### What does In AI context, ### What is MCP? MCP stands for Model Context Protocol. It ### What are Connectors? Connectors are pre-built integrations that let Claude access your work tools — Gmail, Google Drive, Slack, Asana, Figma, Notion, and 50+ more. You set them up with a couple of clicks through OAuth (the ### What is the Filesystem connector? A specific MCP server that gives Claude direct access to files and folders on your computer. You specify which directories Claude can touch, and it can read, write, create, move, and search files within those directories. It asks permission before every action. ### What is Cowork? Cowork is a feature in Claude Desktop that gives you Claude Code ### What is Dispatch? A feature inside Cowork that lets you send tasks to Claude from your phone. Claude works on your desktop computer, and you come back to the finished result. Your phone is the remote control; your desktop does the processing. ### What is Computer Use? A research preview feature (March 2026) that lets Claude navigate your actual screen — clicking, typing, opening apps — when there isn ### What is Plan Mode? A mode in Claude Code where Claude explores your codebase and proposes a plan before making any changes. It ### What are Skills? Reusable prompts that show up as slash commands in Claude Code. You create a SKILL.md file with instructions, and Claude follows that playbook when you invoke the skill. Example: a `/deploy` skill that runs your test suite, builds, deploys, and verifies — triggered with one command. ### What are Hooks? Scripts that run automatically at specific points in Claude Code ### What does /compact do? It compresses your conversation history to free up context window space. Use it when your session has been going for a while and responses start feeling less precise or Claude starts ### What The total amount of text (measured in tokens) that Claude can ### What A unit of text that AI models process. Roughly, 1 token ≈ ¾ of a word in English. So 1,000 tokens ≈ 750 words. Tokens matter because they determine cost (on API) and how much context Claude can hold at once. ### What is git? A version control system that tracks changes to your files over time. Think of it as unlimited undo + a complete history of every change ever made. Developers use it to safely experiment (you can always revert) and collaborate (multiple people can work on the same codebase). Claude Code can manage git operations through natural language. ### What is CI/CD? Continuous Integration / Continuous Deployment. It ### What does -p mean in claude -p? The -p flag (or --print) runs Claude Code in non-interactive mode. It processes your prompt, outputs the result, and exits — no interactive input needed. Essential for automation and CI/CD pipelines where there ### What Three Claude models at different capability/speed tradeoffs. Opus 4.6 is the most powerful (deep reasoning, complex tasks). Sonnet 4.6 balances speed and intelligence (everyday work). Haiku 4.5 is the fastest and cheapest (simple tasks). Use Sonnet for 80% of your work, Opus for the hard 20%. ### Can I use Claude Code with local models or NVIDIA GPUs? Yes. While Claude Code defaults to Anthropic ### Do I need to be a developer to use any of this? For Claude chat and Connectors — no. For Cowork — no, it ### How much does it cost? Claude Pro at $20/month includes Claude chat, Connectors, Cowork, and Claude Code. Claude Max at $100-200/month adds higher usage limits. All connectors are free — you just need the paid Claude plan and a subscription to the tool you