← All guides

Claude Code Complete Guide: Installation, Commands, and Advanced Workflows

Complete reference for Claude Code: installation, CLI commands, CLAUDE.md, slash commands, MCP servers, worktrees, hooks, and production workflows.

🇰🇷 한국어로 보기 →

Claude Code Complete Guide: Installation, Commands, and Advanced Workflows

Claude Code is Anthropic's agentic coding tool — a CLI that runs Claude models with direct filesystem and terminal access. It reads your codebase, writes and edits files, runs commands, and works in multi-step loops until a task is complete. This guide covers everything from first install to advanced production workflows.

Free download: 30 production-tested Claude Code prompts

Skip the trial-and-error. Copy-paste-ready prompts for debugging, refactoring, testing, architecture, documentation, and security.

Get the free cheatsheet →


Quick Start

# Install
npm install -g @anthropic-ai/claude-code

# Authenticate
claude auth login

# Start in your project
cd your-project
claude "explain what this codebase does"

Requires Node.js 18+. Authentication uses your Anthropic API key (set ANTHROPIC_API_KEY environment variable) or interactive login.


What Claude Code Can Do


Installation and Setup

# Global install (recommended)
npm install -g @anthropic-ai/claude-code

# Or with specific version
npm install -g @anthropic-ai/claude-code@latest

# Verify
claude --version

Authentication

# Interactive login (browser-based)
claude auth login

# Or set API key directly
export ANTHROPIC_API_KEY="sk-ant-..."

# Verify authentication
claude "hello"

Project Configuration

Create CLAUDE.md in your project root for project-specific context:

# MyProject

## Stack
- Next.js 15, TypeScript strict
- Prisma + PostgreSQL
- Package manager: bun

## Rules
- No `any` type
- Run `bun run typecheck` after code changes
- Commit messages: conventional commits

Claude reads CLAUDE.md automatically at the start of each session. → Deep dive: Context Engineering for Claude


CLI Commands Reference

Basic Usage

# Start interactive session
claude

# One-shot task (non-interactive)
claude "add error handling to src/api/users.ts"

# With file context
claude "@src/components/Button.tsx refactor to use Tailwind"

# With multiple files
claude "@src/lib/auth.ts @src/api/login.ts fix the auth flow"

Flags

# Skip permission prompts (trusted environments)
claude --dangerously-skip-permissions "run all tests and fix failures"

# Specify model
claude --model claude-opus-4-5 "design the system architecture"
claude --model claude-haiku-4-5 "rename this variable"

# Continue last conversation
claude -c "actually, make that function async"

# Print mode (non-interactive output)
claude -p "summarize what changed in the last commit"

# Verbose output (see tool calls)
claude --verbose "debug this failing test"

Session Management

# List recent sessions
claude sessions

# Resume specific session
claude -r SESSION_ID

# Clear session history
claude clear

CLAUDE.md Configuration

CLAUDE.md is the most powerful way to customize Claude Code behavior. It's read at the start of every session in that directory.

File hierarchy (all are merged):

~/.claude/CLAUDE.md          → global, all projects
project-root/CLAUDE.md       → project-wide (commit to git)
project-root/src/CLAUDE.md   → subdirectory overrides

What to include:

What NOT to include:

Full guide: Memory System — CLAUDE.md vs Auto-Memory


Slash Commands Reference

Built-in slash commands (type in Claude Code session):

Command Description
/help Show available commands
/clear Clear conversation context
/compact Compress context to save tokens
/model claude-sonnet-4-5 Switch model mid-session
/cost Show current session token cost
/status Show session info

Custom Slash Commands (Skills)

Create reusable workflows in .claude/skills/[name]/SKILL.md:

# Create a custom /deploy skill
mkdir -p .claude/skills/deploy
# Write .claude/skills/deploy/SKILL.md with your deployment steps
# Then use: /deploy

Custom skills guide (English) | 한국어 가이드


MCP Servers

Model Context Protocol lets Claude Code integrate with external services:

// ~/.claude/claude.json
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": { "GITHUB_TOKEN": "your-token" }
    },
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/allowed/path"]
    }
  }
}

Best MCP Servers for Claude Code 2026


Hooks

Hooks run shell commands at specific points in Claude Code's lifecycle:

// .claude/settings.json
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Write|Edit",
        "hooks": [{"type": "command", "command": "echo 'Writing file: $TOOL_INPUT_PATH'"}]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Write",
        "hooks": [{"type": "command", "command": "bun run typecheck 2>&1 | head -20"}]
      }
    ]
  }
}

Claude Code Hooks guide


Advanced Patterns

Worktree Isolation

Run Claude in an isolated git worktree for risky changes:

# With --isolation flag (experimental)
claude --isolation worktree "refactor the entire auth module"

# Manual worktree
git worktree add ../feature-branch main
cd ../feature-branch
claude "implement the new feature"

Worktree isolation guide

Plan Mode

Review a plan before Claude executes:

# In Claude Code session
/plan "migrate from REST to GraphQL"

# Claude proposes steps, you approve before execution

Plan mode deep dive

Background Tasks

Run Claude in non-blocking mode:

# Start background task
claude --background "run all tests and create a report"

# Check progress
claude tasks

# Get results
claude task-output TASK_ID

Background tasks guide

Parallel Subagents

claude "Research these three topics in parallel using subagents:
1. How does our authentication system work?
2. What are all the API endpoints?
3. What tests exist and what's the coverage?

Then synthesize findings."

Parallel subagents guide


Model Selection

Task Recommended Model Why
Complex architecture claude-opus-4-5 Best reasoning
Daily coding claude-sonnet-4-5 Best cost/quality
Simple tasks (rename, format) claude-haiku-4-5 Fastest, cheapest
# Global model default in ~/.claude/CLAUDE.md
## Model
Use claude-sonnet-4-5 by default.
Use claude-opus-4-5 only when I explicitly ask for it.

Specialized Guides

Development:

Features:

Comparisons:

Korean (한국어):


Frequently Asked Questions

Is Claude Code free? Claude Code uses your Anthropic API credits. There's no separate Claude Code subscription — you pay for API usage (tokens) at standard Anthropic API rates. Heavy daily use typically costs $10-50/month.

Does Claude Code work offline? No — it requires an active Anthropic API connection for all inference.

Can I use Claude Code in VS Code / JetBrains? Yes — Claude Code has IDE integrations. → IDE Setup Guide

What's the context window limit? Claude Sonnet 4.5 and Opus 4.5 support 200K token context windows. For most codebases, this means Claude can read the entire codebase at once. Large monorepos may need the /compact command to manage context.

Is my code sent to Anthropic? When you use Claude Code, the files and commands you share are sent to Anthropic's API for inference. Anthropic's API usage policy applies. For enterprise privacy requirements, see Anthropic's enterprise options.


Go Deeper

Power Prompts 300 — $29 — 300 tested Claude Code prompts: EDA workflows, refactoring patterns, debugging prompts, CLAUDE.md templates for 5 project types, and the "slash command library" for teams.

→ Get Power Prompts 300 — $29

30-day money-back guarantee. Instant download.

AI Disclosure: Written with Claude Code.

Tools and references