The Complete Reference

Claude Code Guide

A practical, copy-paste reference for everything in Claude Code — setup, commands, hooks, skills, subagents, agent teams, plugins, MCP, the Agent SDK, and the workflows that actually work. Verified against the official Anthropic docs. Built for developers who want to ship, not read tutorials.

By Hasan Aboul Hasan Updated May 2026 Claude Code v2.1.x 30+ copy-paste configs
Last verified: May 24, 2026 against the official Anthropic Claude Code docs.

Getting Started

Up and running in under 60 seconds.

Claude Code is an agentic coding tool that lives in your terminal. It can edit files, run commands, search your codebase, and interact with git — all through natural language.

Install on macOS, Linux, or WSL

Terminal
curl -fsSL https://claude.ai/install.sh | bash

Install on Windows

PowerShell
irm https://claude.ai/install.ps1 | iex
CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
WinGet
winget install Anthropic.ClaudeCode

Install ↗ Git for Windows so Claude Code can use the Bash tool. Without it, Claude Code falls back to PowerShell.

Install via Homebrew (macOS / Linux)

Stable / latest
# Stable channel (~1 week behind, skips bad releases)
brew install --cask claude-code

# Latest channel
brew install --cask claude-code@latest

First launch

Open any project directory and run claude. You'll be prompted to log in on first use. Switch accounts later with /login.

Terminal
cd your-project
claude
💡 Tip
You can skip all permission prompts with --dangerously-skip-permissions, but a better option is Auto mode — an AI classifier decides what's safe. Cycle to it with Shift + Tab. Or pass --permission-mode auto at launch.

Run Claude Code in VS Code

You can also run Claude Code directly inside VS Code, JetBrains IDEs, and Cursor. Install the Claude Code extension from the VS Code marketplace, and it will appear as an integrated panel in your editor. Same machinery, just rendered inside the IDE.

Claude Code running in VS Code

Other useful launch flags

CommandWhat it does
claude "task"Run a one-time task and stay in the session
claude -p "query"One-off headless query, exit when done
claude -cContinue the most recent conversation in the current directory
claude -rResume any previous conversation interactively
claude agentsOpen Agent View (background sessions panel, research preview)
claude agents --jsonList live sessions as JSON for scripts and status bars

Keyboard Shortcuts

The shortcuts worth memorizing.

Shift + EnterNew line without sending
Shift + TabCycle permission modes (default / plan / auto / acceptEdits)
Ctrl + CCancel current operation
Ctrl + DExit the session
EscCancel current input / interrupt a turn
Esc + EscRewind / summarize conversation
Ctrl + LClear prompt input + force full redraw
Ctrl + RSearch command history
Ctrl + TToggle task list
Ctrl + GOpen external editor
Ctrl + BBackground current task
Shift + ↓Cycle through Agent Team teammates (when teams enabled)
?Show shortcuts for the current environment
Step back through command history
💡 Tip
Type / at the start of an empty prompt to see every command and skill available in your setup, including custom, plugin, and MCP-provided ones. Press ? any time for the shortcut cheat sheet on your platform.

Permissions

Control exactly what Claude Code can and can't do.

Claude Code uses a tiered permission system: read-only tools (file reads, grep) need no approval, bash commands require approval per project, and file modifications require approval per session. Rules are evaluated in order: deny → ask → allow. Deny always wins.

Where to configure

Permissions live in settings.json at two levels:

Project-level .claude/settings.json Checked into git. Shared with your team.
Global (user-level) ~/.claude/settings.json Applies to all your projects.
💡 Tip
Project settings override user settings. If a tool is denied at the project level, no user-level rule can allow it.

Permission Modes

Set defaultMode in your settings to change how Claude asks for approval:

Mode Behavior
defaultStandard behavior — prompts on first use of each tool
acceptEditsAuto-accepts file edits and common filesystem commands (mkdir, touch, mv, cp) inside the working directory
planRead-only — Claude can analyze with reads + read-only shell commands but cannot edit source files
autoAuto-approves tool calls with background safety checks. Research preview
dontAskNew. Auto-denies tools unless pre-approved via /permissions or permissions.allow
bypassPermissionsSkips all prompts. Root and home directory removals (rm -rf /, rm -rf ~) still prompt as a circuit breaker. Use only in containers/VMs

Example 1: Minimal — auto-approve reads only

Good starting point. Claude can read your code freely but still asks before running commands or editing files.

.claude/settings.json (project)
{
  "permissions": {
    "allow": [
      "Read",
      "Grep",
      "Glob"
    ]
  }
}

Example 2: Solo developer — trust most tools

For personal projects where you want minimal interruption. Put this in your global settings.

