Skip to content
GrowthVector.io

Claude Code Best Practices: Skills, Hooks, Subagents and Pricing

Claude Code best practices for building Bookly

Updated

Claude Code best practices come down to three habits: tell it what it cannot see, give it a check to run, and enforce the rules that cannot bend. This is Step 10 of 12 in the Vibe Coding guide, the first of three agent deep dives. You leave with a CLAUDE.md for Bookly, one skill, one hook, one read-only reviewer subagent, and a plan and cost check.

The three habits map to features with different levels of control. CLAUDE.md, skills and prompts are instructions that Claude weighs on each turn. Hooks, deny rules, the sandbox and managed settings run every time, whatever the model decides. This page covers how Claude Code applies those layers. The method behind them, from planning to security, is on the earlier pages.

The running example is Bookly, a booking app for a small hair salon. The CLAUDE.md, skill, hook and subagent shown here illustrate how Bookly would use Claude Code. They are not results from a real build.

Related guides: vibe coding legal, Claude Cowork deep dive, vibe coding workflow, vibe coding security.

Best Practices

Claude Code best practices: tell it what it cannot see, give it a check, enforce the rules that cannot bend

The three habits behind most of the official guidance

1. Tell it what it cannot see

Write only what Claude cannot find by reading the repo. Ask of each line: could Claude find this by reading the code, and would it go and look? If both answers are yes, cut the line.

2. Give it a check to run

Use a test, a build, a linter, or a screenshot next to the mockup. Ask for the command and its output, not for a claim that all tests pass.

3. Enforce the rules that cannot bend

A rule that must always hold goes in a hook or a deny rule. If you keep adding emphasis to a CLAUDE.md line and Claude still misses it, move the line to a hook.

LayerWho enforces itUse for
Prompts, CLAUDE.md, skillsClaude decides on each turnPreferences, conventions and how to work. Advice, not a guarantee
Hooks (command and http), deny rules, sandbox, managed settingsClaude Code enforces themRules that must hold every time, whatever the model decides
Habits the official guidance says you can stop
  • Aggressive context management. Current models have large windows and compact on their own.
  • Emphasis such as IMPORTANT or ALL CAPS. It makes Claude over-apply the rule.
  • Subagents "to protect context" or "for a better answer". They cost tokens and do not make answers smarter.
  • "Think hard" phrasing. Set the effort level instead.
  • "Keep going, don't be lazy" lines.
  • Architecture and file layout written into CLAUDE.md. Claude can read the repo.
Keep doing
  • Run /clear between unrelated tasks. A focused context is cheaper and gives better answers.
  • Correct a drift early. Press Esc when Claude goes off course.
  • After two failed corrections, run /clear and write a better prompt instead of a third correction.
  • Keep Claude's rules in one place: CLAUDE.md for advice, hooks and deny rules for limits.

Part 1: What It Is & Setup

~$13
Average cost per developer per active day
90%
Users under $30 per active day
$20
Pro plan per month
6
Permission modes

Cost figures are Anthropic's reported averages across enterprise deployments. Your own cost depends on the tasks you run.

Why Non-Coders Should Use Claude Code

Despite its name, Claude Code isn't just for programmers. It works directly with your filesystem, remembers preferences across sessions, and can help you automate repetitive workflows.

Three Places It Can Run

The same agent runs in three execution environments; pick one per task. Cloud sessions keep running after you close your laptop. They count against your plan limits and need a claude.ai login, not an API key. Remote Control steers a local session from a browser or phone.

EnvironmentWhere it runsUse for
Local (default)Your machineEveryday work in your own repo, with your files, tools and environment
CloudAnthropic-managed VMsLong tasks that keep running after you close your laptop. Start with claude --cloud, pull back with claude --teleport
Remote ControlYour machine, driven from a browser or phoneSteer a local session from another device. It is not a cloud run

Getting Started Tutorial

Install and configure Claude Code in under 5 minutes

1Install Claude Code

Open your terminal (Terminal on Mac, PowerShell on Windows) and paste the command for your OS. It installs in seconds; the native installer auto-updates itself. Homebrew and WinGet installs do not: update them with brew upgrade claude-code or winget upgrade Anthropic.ClaudeCode.

# Mac / Linux / WSL
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
# Homebrew (macOS)
brew install --cask claude-code
# WinGet (Windows)
winget install Anthropic.ClaudeCode

Homebrew has two casks: claude-code (stable, about a week behind) and claude-code@latest. On native Windows, Git for Windows is recommended. Packages are also available for apt, dnf and apk. A Windows CMD installer exists as well.

Also available as a VS Code extension (search "Claude Code" in the Extensions panel) and in JetBrains IDEs. The Claude Desktop app runs on macOS, Windows and a Linux beta, with the Code tab. The web version at claude.ai/code also runs in the Claude iOS and Android apps. Slack, Chrome, GitHub Actions, GitLab CI/CD and the Agent SDK complete the list.

2Log In

Type claude in your terminal and hit Enter. It will open a browser window to log in. That's it. Credentials are saved for future sessions.

Claude Pro / Max

Pro is $20 per month, or $17 per month billed annually. Max starts at $100 per month. Log in with your claude.ai account. The Free plan does not include Claude Code. Every paid plan defaults to Opus 5.5.

API Credits

Pay per token through the Claude Console at platform.claude.com. Track spending on platform.claude.com/usage. Good if you want granular cost control.

Teams / Enterprise

Team seats run from 2 to 150 seats, at $20 per seat per month billed annually or $25 billed monthly. Enterprise is US$20 per seat per month billed annually, with a 20-seat minimum. Cloud providers can also sign in: Amazon Bedrock, Claude Platform on AWS, Google Cloud's Agent Platform and Microsoft Foundry.

