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.
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
- Read and write files — understands your entire codebase in context
- Run shell commands —
npm run build,pytest,git commit, anything - Multi-step tasks — keep working until the task is done, not just one response
- Parallel subagents — spawn multiple agents for concurrent research or implementation
- MCP integrations — connect to GitHub, Slack, databases, and more via Model Context Protocol
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:
- Technology stack and versions
- Coding conventions (error patterns, naming)
- Architecture constraints
- Forbidden patterns
- Key file paths
- Test and build commands
What NOT to include:
- Temporary task notes
- API keys or secrets
- Information that changes frequently
→ 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"}]
}
]
}
}
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"
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
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
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."
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:
- Claude Code for Backend: Python, Go, Node.js
- Claude Code for Frontend: Next.js and React
- Claude Code for Data Science: Jupyter Workflows
- Claude Code Git Workflow
- Claude Code for Teams
- Docker Container Setup with Claude Code
- PR Review Automation with Claude Code
- GitHub Actions CI/CD with Claude Code
- Refactoring Large Codebases with Claude Code
- Database Migrations with Claude Code
- Automated Test Generation with Claude Code
- Security Vulnerability Detection with Claude Code
- React Native Mobile Development with Claude Code
- Open Source Contribution with Claude
- 200K Context Window Techniques — Long context strategies and chunking
- Legacy Codebase Modernization with Claude Code — Modernizing old codebases
- Building Custom MCP Servers with Claude Code — Create your own MCP integrations
- Auto-Generate Documentation with Claude Code — Automated docs from code
- Monorepo Setup with Claude Code (Turborepo/Nx) — Manage Turborepo and Nx monorepos
- REST API Design & Generation with Claude Code — Design, scaffold, and document REST APIs
- Kubernetes YAML Automation with Claude Code — Generate and manage Kubernetes manifests
- Chrome Extension Development with Claude Code — Build MV3 Chrome extensions
- Microservices Architecture with Claude Code — Decompose and build microservices
- Migrate from OpenAI to Claude — Line-by-line SDK migration guide
- Serverless Functions with Claude Code — AWS Lambda, Vercel Functions, and Cloudflare Workers
- SQL Generation with Claude Code — Write, optimize, and debug SQL queries
- Electron Desktop App Development — Build cross-platform desktop apps with Electron and Tauri
- Web Scraping Automation with Claude Code — Playwright + Claude for structured data extraction
- Android Development with Claude Code — Kotlin, Jetpack Compose, Room, Retrofit, Hilt
- Test Coverage Improvement — Targeted test generation from coverage reports
- Stripe Payment Integration — Checkout, webhooks, subscriptions, idempotency keys
- Supabase Integration — Postgres + RLS + Auth + Realtime + Storage
- Terraform Infrastructure — IaC modules, state management, drift detection
Features:
- Slash Commands Reference
- Claude Code Hooks
- Context Management
- Memory System
- Plan Mode
- Worktree Isolation
- Background Tasks
- Todo System
Comparisons:
- Claude Code vs Cursor
- Claude Code vs GitHub Copilot
- Cursor to Claude Code Migration
- Agent SDK vs Claude Code
Korean (한국어):
- Claude Code 한국어 가이드
- MCP 서버 가이드 (한국어)
- 커스텀 스킬 만들기
- SQL 쿼리 자동 생성 가이드
- Claude API 슬랙봇 만들기
- Claude API 디스코드봇 만들기
- Claude API Ruby/Rails 가이드
- 이메일 자동화 가이드
- Stripe 결제 통합 가이드
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.
30-day money-back guarantee. Instant download.