~/.claude/settings.json (global)
{
  "permissions": {
    "allow": [
      "Bash(npm *)",
      "Bash(git *)",
      "Read",
      "Edit",
      "Grep",
      "Glob",
      "WebFetch",
      "WebSearch",
      "mcp__*"
    ]
  }
}

Example 3: Team project — allow builds, block danger

Allow common dev commands but explicitly block destructive ones. Great for shared repos.

.claude/settings.json (project)
{
  "permissions": {
    "allow": [
      "Bash(npm run *)",
      "Bash(git commit *)",
      "Read",
      "Grep",
      "Glob"
    ],
    "deny": [
      "Bash(git push *)",
      "Bash(rm -rf *)"
    ]
  }
}
⚡ Pro tip
Try Auto mode instead of manually listing every tool. An AI classifier decides what's safe based on your request. Start with --permission-mode auto or cycle to it with Shift + Tab.

Commands

Every built-in command and when to reach for it.

Command What it does When to use it
/initInitialize project with a CLAUDE.md guideFirst time in a project
/compactCompact conversation with optional focus instructionsContext usage exceeds 80%
/clearWipe context, start freshSwitching tasks
/diffInteractive diff viewer for uncommitted changesBefore committing
/modelSwitch between Opus / Sonnet / HaikuMatch model to task complexity
/effortSet effort level (low/medium/high/xhigh/max)Balance speed vs. thoroughness
/planEnter plan mode — read-only exploration before codingStarting a complex task
/resumePick up a previous sessionReturning to unfinished work
/branchBranch the conversation at this point"What if" experiments
/rewindRewind conversation and/or code to a previous pointUndo Claude's changes
/memoryManage auto-saved context and CLAUDE.mdPersist info between sessions
/contextVisualize current context usage as a gridCheck how much context is used
/costShow token usage statisticsCheck spending
/usageNew. Per-category breakdown (skills, subagents, plugins, per-MCP-server)Find what's driving your usage limits
/goalNew (v2.1.139+). Set a completion condition; Claude works autonomously until met. /goal clear stopsLong-running autonomous work
/pluginOpen the plugin manager (Discover / Browse / Manage)Installing or managing plugins
/agentsPanel with a Running tab (live subagents) and Library tab (definitions)Managing subagents in the current session
/tasksList background items in the current sessionTracking work running in the background
/backgroundDetach the whole session to keep running as a background agentFree your terminal while a long task runs
/mcpView and manage MCP server connectionsAdding or troubleshooting MCP servers
/configOpen settings (theme, model, preferences)Customizing Claude Code
/permissionsView and manage permission rulesReviewing what's allowed
/doctorDiagnose installation and settingsSomething isn't working
/btwQuick side question without polluting contextNeed a fast answer mid-task
/exportExport conversation as plain textSave or share a session
/loginSwitch accounts or re-authenticateMultiple Anthropic accounts
💡 Tip
Not all commands are visible in every environment. Some depend on your platform, plan, or Claude Code version. Type / in your session to see which commands are available to you.

Bundled Skills

These ship with Claude Code — no installation needed. Bundled skills are prompt-based: they give Claude detailed instructions and let it orchestrate the work using its tools. Invoke them with / followed by the skill name.

/code-reviewStructured code review of changes
/batchParallel work across worktrees
/debugStructured debugging workflow
/loopRepeat prompt on an interval (or self-paced)
/claude-apiAPI-focused work — auto-loads on anthropic SDK import
/runv2.1.145+. Launch and drive your app
/verifyv2.1.145+. Build + run to confirm a change works
/run-skill-generatorv2.1.145+. Record the launch recipe
💡 Tip
/init, /review, and /security-review are built-in commands that are also accessible through the Skill tool — so they look like skills but aren't bundled skills proper.

Custom Commands

Create your own slash commands with plain markdown files.

Custom commands are markdown files that become slash commands. Save them as skills (recommended) or in the legacy commands folder:

Project-level .claude/skills/name/SKILL.md Shared with your team via git.
Global (personal) ~/.claude/skills/name/SKILL.md Available in all your projects.
💡 Tip
Custom commands have been merged into skills. Files in .claude/commands/ still work, but .claude/skills/ is now the recommended path. Skills add optional features like YAML frontmatter, auto-triggering, and bundled scripts.

Use $ARGUMENTS in your skill to accept input when invoked.

.claude/skills/review/SKILL.md
Review the changes on the current branch compared to main.

Focus on:
1. Logic errors and edge cases
2. Security issues
3. Performance concerns
4. Missing error handling

Reference file names and line numbers.
Show the diff summary first.
.claude/skills/test/SKILL.md
Write tests for $ARGUMENTS

Cover:
- Happy path
- Empty / null input
- Error cases
- Edge cases