3Start Your First Session

Navigate to any project folder and type claude. You'll see a welcome screen. Just start typing what you want. Plain English works.

# Open your project and start Claude
cd ~/my-project
claude
# Then just talk to it:
what does this project do?
explain the folder structure
add input validation to the signup form

Claude reads your files automatically, so you don't need to copy-paste code. New terminal and VS Code sessions start in auto mode, where a classifier approves routine actions without asking. Press Shift+Tab to change the mode, or start with claude --permission-mode default to get a prompt before each edit.

4Commands You'll Use Daily

claude Start a session
claude -c Continue last conversation
claude -r Resume a past session
claude -p "..." Headless mode for scripts and CI
claude "fix the bug" One-shot task
/init Create a CLAUDE.md for your project
/help See all commands
Ctrl+C Exit

5Tips for Non-Developers

Be specific

Instead of "fix the bug," say "the login page shows a blank screen after entering a wrong password. Fix it."

Ask before building

Start with "what does this project do?" or "explain how authentication works" before asking for changes.

Break it down

Instead of "build me an app," try step-by-step: "1. create a form, 2. add validation, 3. connect to the database."

Use /init

Running /init creates a CLAUDE.md with project context. This saves you from re-explaining your project every session.

Part 2: Interface & Control

Essential Slash Commands

The commands you will use most, with what each one does.

CommandPurpose
/initCreate a CLAUDE.md for the project. CLAUDE_CODE_NEW_INIT=1 adds an interactive setup for skills, hooks and memory
/clear [name]Start a fresh context between unrelated tasks. A name labels the old session for /resume
/compact [focus]Summarize the conversation and keep the focus you name
/modelSwitch models. Use /model fable for the hardest, longest tasks
/effortSet effort: low, medium, high, xhigh, max, or auto. ultracode is a separate toggle
/goal [condition]Keep Claude working across turns until the condition is met
/mcpManage MCP connections
/contextView context window usage
/usageShow plan usage and what it went to. /cost is an alias
/memoryEdit CLAUDE.md files and turn auto memory on or off
/rewindRestore code, conversation or both to a checkpoint
/permissionsManage tool allowlist and URL domains

Keyboard Shortcuts

From the interactive-mode reference.

ShortcutAction
Shift+TabCycle permission modes: default, acceptEdits and plan, then any optional modes you enabled. Alt+M on Windows if Shift+Tab does not reach the terminal
Alt+PSwitch model without clearing the prompt
Alt+OToggle fast mode
EscInterrupt (preserves context)
Esc EscRewind menu (empty input) / clear draft (with text)
Ctrl+VPaste images directly (Alt+V on Windows/WSL)
Ctrl+GOpen the prompt or the plan in your editor
Ctrl+RSearch prompt history across all projects
\ + EnterMulti-line input. Shift+Enter also works in several terminals, including Windows Terminal
Ctrl+BMove the current task to the background
!commandRun shell command directly
TabAccept AI prompt suggestion

Use /memory to edit CLAUDE.md files and to turn auto memory on or off.

Permission Modes

Six modes control what Claude may do without asking. Shift+Tab cycles the first three and any optional modes you enable. Set dontAsk with --permission-mode or in settings. The Bash sandbox is a separate layer. Turn it on with /sandbox on macOS, Linux or WSL2. Deny rules hold in every mode.

ModeBehavior
ManualAsks before each edit and command. It was the old default; new terminal and VS Code sessions now start in Auto.
Accept editsAuto-accepts file edits and common filesystem commands; still asks for other terminal commands.
Plan modeRead-only. Claude explores and proposes a plan you approve before any edits.
AutoThe starting mode for new terminal and VS Code sessions since v2.1.283. A classifier model reviews each action first. Pauses after 3 blocks in a row or 20 in total.
dontAskAllows only pre-approved tools and refuses the rest. Meant for locked-down CI and scripts. Set with --permission-mode dontAsk.
Bypass permissionsSkips nearly all prompts (--dangerously-skip-permissions). Deny rules still block. Use only in a container or VM without internet access.
Allowlisting
  • Allowlist: Use /permissions to always allow specific tools (e.g., Edit, Bash).
  • Bypass mode: --dangerously-skip-permissions skips nearly all prompts. Use it only in a container or VM without internet access.
Example rules (.claude/settings.json)
{ "permissions": { "allow": ["Edit", "Bash(npx tsc --noEmit)"], "ask": ["Bash(git push *)"], "deny": ["Read(./.env)"] } }

A deny rule holds in every mode, including auto and bypass. A Read deny rule catches cat .env but not a script that opens the file, so pair deny rules with /sandbox for security rules. Trusted infrastructure goes in autoMode.environment and autoMode.allow in ~/.claude/settings.json. Or run /permissions and add rules in its interface.

Effort Levels

Effort is the main control for cost and quality. Set it with /effort, --effort or CLAUDE_CODE_EFFORT_LEVEL

EffortUse for
lowQuick brainstorming and simple questions
mediumDefault on Opus 5.5, Sonnet 5.5 and Haiku 5.5
highBugs in code you did not write, flaky tests, schema changes
xhighThe same cases as high, when high is not enough. Writing ultrathink in one prompt runs that turn at this level
maxHard problems you leave running unattended. It tends to overthink ordinary tasks
"think hard" is ordinary prompt text, not a control. Alt+T does nothing on Opus 5.5, Sonnet 5.5, Haiku 5.5 or Fable, which always think
Do not set max for everything. It tends to overthink ordinary tasks and costs more time and tokens