Use the existing test framework. Run tests after writing them.
.claude/skills/refactor/SKILL.md
Refactor $ARGUMENTS to be cleaner and more maintainable.

Rules:
- Keep the same behavior (no feature changes)
- Improve naming and readability
- Extract repeated logic into functions
- Add type hints if missing
- Run tests after to confirm nothing broke

Hooks

Automated actions that run at specific points in Claude Code's lifecycle.

Hooks are shell commands, HTTP calls, or LLM prompts that execute automatically at specific lifecycle points. Add them to .claude/settings.json (project) or ~/.claude/settings.json (global). Hook commands receive JSON on stdin with tool details.

PreToolUse
Runs before a tool. Can block dangerous commands (exit code 2 = block).
PostToolUse
Runs after a tool succeeds. Use for auto-formatting and linting.
Notification
Fires when Claude needs input or finishes. Use for desktop alerts.
💡 Tip
Claude Code has 29 hook events as of May 2026: SessionStart, Setup, UserPromptSubmit, UserPromptExpansion, PreToolUse, PermissionRequest, PermissionDenied, PostToolUse, PostToolUseFailure, PostToolBatch, Notification, SubagentStart, SubagentStop, TaskCreated, TaskCompleted, Stop, StopFailure, TeammateIdle, InstructionsLoaded, ConfigChange, CwdChanged, FileChanged, WorktreeCreate, WorktreeRemove, PreCompact, PostCompact, Elicitation, ElicitationResult, SessionEnd. The examples below cover the most common ones. See the ↗ full hooks reference for every event and its exit-code-2 behavior.

Auto-format Python files after every edit

.claude/settings.json
{
  "hooks": {
    "PostToolUse": [{
      "matcher": "Write|Edit",
      "hooks": [{
        "type": "command",
        "command": "jq -r '.tool_input.file_path' | xargs black 2>/dev/null; exit 0"
      }]
    }]
  }
}

Auto-format JavaScript/TypeScript with Prettier

.claude/settings.json
{
  "hooks": {
    "PostToolUse": [{
      "matcher": "Write|Edit",
      "hooks": [{
        "type": "command",
        "command": "jq -r '.tool_input.file_path' | xargs npx prettier --write 2>/dev/null; exit 0"
      }]
    }]
  }
}

Block dangerous commands

.claude/settings.json
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "Bash",
      "hooks": [{
        "type": "command",
        "command": "jq -r '.tool_input.command' | grep -qE 'rm -rf|git push.*--force|git reset --hard' && echo 'Blocked: dangerous command' >&2 && exit 2 || exit 0"
      }]
    }]
  }
}

Protect sensitive files from edits

.claude/settings.json
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "Write|Edit",
      "hooks": [{
        "type": "command",
        "command": "jq -r '.tool_input.file_path' | grep -qE '\\.env|secrets/|\\.git/' && echo 'Blocked: protected file' >&2 && exit 2 || exit 0"
      }]
    }]
  }
}

Desktop notification when Claude needs input

macOS
{
  "hooks": {
    "Notification": [{
      "matcher": "",
      "hooks": [{
        "type": "command",
        "command": "osascript -e 'display notification \"Claude Code needs input\" with title \"Claude Code\" sound name \"Ping\"'"
      }]
    }]
  }
}
Windows (PowerShell)
{
  "hooks": {
    "Notification": [{
      "matcher": "",
      "hooks": [{
        "type": "command",
        "command": "powershell -Command \"Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('Claude Code needs your attention','Claude Code')\""
      }]
    }]
  }
}
⚡ Pro tip
Five hook handler types are available: "command" (shell), "http" (webhook), "mcp_tool" (invoke an MCP tool), "prompt" (single-turn LLM eval), and "agent" (spawns a subagent). For blocking hooks, exit code 2 blocks the action and shows stderr as feedback to Claude. The exact effect depends on the event: PreToolUse blocks the tool call, UserPromptSubmit rejects the prompt, PreCompact blocks compaction.

Subagents

Delegate side tasks to isolated workers so your main context stays clean.

A subagent is a specialized AI assistant that runs in its own context window, does the work, and returns only the summary to your main session. The verbose output — file searches, log dumps, multi-step reasoning — stays isolated. Use one when a side task would flood your main conversation with stuff you won't reference again.

Subagents help you:

  • Preserve context by keeping exploration and implementation out of your main conversation
  • Enforce constraints by limiting which tools a subagent can use
  • Reuse configurations across projects with user-level subagents at ~/.claude/agents/
  • Specialize behavior with focused system prompts for specific domains
  • Control costs by routing tasks to faster, cheaper models like Haiku

Define a subagent

Subagents live in .claude/agents/<name>.md (project) or ~/.claude/agents/<name>.md (personal). The frontmatter description tells Claude when to delegate to it.

.claude/agents/research.md
---
description: Research a topic across the codebase. Use when the user asks "where is X used", "what depends on Y", or for any read-only exploration that would flood the main context.
tools: Read Glob Grep
---

You are a focused codebase researcher. Your job is to investigate the user's question
across the project and return a concise summary with file paths and line numbers.

Process:
1. Find relevant files with Glob and Grep first
2. Read the files in depth
3. Return a structured summary: findings, file references, open questions

Don't edit anything. Don't run shell commands. Stay read-only.

Invoke and manage subagents

Open the subagent panel with /agents. The Running tab shows live subagents. The Library tab lets you create and edit definitions. Claude can also auto-delegate to a subagent when the description matches your request.

⚡ Pro tip
Route subagents to a cheaper model with the CLAUDE_CODE_SUBAGENT_MODEL env var. Keep Opus for your main reasoning, send the grunt work to Haiku.
export CLAUDE_CODE_SUBAGENT_MODEL="claude-haiku-4-5"

Skills + Subagents

A skill can run in a subagent by adding context: fork to its frontmatter. The skill content becomes the subagent's prompt, with the agent type controlling tools and model.

.claude/skills/deep-research/SKILL.md
---
name: deep-research
description: Research a topic thoroughly across the codebase
context: fork
agent: Explore
---

Research $ARGUMENTS thoroughly:

1. Find relevant files using Glob and Grep
2. Read and analyze the code
3. Summarize findings with specific file references

Agent Teams

Multiple coordinated Claude Code sessions that talk to each other.

⚠ Experimental
Agent Teams are experimental and disabled by default. Requires Claude Code v2.1.32+. Enable with CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 in your settings or environment.

While subagents are isolated workers that report back to the main agent, Agent Teams are multiple full Claude Code sessions that coordinate as peers. One session is the lead. The others are teammates that share a task list and message each other directly — no central dispatcher.

Subagents vs Agent Teams

 SubagentsAgent Teams
ContextOwn context; results return to callerOwn context; fully independent
CommunicationUp to the main agent onlyTeammates message each other directly
CoordinationMain agent manages all workShared task list with self-coordination
Best forFocused tasks where only the result mattersComplex work that needs discussion and collaboration
Token costLower (results summarized back)Higher (each teammate is a full session)

Enable Agent Teams

~/.claude/settings.json
{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
  }
}

Start a team

After enabling, just describe the team you want in natural language. Claude creates the team, spawns the teammates, and coordinates.

In your Claude Code session
Create an agent team to review PR #142. Spawn three reviewers:
- One focused on security implications
- One checking performance impact
- One validating test coverage
Have them each review and report findings.

Behind the scenes Claude generates ~/.claude/teams/<team-name>/config.json and a shared task list at ~/.claude/tasks/<team-name>/. Don't edit these by hand — the runtime overwrites them.

Display modes

In-process (default)
All teammates run inside your main terminal. Use Shift + ↓ to cycle through teammates and message them directly. Works in any terminal.
Split panes
Each teammate gets its own pane. Click into a pane to interact directly. Requires tmux or iTerm2 with the it2 CLI.

Best practices

  • 3–5 teammates is the sweet spot. Beyond that, coordination cost eats the parallel-work gain.
  • Avoid file conflicts. Two teammates editing the same file overwrites each other. Partition the work so each teammate owns a different set of files.
  • Require plan approval for risky tasks: "Spawn an architect teammate to refactor auth. Require plan approval before any changes." The teammate stays in read-only plan mode until the lead approves.
  • Use hooks to enforce quality gates: TeammateIdle, TaskCreated, TaskCompleted. Exit with code 2 to send feedback and keep the teammate working.
  • Clean up with the lead when finished: "Clean up the team". Teammates shouldn't run cleanup — only the lead.
⚠ Known limitations
/resume and /rewind don't restore in-process teammates. Task status can lag. One team per lead at a time. No nested teams. Split-pane mode doesn't work in VS Code's integrated terminal, Windows Terminal, or Ghostty.

CLAUDE.md

The context file that tells Claude how your project works.

Claude reads CLAUDE.md at the start of every session. It's where you put your project's architecture, coding standards, build commands, and any rules you want Claude to follow.

For existing projects, run /init — Claude analyzes your codebase and generates a CLAUDE.md with the conventions it discovers. Then refine it with anything Claude wouldn't know on its own. For new projects, use the template below as a starting point.

Where to place it

Project-level ./CLAUDE.md or ./.claude/CLAUDE.md Shared with your team via git.
Personal (all projects) ~/.claude/CLAUDE.md Your preferences across every project.

Template

Use this as a starting guide — customize it for your project:

CLAUDE.md
# Project: [Name]