Custom Commands and Skills

Commands and skills are one mechanism. Each one creates a slash command you can run

# .claude/skills/fix-issue/SKILL.md
---
description: Fix a GitHub issue end to end
disable-model-invocation: true
---
Analyze and fix GitHub issue: $ARGUMENTS
1. Use `gh issue view` to get details
2. Search codebase for relevant files
3. Implement changes
4. Write and run tests
5. Create PR
# Usage: /fix-issue 1234

The older .claude/commands/fix-issue.md path still works and creates the same command. Skills from a plugin are namespaced, for example /plugin-name:skill.

Course Correction Tools

Redirect Claude mid-task without losing context

Ask for a plan

Tell Claude to plan before coding, and confirm the plan before implementation starts.

Escape

Interrupt Claude during any phase. Context is preserved for redirection.

Escape Escape

On an empty prompt, opens the rewind menu to restore code, conversation or both. Files changed only by a Bash command are not restored.

/btw

Ask a side question without adding it to the conversation history.

Ask to undo

Have Claude undo changes and take a different approach.

Claude Code tips: shortcuts and commands that save the most time

Features in the terminal that save the most time each day

FeatureShortcutDescription
CheckpointingEsc Esc or /rewindRestores code, conversation or both. Covers files Claude edits with its own tools, not files changed only by a Bash command.
Side question/btwAsks a quick question without adding it to the conversation history.
Named sessions/rename, then claude --resume <name>Name a multi-day task, then resume it by that name.
Prompt suggestionsAuto-appearsNext-step suggestions based on context. Press Tab to accept.
Prompt history searchCtrl + RSearch prompts across all project conversations. Press Ctrl+R again to cycle results.
Editor promptCtrl + GWrite a long prompt, or edit a plan, in your editor.
Model switchAlt + PChange the model without clearing the prompt.
Fewer prompts/fewer-permission-promptsBuilds a permission allowlist from your past transcripts.
Config check/doctor prompt-audit/doctor suggests cuts to CLAUDE.md. prompt-audit flags stale or contradictory instructions.
File mention@pathMention a file to add it to the prompt.

Data Input Methods

Four ways to get data into Claude for processing

Copy & Paste

How: Directly into prompt (most common)

Use for: Quick data snippets, error messages, short text

Pipe into Claude

How: cat foo.txt | claude or cat logs.txt | claude -p "Analyze errors"

Use for: Logs, CSVs, large data files that would be tedious to paste

Tell Claude to Pull Data

How: Ask Claude to use bash commands, MCP tools, or custom slash commands

Use for: Data from APIs, databases, or external services Claude can access

File Paths & URLs

How: Mention file paths or paste URLs for Claude to read directly

Use for: Images, PDFs, documentation pages, design mocks

Part 3: Inner Workings

CLAUDE.md Configuration Files

Claude Code's memory, automatically loaded at session start.