## Tech Stack
- [Framework], [Language + version]
- [Database], [Key libraries]

## Commands
- Dev: [command]
- Build: [command]
- Test: [command]
- Lint: [command]

## Architecture
- [Where services live]
- [Where routes/views live]
- [Where models/types live]
- [Where tests live]

## Code Style
- [Rule 1 — be specific]
- [Rule 2]
- [Rule 3]

## Rules
- ALWAYS run tests after changes
- ALWAYS use TypeScript strict mode
- NEVER commit directly to main
- Keep files under 300 lines — split if larger
💡 Tip
Keep CLAUDE.md under 200 lines. For larger projects, split instructions into .claude/rules/ files — you can scope rules to specific file types using paths frontmatter. You can also import other files with @path/to/file syntax.

Skills

Advanced auto-triggering commands with bundled resources.

Skills are the next level beyond custom commands. They live at .claude/skills/your-skill-name/SKILL.md and support auto-triggering, bundled scripts, and subagent control.

Commands
  • Plain markdown file
  • Manual /slash invocation
  • No bundled files
  • Simple — start here
Skills
  • YAML frontmatter + markdown
  • Auto-triggered by AI
  • Bundled scripts, references, assets
  • Advanced — upgrade when needed

Popular Skills

Remotion
Generate motion graphics and videos with code. Auto-activates when Remotion code is detected. 117k+ installs.
Frontend Design
Official Anthropic skill. Gives Claude a design system and philosophy before it touches any code. 277k+ installs.
Superpowers
Full dev workflow: brainstorming, TDD, code review, git worktree automation. 40k+ GitHub stars.
Claude API
Bundled skill. Auto-loads API reference when your code imports the Anthropic SDK.

Find More Skills

The skill ecosystem is growing fast. Browse community directories:

↗ awesome-claude-skills Curated GitHub list
↗ AgentSkills.io Open standard directory
↗ SkillsMP.com Skills marketplace

Create Your Own Skill

Create a directory in .claude/skills/your-skill-name/ with a SKILL.md file. Add YAML frontmatter for name and description — Claude uses the description to decide when to auto-load it.

.claude/skills/explain-code/SKILL.md
---
name: explain-code
description: Explains code with diagrams and analogies. Use when the user asks "how does this work?"
---

When explaining code, always include:

1. **Start with an analogy** — compare the code to something from everyday life
2. **Draw a diagram** — use ASCII art to show the flow or structure
3. **Walk through the code** — explain step-by-step what happens
4. **Highlight a gotcha** — what's a common mistake or misconception?

Keep explanations conversational.
💡 Tip
You can also bundle scripts, templates, and reference files alongside your SKILL.md. Add disable-model-invocation: true in the frontmatter to make a skill manual-only (e.g. for deploy workflows you don't want Claude auto-triggering).

Workflows

The mental models that separate productive Claude Code users from everyone else.

The Three Pillars

01

Modular Structure

Every feature in its own file. Check at 300 lines — if a file is longer, it needs splitting.

02

One Task Per Session

Plan → Code → Test → Commit → /clear → Next. Fresh sessions are cheap. Polluted sessions cost quality.

03

Know Your Building Blocks

Before prompting: What APIs do I need? What data flows where? What does the output look like? This is the approach we teach in ↗ Solo Builder Course — understand the building blocks before you prompt.

The Development Cycle

01
Plan
Define what to build
02
Code
Let Claude implement
03
Test
Verify it works
04
Commit
Save your progress
05
/clear
Fresh session, next task
⚡ Pro tip
Commit after every working change. Fresh sessions are cheap — polluted sessions cost you in quality and token spend.

Power Prompts

Battle-tested prompts for common situations. Copy them directly.

Force Proper Planning
When: Starting any significant task
Before writing any code, analyze the existing codebase structure and create a detailed plan. List every file you'll create or modify, and explain why. Wait for my approval before implementing.
The Elegant Redo
When: When the first attempt feels hacky
Knowing everything you know now, scrap this and implement the elegant solution.
Root Cause Debugging
When: When you get an error
This error is happening: [paste error]
Don't just fix the symptom. Find the root cause, explain it, then fix it properly. Run tests after.
Parallel Subagents
When: 3+ independent tasks
Use parallel subagents for these independent tasks:
1. [Task A]
2. [Task B]
3. [Task C]
Work on all three at the same time. Combine results when done.
New Project Scaffold
When: Starting from scratch
Create a modular project structure for [description].
Each feature gets its own file in a logical folder structure.
No file should be longer than 300 lines.
Include type hints and error handling from the start.
Find Large Files
When: Refactoring or improving code quality
Scan the entire project for files larger than 600 lines of code. List them sorted by size, and suggest how each could be split into smaller, focused modules.
Clarify Before Building
When: After any prompt — append this to stay aligned
Before you start, ask me questions to make sure you understand exactly what I want.
⚡ Pro tip
Add "ask me questions first" to the end of any complex prompt. It forces Claude to clarify requirements before jumping into code — saving you from back-and-forth corrections later.

Plugins, Marketplaces & MCP

Three layers of extensibility, in order of how often you'll touch them.

Plugins

A plugin bundles skills, hooks, subagents, MCP servers, and LSP servers into a single installable package. Instead of every teammate manually setting up the same skills + hooks, a plugin is a one-click install.

Run /plugin inside Claude Code to open the plugin manager. The Discover and Browse screens now show each plugin's commands, agents, skills, hooks, and MCP/LSP servers before installation — you see exactly what you're getting.

Inside Claude Code
# Browse the manager UI
/plugin

# Install from the Anthropic-managed marketplace
/plugin install frontend-design@claude-plugins-official
/plugin install github@claude-plugins-official
/plugin install sentry@claude-plugins-official
/plugin install typescript-lsp@claude-plugins-official

Plugin Marketplaces

A marketplace is a marketplace.json file hosted on GitHub (or any git host) that lists multiple plugins from one source. Add the marketplace once; install any of its plugins thereafter.

Add and install
# Add a community marketplace
/plugin marketplace add owner/repo

# Install a specific plugin from it
/plugin install name@marketplace

# CLI equivalent (without a session)
claude plugin install plugin-name

The default trusted source is ↗ anthropics/claude-plugins-official. For your own marketplace, publish a marketplace.json in a git repo — that's the whole setup.

MCP Servers

MCP (Model Context Protocol) servers give Claude Code access to systems it doesn't already understand: GitHub, your database, your browser, your production tooling. Add them with claude mcp add.

Recommended day-one MCP servers

ServerWhat it doesWhen to add
GitHubPRs, issues, code search, branches across reposSingle highest-impact install for most developers
PlaywrightBrowser automation — Claude can see your UIBuilding or testing web apps
Postgres / MySQL / MongoDBRead schemas, run queries against your DBAnything beyond a toy app
Fetch / Brave SearchLive web groundingCross-stack work, doc lookups
Linear / NotionPull tickets, write docs from your sessionIf your team lives in Linear or Notion
SimplerLLMAI library docs and code examplesWhen writing Python LLM apps
⚠ Sweet spot: 3–6 servers
Past about 10 visible MCP tools, Claude's tool selection accuracy starts to degrade — it picks the wrong one or misses the right one. Add what you'll actually use, prune what you don't.
Local (stdio) servers
# Browser automation — Claude can see your UI
claude mcp add --transport stdio playwright -- npx @playwright/mcp@latest

# GitHub — PRs, issues, code search across repos
claude mcp add --transport stdio github -- npx @anthropic/mcp-github@latest

# Postgres — read schemas, run queries
claude mcp add --transport stdio postgres -- npx @modelcontextprotocol/server-postgres@latest postgresql://user:pass@host/db
Remote servers (SSE / HTTP)
# SimplerLLM — AI library docs and code examples
claude mcp add --transport sse simplerllm https://learnwithhasan.com/simplerllm/mcp/server/sse/

# Notion — connect to your workspace
claude mcp add --transport http notion https://mcp.notion.com/mcp

Learn more about the ↗ SimplerLLM MCP server for AI library documentation access. Use /mcp any time to view connection status.

Model Selection

Match the model to the task. Use CC Switch for non-Anthropic models.

Claude Code defaults to Anthropic models (Opus and Sonnet). Use /model to switch between them. For non-Anthropic models, ↗ CC Switch lets you route to 50+ models from providers like DeepSeek, MiniMax, OpenRouter, and more.

CC Switch — route Claude Code to multiple model providers
Model Best for Cost
Claude Opus 4.7Complex architecture, planning, long-running goals$$$
Claude Sonnet 4.6Everyday coding, the default for most sessions$$
Claude Haiku 4.5Fast grunt work, subagents, evaluator hooks$
MiniMax M2.7Strong coding, much cheaper via OpenRouter$
DeepSeek V3Budget tasks via OpenRouter / direct API¢
⚡ Pro tip — Fast Mode
Toggle Fast Mode with /fast to use Claude Opus with faster output. Defaults to Opus 4.7. To pin Fast Mode to Opus 4.6 instead, set CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE=1.
⚡ Pro tip — Subagent model routing
Run your main session on Opus for reasoning, route subagents to Haiku for cost:
export CLAUDE_CODE_SUBAGENT_MODEL="claude-haiku-4-5"

Claude Agent SDK

Build Claude into your own apps — same machinery as Claude Code, as a library.

The Claude Agent SDK gives you the same tool-using agent loop that powers Claude Code, but as a Python or TypeScript library you import into your own application. Hand Claude an objective, and it autonomously reads files, runs commands, edits code, and iterates — all from inside your app.

The TypeScript SDK bundles a native Claude Code binary as an optional dependency, so you don't need to install Claude Code separately.

Install

Python
pip
pip install claude-agent-sdk
export ANTHROPIC_API_KEY=sk-ant-...
TypeScript
npm
npm install @anthropic-ai/claude-agent-sdk
export ANTHROPIC_API_KEY=sk-ant-...

Your first agent in 8 lines

Python
import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions

async def main():
    async for message in query(
        prompt="Find and fix the bug in auth.py",
        options=ClaudeAgentOptions(allowed_tools=["Read", "Edit", "Bash"]),
    ):
        print(message)

asyncio.run(main())
TypeScript
import { query } from "@anthropic-ai/claude-agent-sdk";

for await (const message of query({
  prompt: "Find and fix the bug in auth.ts",
  options: { allowedTools: ["Read", "Edit", "Bash"] }
})) {
  console.log(message);
}

Built-in tools (no implementation needed)

ToolWhat it does
ReadRead any file in the working directory
WriteCreate new files
EditPrecise edits to existing files
BashTerminal commands, scripts, git operations
MonitorWatch a background script and react to each output line as an event
GlobFind files by pattern (**/*.ts, src/**/*.py)
GrepSearch file contents with regex
WebSearchSearch the web for current information
WebFetchFetch and parse web page content
AskUserQuestionMulti-choice clarifying questions back to the user

Build it into a desktop app

The Agent SDK is built for being embedded. You spin up an async for message in query(...) loop inside your app's event handler, stream tokens to your UI, and respond to AskUserQuestion events with a native picker.

Real example: VidTSX. VidTSX is my desktop app for AI motion graphics. Inside it, Claude drives the whole production pipeline — script generation, scene layout, prompt-to-video render orchestration — using the Agent SDK. The same agent that fixes bugs in Claude Code is the one that writes a Remotion composition and schedules a render job. One binary, two surfaces.

See how VidTSX uses Claude under the hood ↗

What else you get

Hooks
Same lifecycle events as Claude Code (PreToolUse, PostToolUse, Stop, SessionStart, UserPromptSubmit, …) exposed as Python/TS callbacks. Validate, log, block, transform.
Subagents
Define specialized agents (AgentDefinition in Python) and have your main agent delegate via the Agent tool. Each subagent has its own context window.
MCP
Same MCP server ecosystem, just configured in SDK options (mcp_servers={...}) instead of via claude mcp add.
Permissions
Pre-approve safe tools with allowed_tools=[...], block dangerous ones via permission rules. Interactive approval flow via AskUserQuestion.
Sessions
Capture session_id from the init message; resume with resume=session_id. Fork sessions to explore alternative paths from any point.
Config inheritance
By default the SDK loads .claude/ from your CWD and ~/.claude/ (skills, slash commands, CLAUDE.md). Set setting_sources to restrict.

Compare to other Claude tools

 Agent SDKClaude Code CLIAnthropic Client SDKManaged Agents
Runs inYour processYour terminalYour processAnthropic-managed
Tool loopBuilt inBuilt inYou implementManaged
Best forCustom apps, CI/CD, desktop integrationsInteractive dev, one-off tasksDirect API control, custom logicHosted production agents, async work
⚠ Heads up — June 15, 2026 credit change
Starting June 15, 2026, Agent SDK usage (and headless claude -p usage) on subscription plans draws from a separate monthly Agent SDK credit, distinct from your interactive Claude Code limits. If you're shipping production agents, plan for that line item. ↗ Anthropic support article.
💡 Branding for builders shipping their own products
When you ship an app built on the Agent SDK, Anthropic's branding rules:
  • ✓ "Claude Agent" or "Claude" (preferred in dropdowns)
  • ✓ "{YourAgent} Powered by Claude"
  • ✗ "Claude Code" or "Claude Code Agent" (reserved for Anthropic's own product)

Full docs: ↗ Agent SDK overview · ↗ Quickstart · ↗ Example agents repo

Use Claude Code for Free

Route Claude Code to a free OpenRouter model — per project, no global config conflicts.

You can run Claude Code at $0 cost by pointing it at a free model on ↗ OpenRouter. We do this at the project level so it never touches your global Claude configuration — no conflicts, no broken main setup, just a sandboxed override for the one project you want free.

Step 1 — Create the project-level config. Inside the project where you want to use Claude Code for free, create a .claude folder, and inside it create a file named settings.local.json.

.claude/settings.local.json file in the project root

Step 2 — Get a free OpenRouter API key. Sign up at ↗ openrouter.ai, create an API key, then browse the models page and copy the slug of any model tagged free (for example minimax/minimax-m2.5:free).

Step 3 — Paste this into .claude/settings.local.json (replace the key and model slug with your own):

.claude/settings.local.json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "XXX",
    "ANTHROPIC_BASE_URL": "https://openrouter.ai/api",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "minimax/minimax-m2.5:free",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "minimax/minimax-m2.5:free",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "minimax/minimax-m2.5:free"
  }
}