File Hierarchy
LocationScopePurpose
Managed policy CLAUDE.mdOrganizationSet by an admin for everyone. On Windows: C:\Program Files\ClaudeCode\CLAUDE.md
~/.claude/CLAUDE.mdGlobalYour rules for every project on this machine
./CLAUDE.md or ./.claude/CLAUDE.mdProjectShared with the team through git
./CLAUDE.local.mdLocalGitignored. Your personal notes for this project
.claude/rules/*.mdPath-scopedLoads only when Claude works on files that match its paths: filter
Subdirectory CLAUDE.mdOn-demandLoads when Claude works on files in that folder
Imports, AGENTS.md and auto memory
  • Imports: @path/to/file pulls a file into context. It does not reduce what the file costs.
  • AGENTS.md: with no CLAUDE.md, Claude Code reads AGENTS.md. With both, it reads CLAUDE.md only, unless CLAUDE.md imports AGENTS.md with @AGENTS.md.
  • Auto memory: Claude writes its own notes to a MEMORY.md index on your machine. The first 200 lines or 25KB of that index load each session. Turn it off with /memory or CLAUDE_CODE_DISABLE_AUTO_MEMORY=1.
Best Practices
Target under 200 lines per CLAUDE.md file. /doctor suggests cuts
Write plain, direct rules. Emphasis such as IMPORTANT makes Claude over-apply the rule
Run /init to generate, /memory to edit, and /doctor prompt-audit to find stale or contradictory lines
Write only what Claude cannot find by reading the repo. Architecture and file layout are left out
Example: Bookly CLAUDE.md (illustrative)
# Bookly: booking app for a hair salon (illustrative) ## Commands - Install: npm install - Typecheck: npx tsc --noEmit - Run one test file: npm test -- tests/bookings.test.ts ## Rules - Money is stored in whole cents. Never use floats for deposits or refunds. - Refunds go through the cancel flow in src/lib/bookings.ts. Never call the payment API from a component. - Applied migrations in db/migrations/ are read-only. Add a new file for each schema change. - One slot holds one booking. The database enforces it with a unique constraint on staff and start time. ## Gotchas - Clients see only their own bookings. Check the client ID on every query, not only in the UI.

Each line passes the test above: Claude cannot get it from the code alone. The migration rule matters for Bookly because a change to an applied migration breaks every environment that already ran it. The hook below enforces that rule.

Context Engineering

Managing the context window for maximum performance

Token management

Every request re-sends the whole conversation, so a long session costs more on each turn.

Run /clear between unrelated tasks. Use /compact with a focus for a long session you keep.

Context window

Models with a native 1M-token window compact automatically at about 967K tokens by default.

Do not manage context at a fixed percentage. Keep /clear for cost and focus.

Prompt cache

The cache lasts about 1 hour on a subscription and 5 minutes on an API key. A session over about 200K tokens that sits idle is compacted before the cache expires.

After a long break, expect the first reply to re-read the whole context at full price.

Pro Workflow

Recommended loop for complex features

1. Explore

Ask questions first. Use the Explore subagent to map the code before you change it.

Sonnet 5.5 or Haiku 5.5

2. Plan

Enter plan mode with Shift+Tab or /plan when the first direction is costly to redo. Ctrl+G edits the plan in your editor.

Opus 5.5

3. Execute

Implement in small steps, and give each step a check to run.

Sonnet 5.5

4. Review

Run /code-review, which reviews in a fresh subagent, or hand the diff to a read-only reviewer subagent.

Fresh context

Claude Code subagents: built-ins, custom agents, cost and when they help

Built-in and custom subagents, how they are configured, and what they cost

AgentRoleToolsDescription
ExploreRead-only searchWrite and Edit deniedFinds and reads code fast. Runs on the main conversation's model. Skips CLAUDE.md and the git status snapshot.
PlanResearch in plan modeWrite and Edit deniedReads the codebase before you approve a plan. Skips CLAUDE.md and the git status snapshot.
General-purposeTask executorDefault tool setHandles multi-step work. A subagent starts with a fresh context window and does not see your conversation. Only a fork carries it.
Custom subagentYour specialistSet in its frontmatterA Markdown file in .claude/agents/ (project) or ~/.claude/agents/ (personal). The name and description fields are required.
Agent toolSpawns subagentsBuilt inReplaces the older Task tool. Built-ins: Explore, Plan, general-purpose, claude, statusline-setup (Sonnet) and claude-code-guide (Haiku).
  • Model order: the model set per call, then the model in the agent file, then CLAUDE_CODE_SUBAGENT_MODEL, then the main model.
  • Nesting goes three layers deep. Up to 20 subagents can run at once by default.
  • Subagents cost tokens too. By default they use the same model or a smaller one, so they give parallel work or a fresh review, not a smarter answer.
  • A reviewer that cannot edit: set tools to Read, Grep and Glob. Tell it to report only gaps that affect correctness and to skip style, or it always finds something.
  • Dynamic workflows (/workflows, or /effort ultracode) have Claude write a script that runs many subagents in the background and returns one result. By default up to 16 run at once and 1,000 per run. On Pro, turn the feature on in /config.
  • Agent teams are experimental and off by default. Set CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 to try them. They suit research, review and parallel modules, and they are a poor fit for edits to the same file.
--- name: reviewer description: Reviews a diff for gaps that affect correctness tools: Read, Grep, Glob --- Report only gaps that affect correctness. Skip style.

The reviewer above is a file at .claude/agents/reviewer.md. Its tool list, not a request in the prompt, keeps it from editing.

Claude Code skills: SKILL.md, frontmatter and when a skill beats CLAUDE.md

A skill's body loads only when the skill runs. Its description stays in context on every request

Skills live in .claude/skills/<name>/SKILL.md for the project, in ~/.claude/skills/<name>/SKILL.md for you, or inside a plugin. Skills follow the Agent Skills open standard.

Each skill's description and when_to_use text is cut at 1,536 characters in the listing. Keep SKILL.md under 500 lines.

Frontmatter fieldWhat it does
descriptionWhat the skill does and when to use it. Always in context
disable-model-invocationSet to true for skills with side effects, such as deploy or send. The description leaves context
user-invocableWhether you can run the skill directly as a slash command
allowed-toolsTools the skill may use without asking
context: forkRuns the skill in a forked subagent with its own context
pathsLimits when the skill is offered, by file path
Bookly skill (illustrative)
# .claude/skills/new-migration/SKILL.md --- description: Add a new Bookly migration. Never edit an applied one disable-model-invocation: true --- 1. Read the newest file in db/migrations/ to get the next number. 2. Create one new file with one schema change. Do not touch existing files. 3. Run npx tsc --noEmit. 4. Report the file name and what it changes.

Set disable-model-invocation: true on any skill with side effects, such as a release that bumps a version and pushes a tag. You then run it yourself with /new-migration.

Which tool fits the job
When this happensUse
Claude gets a convention wrong twiceAdd it to CLAUDE.md
You paste the same procedure a third timeMake a skill
You copy data from a tool Claude cannot seeAdd an MCP server
A side task floods your conversationUse a subagent
Something must happen every timeWrite a hook
A second repo needs the same setupMake a plugin

Skills & Plugins

Plugins install skills, agents, hooks and MCP servers as one unit

How skills work

A skill is a folder with a SKILL.md file. Its description stays in context on every request. Its body loads only when the skill runs.

Keep SKILL.md under 500 lines so each load stays small

How plugins package them

A plugin bundles skills, agents, hooks and MCP servers into one unit that you install with /plugin. Plugins run code with your user privileges, so review one before you install it.

Every enabled plugin's descriptions sit in context, so disable the ones you do not use

Popular Plugin Example: frontend-design

It is in Anthropic's official plugin marketplace as a frontend design skill for UI and UX implementation.

Claude Code hooks: events, exit codes and three recipes you can paste

A hook runs a command at a fixed point in the session. Command and http hooks are deterministic

EventWhen it runsExample
PreToolUseBefore a tool call runsBlock a path or a command. Exit code 2 stops the call and sends stderr to Claude
PostToolUseAfter a tool call finishesRun a formatter after every Edit or Write
StopWhen Claude finishes a turnExit code 2 keeps Claude working. Claude Code overrides a Stop hook after 8 blocks in a row
UserPromptSubmitWhen you submit a prompt, before Claude reads itAdd context or check the prompt format
SessionStartWhen a session startsLoad setup that every session needs
PreCompactBefore compactionKeep notes that the summary must not lose
SubagentStopWhen a subagent finishesCheck the subagent's result before the main session uses it

Claude Code has 33 hook events. The table shows the main ones.

Exit codes
  • Exit code 2 blocks the action and sends stderr to Claude. On PreToolUse it blocks the tool call. On Stop it keeps Claude working.
  • Exit code 1 is a non-blocking error. A policy hook must exit 2, or set onFailure: "block" (v2.1.295 and later).
  • PostToolUse runs after the tool. Exit code 2 there cannot undo the edit. It only shows stderr to Claude.
Handler types and matchers
  • Five handler types: command, http, mcp_tool, prompt and agent. Only command and http hooks are deterministic. Prompt and agent hooks ask a model.
  • Matchers made of letters, digits, underscores and | match exactly. Any other text is a JavaScript regex, and matchers are not anchored: Edit.* also matches NotebookEdit.
  • Settings live in ~/.claude/settings.json, .claude/settings.json (shared), .claude/settings.local.json, managed policy, a plugin's hooks/hooks.json, or a skill or subagent's frontmatter.
Bookly hook: block edits to applied migrations
#!/usr/bin/env bash # .claude/hooks/block-applied-migrations.sh (needs jq on the PATH) path=$(jq -r '.tool_input.file_path // empty' | tr '\\' '/') if [[ "$path" == */db/migrations/* && -e "$path" ]]; then echo "Bookly rule: applied migrations are read-only. Add a new migration file instead." >&2 exit 2 fi exit 0

Claude Code sends the tool input as JSON on stdin. The script needs jq on the PATH. On Windows the file path arrives with backslashes, so the script converts them first. A new migration file passes. An edit to an existing one exits with code 2.

Settings file with the Bookly hook and two recipes
{ "hooks": { "PreToolUse": [ { "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "bash .claude/hooks/block-applied-migrations.sh" } ] } ], "PostToolUse": [ { "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "jq -r '.tool_input.file_path' | xargs npx prettier --write" } ] } ], "Stop": [ { "hooks": [ { "type": "command", "command": "npx tsc --noEmit 1>&2 || exit 2" } ] } ] } }

The PreToolUse entry runs the Bookly script. The PostToolUse entry runs Prettier after each edit. The Stop entry runs the typecheck and keeps Claude working until it passes. Claude Code overrides a Stop hook after 8 blocks in a row with no tool call between them. In a real project, move the command into a script that exits 0 when stop_hook_active is true, as Step 5 shows, so a check the agent cannot fix does not loop.

Rule of thumb: a rule that must always hold goes in a hook. Advice goes in CLAUDE.md. A hook that enforces a mere preference is a hook to delete.

MCP (Model Context Protocol) Servers

Connect Claude Code to data it cannot read on its own, such as a database or a hosted API

ScopeStored inUse for
Local (default)~/.claude.jsonYour own server setup on this machine
Project.mcp.json in the repoShared with the team through git
User~/.claude.jsonPersonal servers you want outside any one repo
Add a server
claude mcp add --transport http <name> <url>

Use the HTTP transport. The SSE transport is deprecated.

Keep the context small
  • Tool search is on by default. Idle MCP tools add only their names and server instructions to context.
  • Disable servers you do not use. Prefer a CLI where one exists, such as gh, aws or gcloud.
  • A tool result past 10,000 tokens triggers a warning. Output is capped at 25,000 tokens by default. MAX_MCP_OUTPUT_TOKENS changes the cap.

Headless Mode & Automation

Run Claude non-interactively for CI/CD and scripts (claude -p "prompt")

Issue Triage

Run on GitHub Actions to auto-label new issues or summarize bug reports.

Subjective Linter

"Review this PR for tone, variable naming clarity, and missing comments."

Fan-out Migration

Generate a list of 100 files, then script claude -p to migrate each one in parallel.

Pipelining

cat logs.txt | claude -p "Find errors" --output-format json | process_errors.py

claude --bare -p "Fix the next failing test in the list, then stop" \ --allowedTools "Read,Edit,Bash(git add *),Bash(git commit *)" \ --permission-mode dontAsk --max-turns 20

--bare skips hooks, skills, plugins, MCP servers and CLAUDE.md, so every machine runs the same way. --max-turns and --max-budget-usd cap the run, and --output-format json returns structured output. Try the script on three files before you run it on the full list.

Bypass only in a container: the docs say to use --dangerously-skip-permissions only in a container, VM or dev container without internet access. See the reference devcontainer.

Multi-Claude Workflows

Scale your intelligence by running parallel instances

Reviewer Pattern

1. Claude A writes code.
2. /code-review, or a read-only reviewer subagent, reviews it in a fresh context.
3. Claude A fixes what the review found.
(A fresh context avoids tunnel vision. The review loop is on Step 4.)

Git Worktrees

claude -w feature-auth starts a session in a new worktree. .worktreeinclude copies gitignored files such as .env into each worktree. Two sessions that edit the same file still conflict. /batch with an instruction splits a mechanical change into 5 to 30 units, runs each in its own worktree, and opens a pull request per unit. When parallel agents are worth it is on Step 4.

Plan with Opus, build with Sonnet

The opusplan alias uses Opus in plan mode and Sonnet while it executes. Use opusplan[1m] for the 1M window in both.

Hidden Power User Features

Commands, environment variables and files that change how Claude Code behaves.

CLI Shortcuts
  • !command - Run a shell command directly from the Claude Code prompt
  • /clear - Start a fresh context between unrelated tasks
  • /compact - Condense the conversation to reduce token usage
  • /usage - Show plan usage and what it went to. /cost is an alias
  • /help - Show available slash commands and usage info
Environment Variables
  • ANTHROPIC_MODEL - Override the default model for a session
  • CLAUDE_CODE_EFFORT_LEVEL - Set the effort level
  • CLAUDE_CODE_SUBAGENT_MODEL - Set the model that subagents use
  • CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 - Turn off automatic memory
  • CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING=1 - Turn off file checkpointing (/rewind then restores conversation only)
Hidden Files
  • .claude/settings.json - Project settings: permissions, hooks, env vars
  • .mcp.json in project root - Shared MCP server config, committed for the whole team

Part 4: Workflows, Marketing & ROI

Claude Code workflow: one Bookly feature from plan to pull request

Booking a slot in Bookly, step by step. Each step gives Claude a check or a stop condition

1. Scope it in plan mode

Describe the book-a-slot feature for Bookly. Ask Claude to read the booking code and propose a plan. Approve the plan before any edit.

2. Write the failing test first

Ask for the no double booking test. Run it and confirm it fails for the right reason. The test method is on the TDD page.

3. Build on a branch

Create a branch for the task, then let Claude implement in small steps. Branch and commit habits are on the workflow page.

4. Set a completion condition

Use /goal with a condition that a command proves, such as the test suite passing. Add a Stop hook that runs the typecheck.

5. Review in a fresh context

Run /code-review, or hand the diff to a read-only reviewer subagent. Fix what it finds.

6. Open the pull request

Ask for the pull request with the test output and the open risks in the description.

Before you leave a run unattended
  • Does it know what done looks like?
  • Can it check its own work?
  • What may it touch?
  • What stops it: --max-turns, --max-budget-usd or a spend limit?
  • Where does the result go, and who signs off?
Where the method lives

Planning and the PRD are on the planning page. Git, branches and rollback are on the workflow page. Test-first prompts are on the TDD page. Secrets and row-level security are on the security page.

Core Development Loops

Patterns for agentic coding, from exploring the code to committing the change

AExplore, Plan, Code, Commit

Versatile workflow for most features. Prevents "jumping to code" too early. The plan comes from the PRD on Step 3.

1. Explore: "Read file X and explain how it handles Y." (Don't code yet).
2. Plan: "Think about how to implement Z." Use plan mode (Shift+Tab) when the first direction is costly to redo.
3. Code: "Implement the plan." (Verify step-by-step).
4. Commit: "Commit and create PR."

BTDD Loop (Test-Driven)

Claude works best with a clear failing target. The full method is on the TDD page.

1. Red: "Write a test for X. Confirm it fails."
2. Green: "Write code to pass the test. Do not modify the test."
3. Refactor: "Clean up the implementation."

Codebase Q&A (Onboarding)

Treat Claude as a pair programmer who knows the whole repo.

  • "How does the logging system work?"
  • "Where is the API endpoint for user creation?"
  • "Why are we using `useEffect` here?"
  • "What changes made it into v1.2.3?" (Git history search)

Git and GitHub Integration

Claude can handle routine git operations. Install the gh CLI for GitHub access. Branch, commit and rollback habits are on the workflow page.

Smart Commit"Commit these changes" (Generates context-aware message)
History Search"Who changed this file last week and why?"
Create PRs"Create a PR" (understands "pr" shorthand)
Fix Review Comments"Fix the comments on my PR and push"
Fix Failing Builds"Fix the failing CI checks"
Watch a PR/autofix-pr watches the PR for CI failures and review comments
Triage Issues"Loop over open issues and categorize by priority"

Workflow Optimization Tips

Visual Feedback

"Implement this design." → Copy/Paste screenshot of result → "Fix padding."
(Use a browser tool or a manual screenshot. /verify builds and runs the app, then checks the result)

Checklists

For migrations: "1. List all errors in file. 2. Fix one by one. 3. Verify each."

Specific Instructions

Bad: "Fix it."
Good: "Look at `foo.py` history to understand why the API is weird, then fix the type error."

Prompt Specificity Examples

Specific instructions dramatically improve first-attempt success

Poor PromptBetter Prompt
add tests for foo.pyWrite a new test case for foo.py covering the edge case where the user is logged out. Avoid mocks.
why does ExecutionFactory have such a weird api?Look through ExecutionFactory's git history and summarize how its API came to be.
add a calendar widgetLook at how existing widgets are implemented on the home page to understand patterns. HotDogWidget.php is a good example. Then implement a calendar widget with month selection and year pagination.

Use Cases Beyond Code

Know before you script: these task categories are also what Claude Cowork (page 11 of this guide) is built for. Cowork uses the same agentic approach as Claude Code, for non-coding knowledge work. Keep the work here when you want scripts, git history and hooks around it. Choose Cowork when you or a teammate only need the finished deliverable.

File Management & Organization

Tame digital chaos by renaming, sorting, and organizing files with natural language commands.

  • Rename invoices to YYYY-MM-DD Vendor - Invoice - Product.pdf format
  • Organize 5 years of project folders with searchable indexes
  • Transform messy Obsidian vaults into structured knowledge bases
  • Sort photos by EXIF date into year/month folders

Writing & Content Creation

Native skills for creating Word docs, PowerPoints, Excel spreadsheets, and PDFs.

  • End-to-end content creation from idea to publication
  • Technical writing with Hugo integration
  • Presentation slides with multi-AI feedback via MCP
  • Documentation management with CLAUDE.md context

Research & Information Synthesis

Custom slash commands unlock powerful research workflows across platforms.

  • /youtube @channel for full channel analysis
  • Competitor analysis with pricing page summaries
  • Literature reviews and hypothesis generation
  • YouTube transcript analysis with note-taking MCPs

Personal Assistant & Automation

Transform Claude Code into a persistent personal assistant that maintains context.

  • Daily briefings with personalized priority summaries
  • Automated journaling with /daily-journal command
  • Weekly dashboards monitoring personal and career metrics
  • Disk space cleanup, screenshot enhancement, raffle picking

Jupyter Notebooks & Data Science

Read and write Jupyter notebooks with Claude interpreting outputs including images.

  • Open .ipynb file side-by-side with Claude Code in VS Code
  • Explore and interact with data through notebook cells
  • Clean up notebooks before sharing with colleagues
  • Make data visualizations aesthetically pleasing

Business & Productivity Workflows

SEO & Content Strategy

Export your Search Console and GA4 reports to CSV, then ask Claude Code which pages convert and which topics need a new content pillar.

Lead Generation

"Look at what I'm building and identify the top 5 companies in my area that would be good for a pilot."

Meeting Analysis

Download recordings, ask Claude to identify patterns like "all the times I subtly avoided conflict."

Product Management

Keep each PRD as a Markdown file in the repo, then ask Claude Code to split it into tasks. The PRD method is on the planning page.

Claude Code pricing: Pro, Max, Team, Enterprise and API compared

Plan prices, billing periods and limits, as Anthropic publishes them.

PlanPriceLimitsNotes
Pro$20 per month, or $17 per month billed annually5-hour limit and a weekly limit, shared with Claude chatClaude Code is included. Fable is available only through usage credits
Max 5xFrom $100 per month5x the Pro usage, with a separate weekly limit for FableFable at 50% of weekly limits. Includes $100 of monthly API credits
Max 20x$200 per month20x the Pro usageIncludes $200 of monthly API credits
Team Standard$20 per seat per month billed annually, or $25 billed monthly2 to 150 seats; usage from a per-seat allowanceFable not included on Standard seats
Team Premium$100 per seat per month billed annually, or $125 billed monthly5x the Standard usageFable included at 50% of weekly limits
EnterpriseUS$20 per seat per month billed annually20-seat minimum, plus usage at API ratesUsage is billed on top of the seat fee
APIPay per tokenRate limits set per organizationPrompt cache lasts 5 minutes, not 1 hour
What the limits mean
  • Anthropic publishes relative limits, such as 5x and 20x Pro usage. It does not publish message counts per window.
  • Pro and Max can turn on usage credits to keep working past a limit. Use /usage-credits to set them up.
  • On May 6, 2026, Anthropic doubled the five-hour limits for Pro, Max, Team and seat-based Enterprise, and removed the peak-hours reduction for Pro and Max. Weekly limits were not part of that change.
Average cost and cost controls
  • Anthropic reports about $13 per developer per active day, and $150 to $250 per developer per month across enterprise deployments.
  • Check /usage, use /clear between tasks, set effort per task, and give simple subagents a smaller model with model: haiku.
  • The prompt cache lasts about 1 hour on a subscription and 5 minutes on an API key. The first message after a break re-reads the whole context.
  • An agent team uses about 7x more tokens than a standard session when its teammates run in plan mode.
  • API organizations get per-user rate-limit starting points. 1 to 5 users: 200k to 300k tokens per minute and 5 to 7 requests per minute. 50 to 100 users: 25k to 35k tokens per minute and 0.62 to 0.87 requests per minute. 500 or more users: 10k to 15k tokens per minute and 0.25 to 0.35 requests per minute.

Cost Optimization Strategies

API prices per million tokens, and how to match the model to the task

ModelBest ForAPI price per million tokens
Fable 5.1 (fable)Hardest, longest tasks. Never the default; pick it with /model fable$10 input / $50 output
Opus 5.5 (opus)Planning, architecture, final review. Default on every plan$4 input / $20 output
Sonnet 5.5 (sonnet)Routine implementation and standard tasks$2 input / $10 output
Haiku 5.5 (haiku)Quick status checks, data parsing, simple subagent jobs$0.10 / $0.50 up to 100K prompt tokens; $0.50 / $2.50 above

Input and output prices are listed separately. Batch processing saves 50%. US-only inference costs 1.1x. Opus 5.5 fast mode costs 2x. Switch models with /model, and check spending with /usage (alias /cost). The opusplan alias plans with Opus and executes with Sonnet.

Common Mistakes to Avoid

Kitchen-sink session
Put unrelated tasks in one session. Run /clear between them
Correcting the same thing three times
After two failed corrections, run /clear and write a better prompt
Must-hold rules kept only in CLAUDE.md
Move them to a hook or a deny rule that Claude Code enforces
No check for the result
Give Claude a test or a command to run, and ask for its output
Verbose CLAUDE.md
Target under 200 lines per file. Cut every line Claude can find by reading the repo
One model for every task
Use /model and effort levels to match cost to the task

Measure your own return

Measure your own tasks. Outside figures, including vendor case studies, will not match your work

Time per task

Time one real task before you start using Claude Code, then time the same kind of task after. Use the same scope each time.

Cost per task

Run /usage at the end of a task. It shows the share taken by skills, subagents, plugins and MCP servers.

Rework

Count how many corrections a task needed. Repeated corrections are a sign to /clear and write a better prompt.

Checks passed

Count the tasks that passed your test or build check on the first run, and note which prompts got them there.

PPC Workflow Automation

A two-subagent pattern for ad copy: one subagent for headlines, one for descriptions

Key insight: Use two specialized subagents, one for headlines and one for descriptions, rather than one prompt for both. Each subagent gets one task and one output format, so its result is easier to check.

RSA Generation Prompt Pattern

Create a sub-agent for generating Google Ads headlines. Requirements: - Input: CSV with [ad_id, headline, impressions, clicks, ctr] - Filter for ads below your CTR threshold that have enough impressions to judge - Generate headline variations for each underperforming ad - STRICT: Respect the headline length limit in your ad account - Output: CSV with [original_ad_id, new_headline, character_count]

SEO Automation Workflows

Bulk Meta Generation

Process a URL list in batches. Draft a title and a description for each page with its primary keyword, within the length limits your platform applies.

Schema Markup at Scale

Generate JSON-LD FAQ and Product schema ready for HTML insertion. Validate the output before you publish it.

Keyword Cannibalization

Cluster by semantic similarity, identify cannibalization, recommend primary URLs.

Internal Linking Plans

Analyze content, identify linking opportunities, suggest anchor text variations.

Shopify Integration

Export the products to CSV or JSON. Then run one orchestrator and three specialist subagents:

  • 1.Orchestrator Agent manages workflow
  • 2.Product Description Agent (Sonnet) for SEO
  • 3.Meta Fields Agent for structured data
  • 4.SEO Fields Agent optimizes descriptions

Klaviyo Automation

Export the campaign data from Klaviyo to CSV, then ask Claude Code to:

  • Analyze 30-day campaign performance
  • Identify top-performing subject lines
  • Draft subject line variations (urgency, curiosity, personalization)
  • Generate SMS variants that fit the SMS length limit you set

Scheduled Automation Patterns

# Daily SEO health check at 9 AM 0 9 * * * cd /path/to/project && claude -p "Run daily SEO health check" # Weekly content audit on Mondays 0 8 * * 1 cd /path/to/project && claude -p "Generate weekly content report" # Hourly campaign budget monitoring 0 * * * * cd /path/to/project && claude -p "Check budgets, alert on anomalies"

Add --bare, --permission-mode dontAsk and --max-turns to each line, as in the headless example above. For a schedule that must run while your laptop is closed, use /schedule cloud tasks. They need a claude.ai login.

Content Production Workflows

End-to-end automation for high-volume content generation

Ad Copy Variants

Generate headline and description variants for underperforming responsive search ads

Process: Export the ad performance CSV, generate variants for each underperforming ad, filter them by the character limits in your account, then export the list for upload
Output: a CSV of variants with character counts, for your review before upload

Blog Content Briefs with SEO

Turn a keyword into a content brief with a structure to follow

Process: Enter the target keyword, add the search intent notes from your SEO tool, analyze the top 10 ranking pages, generate an H2 and H3 outline with word counts per section
Output: a brief the writer can follow, saved as a Markdown file in the repo

Product Description Generation

Write product copy that follows one brand voice

Process: Export product attributes to CSV or JSON, generate descriptions and meta fields per product, check the output against your brand rules, then import the file
Output: a reviewed import file. Nothing changes on the live store until you import it

Video Ad Script Generation

Write video ad scripts with a hook, body and call to action

Process: Analyze the structure of the top-performing ad scripts you supply, generate variants with different angles, and add timestamps to each part
Output: script variants ready for a creative review

Essential Resources

Official Documentation
GitHub Repository

Next step: Claude Cowork

Next, read the Claude Cowork deep dive. It applies the same agentic approach to non-coding knowledge work, so you can decide which tasks belong in Cowork and which stay in Claude Code.

Common Questions

Is Claude Code free?

No. Claude Code needs a paid Claude plan or an Anthropic Console account billed at API rates; the free Claude plan does not include it. Pro costs $20 a month, or $17 a month billed annually, with a 5-hour limit and a weekly limit shared with chat. Pro and Max can turn on usage credits to keep working past a limit.

How much is Claude Code?

Pro is $20 a month ($200 a year billed annually), and Max starts at $100 a month for 5x or 20x the Pro usage. Team Standard seats are $25 a month or $20 billed annually, and Premium seats are $125 or $100. On the API, Anthropic puts the average at about $13 per developer per active day, or $150 to $250 a month.

How do I install Claude Code on Windows?

Open PowerShell and run irm https://claude.ai/install.ps1 | iex, or install it with winget install Anthropic.ClaudeCode. Anthropic recommends Git for Windows on native Windows. The native installer updates itself; WinGet installs do not, so update those with winget upgrade Anthropic.ClaudeCode. Then run claude in your project folder and sign in with your plan.

How do I update Claude Code?

The native installer updates Claude Code automatically. You can also run claude update to update now. Homebrew and WinGet installs do not auto-update: run brew upgrade claude-code on a Mac or winget upgrade Anthropic.ClaudeCode on Windows. The Homebrew claude-code cask is the stable channel and runs about a week behind claude-code@latest.

How do I use Claude Code in VS Code?

Install the Claude Code extension from the VS Code marketplace; it also works in Cursor. It uses the same Claude plan, CLAUDE.md file and settings as the terminal version, and new VS Code sessions start in auto mode. You can also run claude in VS Code's integrated terminal if you prefer the command line.

Claude Code hooks vs CLAUDE.md: when do I need a hook?

CLAUDE.md is advice. Claude reads it and decides on each turn whether it applies, so a rule that must always hold does not belong there alone. Put 'never read .env', 'always run the formatter' and 'never edit applied migrations' in a deny rule or a hook, because Claude Code enforces those whatever the model decides. If you keep adding emphasis to a CLAUDE.md line and Claude still misses it, move the line to a hook.