Step 4 — Launch Claude Code in that project. Open a terminal in the project folder and run claude. Then run the /model command — you should see the free OpenRouter model listed as the active model. Say hi to confirm it answers.

Claude Code /model command showing the free OpenRouter model active

Step 5 — Verify $0 cost. Head to your OpenRouter usage logs — you'll see your requests landing at $0. Enjoy.

⚠ Important
Because you're now running on a smaller free model — not Claude Opus or Sonnet — the model is much less forgiving of vague prompts and messy context. To get good results, you have to understand how to code with AI the right way: knowing the building blocks, structuring context properly, and breaking work into the right shapes for the model. That's exactly what I teach inside ↗ the Solo Builder Course.

FAQ

Quick answers to common questions.

Claude Code requires a Claude Pro ($20/mo), Max ($100–$200/mo), Team, or Enterprise plan, or Anthropic Console credits. You can also run it effectively for free by routing requests to a free model on OpenRouter via project-level environment variables — covered in the Use Claude Code for Free section.
Custom commands and skills have merged. A file at .claude/commands/deploy.md and a skill at .claude/skills/deploy/SKILL.md both create /deploy and work the same way. Skills add optional features: a directory for supporting files, YAML frontmatter to control invocation, and the ability for Claude to load them automatically when relevant.
Claude Code auto-compacts when approaching context limits, summarizing conversation history to free space. You can run /compact manually with focus instructions, or /clear to start fresh. Use /context to visualize current usage as a grid. Best practice: one task per session, commit in between.
No. Claude navigates your codebase on-demand using tools like Read, Grep, and Glob. It reads files as needed rather than pre-indexing everything. This works with any project size.
VS Code, Cursor (and other VS Code forks), IntelliJ, PyCharm (and other JetBrains IDEs), Slack integration, and any terminal. It also runs as a standalone CLI and is available on the web at claude.ai/code.
Yes. Use CC Switch or set the ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN environment variables to route Claude Code to OpenRouter, DeepSeek, MiniMax, or any provider that speaks the Anthropic Messages API shape.
Skills are reusable instructions stored at .claude/skills/<name>/SKILL.md. A skill is a markdown file with YAML frontmatter; Claude loads it automatically when the description matches your request, or you invoke it directly with /skill-name. Skills can bundle supporting scripts and reference files that load only when needed. See the Skills section for templates.
On Windows PowerShell, run irm https://claude.ai/install.ps1 | iex. On CMD, run curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd. Or via WinGet: winget install Anthropic.ClaudeCode. Install Git for Windows so Claude Code can use the Bash tool; without it, Claude Code falls back to PowerShell.
Subagents run inside one session and return a summary to the main agent — one-way communication. Agent Teams are multiple coordinated Claude Code instances with their own context windows that share a task list and message each other directly. Subagents are best for focused side-tasks; Agent Teams are for complex work requiring collaboration. Agent Teams are experimental and require Claude Code v2.1.32+ and CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1.
A plugin bundles skills, hooks, subagents, MCP servers, and LSP servers into one installable package. Define a marketplace.json file (hosted on GitHub or any git host) that lists your plugins. Users then run /plugin marketplace add owner/repo, followed by /plugin install your-plugin@your-marketplace. Anthropic also maintains an official marketplace at anthropics/claude-plugins-official.
Three to six MCP servers is the sweet spot. Start with GitHub MCP (PRs, issues, code search), Playwright MCP (browser automation), and a database MCP that matches your stack (Postgres, MySQL, or MongoDB). Beyond ten servers, Claude's tool selection accuracy starts to degrade.
The Claude Agent SDK is a Python and TypeScript library that gives you the same tool-using agent loop that powers Claude Code, but embeddable in your own app. Install with pip install claude-agent-sdk or npm install @anthropic-ai/claude-agent-sdk. Same built-in tools (Read, Write, Edit, Bash, Monitor, Glob, Grep, WebSearch, WebFetch, AskUserQuestion), hooks, subagents, MCP, permissions, sessions. Starting June 15, 2026, Agent SDK usage on subscription plans draws from a separate monthly Agent SDK credit. See the Agent SDK section.
By Hasan Aboul Hasan · LearnWithHasan.com · 2026