Master Claude Code in One Page
From install to autonomous agent teams — an interactive guide to every feature, flag, and concept in Claude Code. No jargon, real examples, hands-on demos.
$ claude
Welcome to Claude Code v1.0
Model: claude-sonnet-4-6 · Context: 200K tokens
> Fix the auth bug in login.ts
Running example
Throughout this guide, we'll use TaskFlow — a task management app (Next.js + TypeScript + Prisma + PostgreSQL) — to show every concept in action. Think of it as your pair programming session with Claude Code on a real project.
Your first 5 minutes
Getting Started
Claude Code is a command-line tool by Anthropic. You install it, open your terminal, type claude, and talk to it in plain English. It's not a chatbot — it reads your code, edits files, runs commands, and creates commits. Think of it as a senior developer who lives in your terminal and knows your entire codebase.
Install in 30 seconds
npm install -g @anthropic-ai/claude-codeThen open any project folder and type claude. That's it. Works on macOS, Linux, and Windows (WSL). Also works over SSH and in containers.
How to Write Good Prompts
Claude takes your words literally. A vague prompt gets a vague result. A specific prompt that says what to change, where it is, and how to verify it works gets precise code. Here's the difference:
Vague prompt
"fix the bug"
Which bug? In which file? How should it behave after?
Specific prompt
"The date filter on /api/tasks returns all tasks instead of filtering by dueDate. Fix the Prisma query in src/routes/tasks.ts and add a test."
Prompt tips that work:
- 1.Start with the symptom — what's going wrong?
- 2.Point to the file or area — "in src/auth/login.ts"
- 3.Say what done looks like — "tests pass, no type errors"
- 4.Add constraints — "don't change the public API"
The 6 Built-in Tools
When you ask Claude to do something, it picks from 6 tools. Every action shows up in your terminal — nothing is hidden. You approve each step (or let it run freely in acceptEdits mode).
Read
View any file
Write
Create new files
Edit
Change specific lines
Bash
Run shell commands
Glob
Find files by name
Grep
Search file contents
Watch Claude fix a bug in TaskFlow — it reads the file, finds the issue, edits the code, and runs the tests:
> Fix the auth bug in login.ts
Permissions — You're Always in Control
Claude asks before doing anything risky. You choose how much freedom to give it. Start with "default" — you approve each edit. As you build trust, switch to "acceptEdits" for faster flow.
| Mode | File edits | Shell commands | Best for |
|---|---|---|---|
| default | Asks first | Asks first | Getting started, sensitive code |
| acceptEdits | Auto-approved | Asks first | Daily coding (recommended) |
| plan | Blocked | Blocked | Code review, architecture |
Switch anytime with /permissions or start Claude with claude --allowedTools Edit,Write,Bash to whitelist specific tools. Advanced modes also include dontAsk (auto-deny unless pre-approved) and bypassPermissions (skip all prompts — CI only).
Teaching Claude your codebase
Your Project, Your Rules
Out of the box, Claude knows nothing about your project. It doesn't know you use Next.js, prefer Tailwind, or hate semicolons. These features let you teach it.
CLAUDE.md — Your Project's Rulebook
Create a file called CLAUDE.md in your project root. Claude reads it at the start of every session — like onboarding notes for a new developer. Keep it focused (under 100 lines). Here's a good example:
# TaskFlow
Task management app for small teams.
## Stack
Next.js 15, TypeScript (strict), Prisma, PostgreSQL, Tailwind CSS
## Commands
npm run dev # local server on :3000
npm test # run Vitest
npm run build # production build
npm run lint # ESLint + Prettier check
## Conventions
- Always use TypeScript strict mode
- Use Prisma for all database queries
- API routes in src/app/api/
- Run tests before committing
## Never
- Never modify .env or .env.local
- Never use raw SQL — always Prisma
- Never push directly to mainRun /init to auto-generate a starter CLAUDE.md. You can also place a global one at ~/.claude/CLAUDE.md for preferences that apply to all projects (like "always use bun" or "never auto-commit").
The .claude Directory — Your Project's Brain
Every Claude Code project has a .claude/ folder at the project root. This is where all configuration lives — permissions, hooks, skills, custom commands, and MCP servers. Here's what a well-configured project looks like:
TaskFlow project structure
settings.json — The Central Config
This is where permissions, deny rules, hooks, and MCP servers all live. Here's a production-ready example:
{
// ─── Permissions ───
"permissions": {
"allow": [
"Edit", // auto-approve file edits
"Write", // auto-approve new files
"Bash(npm test*)", // auto-approve test runs
"Bash(npm run lint)" // auto-approve linting
],
"deny": [
"Read:.env*", // protect secrets
"Edit:.env*", // can't edit them either
"Bash(rm -rf*)" // block dangerous commands
]
},
// ─── Hooks ───
"hooks": {
"PostToolUse": [
{ // Auto-format every edited file
"matcher": "Edit|Write",
"command": "npx prettier --write $FILE"
}
]
},
// ─── MCP Servers ───
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"]
},
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": { "DATABASE_URL": "postgresql://..." }
}
}
}Project config: .claude/
Lives in your repo root
Shared with your team via git
Project-specific rules and tools
Commit: settings.json, skills/, commands/ Gitignore: worktrees/
Global config: ~/.claude/
Lives in your home directory
Personal — just for you
Cross-project preferences
Contains: CLAUDE.md, settings.json, projects/ (auto memory), credentials
Best practices for .claude
Memory — How Claude Remembers You
Claude has two kinds of memory:
CLAUDE.md (you write)
Project rules and conventions. Loaded every session. You control what's in it. Think of it as onboarding docs.
Auto Memory (Claude writes)
Tell Claude "always use bun" or "never auto-commit" — it saves your preference to ~/.claude/projects/ and remembers next time.
Context Window — Claude's Short-Term Memory
Everything Claude sees at once fits in a 200K token context window. Your messages, files read, command outputs, CLAUDE.md — it all lives here. When it fills up, Claude auto-summarizes older content. You can also type /compact to manually free up space.
Context Window
200,000 tokens total
7% used
13,000 / 200,000
Context is like milk — it expires
The longer a session runs, the more context gets filled with old file reads, stale outputs, and earlier attempts. When you switch to a new topic or task, start a fresh session instead of continuing in a cluttered one. Use /compact to summarize and free tokens (keeps context), or /clear to wipe everything and start fresh. New task? New session. Your future self will thank you.
Choosing the Right Model
Three models, three tradeoffs. You don't need Opus to rename a variable. Switch mid-session with /model or start with claude --model opus.
Sonnet 4.6
200K tokensInput
$3/M
Output
$15/M
Best for
Switch models mid-session with /model or start with claude --model opus
CLI Flags — Quick Reference
Flags you add when starting Claude. The essential ones:
claudeStart interactive session in current directoryclaude -cContinue your last session (keeps full context)claude -rPick from all past sessions to resumeclaude --model opusStart with a specific modelclaude -p "..."One-shot command, no interactive sessionclaude --allowedTools Edit,BashOnly allow specific toolsclaude --add-dir ../sharedGive Claude access to another directoryclaude --max-turns 10Auto-stop after N tool callsMonorepo tip: Use --add-dir to give Claude access to shared packages. Example: claude --add-dir ../packages/shared --add-dir ../packages/ui
Leveling up
Power Features
Extended Thinking
For hard problems, tell Claude to think deeper. It uses a hidden scratchpad to reason step by step before answering — like a developer whiteboarding before coding. Three levels:
think
~4K tokens
Quick plans, simple logic
"think about how to rename this function safely"
megathink
~10K tokens
Multi-file refactors
"megathink. How should I restructure the API layer?"
ultrathink
~32K tokens
Architecture, complex bugs
"ultrathink. Plan the migration from REST to GraphQL."
Extended thinking is on by default with maximum budget. These keywords were historically used to hint at reasoning depth — Claude still responds to them, but you no longer need them. The quality of your prompt matters more than the keyword.
Skills — Reusable Workflows
If you give Claude the same instructions more than twice, save it as a skill. Just a Markdown file with a name and steps. Your team shares them via git.
---
name: deploy
description: Deploy TaskFlow to production
---
# Deploy to Production
1. Run `npm test` — all tests must pass
2. Run `npm run build` — must compile cleanly
3. Run `npm run lint` — no errors allowed
4. Commit with message "release: vX.X.X"
5. Push to main — Vercel auto-deploys
6. Verify https://taskflow.app loadsNow type /deploy and Claude runs all 6 steps. Anyone on the team can use it.
Hooks — Guaranteed Automation
Unlike prompts (which Claude might interpret differently), hooks are shell commands that always run at specific moments in Claude's lifecycle. They can't be skipped or forgotten.
Configure with /hooks or in .claude/settings.json · Click any step to see an example
The most popular hook — auto-format every file Claude edits:
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"command": "npx prettier --write $FILE"
}]
}Checkpoints & Undo
Every file edit creates a checkpoint. Claude breaks something? Press Esc + Esc to open the rewind menu. Restore code, conversation, or both to any previous point. It's Ctrl+Z for your entire project.
Note: only direct file edits are tracked. Changes from bash commands (like npm install) aren't checkpointed.
Image & Screenshot Support
Paste images directly into the terminal. Paste a Figma screenshot and say "build this component." Paste an error screenshot and say "what's wrong?" Claude sees the image and responds accordingly.
Works with PNG, JPG, and other common formats. Great for replicating UI designs or debugging visual issues.
Slash Commands — Quick Actions
Type / to see instant actions. These are built-in and don't cost any tokens:
/compactSummarize context/clearFresh start/modelSwitch model/rewindUndo changes/contextCheck memory usage/hooksManage hooks/permissionsChange mode/initGenerate CLAUDE.md/copyCopy last response/costSee spendingCustom Slash Commands
Create your own slash commands in .claude/commands/. Each file becomes a command:
Run all tests in the affected
modules. If any fail, fix the
code and re-run until all pass.
Show a summary when done.Now you can type:
/testTeam-wide: commit the commands/ folder to git
Connecting Claude to your world
The Ecosystem
MCP Servers — Plug In Any Tool
MCP (Model Context Protocol) is like a USB port for AI. Plug in a server and Claude gains new abilities — create GitHub PRs, read Figma designs, query databases, post to Slack. It's an open standard, not Anthropic-specific, so any tool can build an MCP server.
3,000+ community MCP servers at mcp.so · Click any server above to see how to add it
IDE Integrations — Claude in Your Editor
Don't want to leave your editor? Claude Code works inside VS Code and JetBrains IDEs. Same capabilities, but inline with your code.
VS Code Extension
Official extension by Anthropic. Opens a Claude panel alongside your code. Highlight code, right-click, ask Claude to explain or refactor it.
JetBrains Plugin
Works in IntelliJ, WebStorm, PyCharm, and all JetBrains IDEs. Same features — Claude reads your project, suggests changes inline.
The extensions use the same Claude Code engine underneath. CLAUDE.md, skills, hooks, and MCP servers all work the same way in your IDE.
Git Integration
Say "commit this" — Claude stages the right files, writes a descriptive message, and commits. Say "create a PR" — it pushes and opens one on GitHub. Built-in safety: never force-pushes, never amends without asking, never skips pre-commit hooks. Works with GitHub, GitLab, and Bitbucket.
Sub-Agents
For complex searches, Claude spawns smaller agents that work in parallel. Need to find all API endpoints? 3 sub-agents scan routes, controllers, and middleware simultaneously. You don't control this — Claude decides when parallelism is faster.
Session History & Resume
Every session is saved locally. claude -c continues your last session with full context. claude -r lets you pick from all past sessions. Close your laptop at 5pm, resume at 9am where you left off.
Claude works without you
Full Autonomy
Headless Mode — No Human Needed
Run Claude from scripts with no interactive session. The -p flag sends a single prompt and returns the result. This is how you put Claude in CI/CD pipelines, cron jobs, and automation scripts.
# One-shot prompt — get a quick answer
$ claude -p "What version is this project?"
TaskFlow v2.1.0 (Next.js 15)
# JSON output — for scripts and automation
$ claude -p "List all TODO comments" --output-format json
# Pipe input — review a git diff
$ git diff | claude -p "Review this diff for bugs"
# Restrict tools for safety in CI
$ claude -p "Review this PR" --allowedTools Read,GrepOutput formats: text (default), json (structured), stream-json (real-time streaming). Use stream-json in GitHub Actions to see progress as it runs.
GitHub Actions — Claude in CI/CD
Claude Code has a built-in GitHub integration. Install it on your repo and Claude can automatically review PRs, fix failing tests, or triage issues.
name: Claude PR Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
npm install -g @anthropic-ai/claude-code
claude -p "Review this PR for bugs,
security issues, and code quality." \
--allowedTools Read,Grep \
--output-format stream-jsonRun /install-github-app inside Claude Code to set up the GitHub integration with one command.
Agent Teams & Worktrees
For large tasks, one Claude isn't enough. A lead agent splits the work among worker agents. Each worker gets its own worktree — an isolated git checkout on a separate branch — so they can edit files simultaneously without conflicts. When done, changes merge back.
Agent Team Orchestration
Lead agent dispatches tasks to parallel workers
Lead Agent
Coordinate refactor of auth system
Refactor login flow
.claude/worktrees/auth-login
Update session middleware
.claude/worktrees/auth-session
Migrate JWT to OAuth2
.claude/worktrees/auth-oauth
TaskFlow needs all API routes migrated to the new error handler. The lead assigns 3 workers — auth-routes, task-routes, user-routes — and the whole migration finishes in parallel.
Pricing — Max vs API
Two ways to pay: Claude Max ($100-$200/month flat, unlimited use) or API (pay per token). Rule of thumb: 10+ sessions per day → Max is cheaper. Fewer → API wins. Every response shows the token count so you always know what you're spending.
Should you use Max or API?
Adjust your usage to find the cheapest option
API (per-token)
$76
/month estimated
Cheaper for youClaude Max (20x)
$200
/month · also $100/mo (5x)
Breakdown
You'd save $124/month with API pricing
How the pros use it
Workflow Tips
Speed Up with Terminal Aliases
Typing claude dozens of times a day gets old fast. Set up shell aliases to save keystrokes and create instant workflows:
# Quick launch
alias c='claude' # just type 'c'
alias cc='claude -c' # continue last session
alias cr='claude -r' # resume a past session
# One-shot commands
alias cq='claude -p' # quick one-shot prompt
alias creview='claude -p "review this diff for bugs"'
# Pipe-friendly
alias cdiff='git diff | claude -p "review this diff"'
alias clog='git log --oneline -20 | claude -p "summarize recent changes"'After adding these, run source ~/.zshrc or open a new terminal. Now c launches Claude, cc continues where you left off.
Voice Input — Talk to Claude
Use a speech-to-text tool like SuperWhisper or MacWhisper to dictate prompts instead of typing them. Press a hotkey, describe what you want in plain English, and it types the prompt into Claude Code for you.
Especially useful for long, detailed prompts that are faster to say than type. "Fix the authentication bug where users can't log in with Google OAuth on the /auth/callback route..."
Getting Output Out
Claude's response is stuck in the terminal — how do you use it elsewhere? Three ways:
/copyCopies Claude's last response to your clipboard-p | pbcopyPipe one-shot output directly to clipboard"save to file"Just ask Claude to write the output to a fileMultitasking with Multiple Sessions
You're not limited to one Claude session. Open multiple terminal tabs and run separate sessions in parallel — each with its own context window.
Tip: keep one "throwaway" tab for quick lookups. Use cq alias for one-shot questions that don't need a full session.
The Write-Test Cycle — TDD with Claude
One of the most powerful patterns: give Claude a failing test and let it code until the test passes. This is test-driven development, automated.
"Make this test pass. Run npm test after each change until green."This works especially well with acceptEdits mode or headless mode. Claude iterates faster when it doesn't wait for approval on each edit.
When to Use What — CLAUDE.md vs Skills vs Commands
Three ways to give Claude instructions, each for a different purpose. New users often put everything in CLAUDE.md — here's where each belongs:
| Feature | Use for | Runs when | Example |
|---|---|---|---|
| CLAUDE.md | Always-on rules & context | Every session, automatically | "Use TypeScript strict mode" |
| Skills | Multi-step workflows | When you type /skillname | /deploy → test, build, push |
| Commands | Quick prompt templates | When you type /commandname | /review → review changed files |
Rule of thumb: if it should always apply → CLAUDE.md. If it's a multi-step recipe → Skill. If it's a one-off instruction → Command.
Customize Your Status Line
The status bar at the bottom of Claude Code shows model, cost, and context usage. You can customize it in settings to show different info or change colors.
Configure in settings or check claude config set for options.
Audit Your Approved Permissions
Over time, you'll approve various tools and commands. Periodically check what you've allowed:
.claude/settings.jsonallow arrayBash(*))Be specific: Bash(npm test*) is safer than Bash(*).
The Full Picture
You started by typing claude in a terminal. Now you know every concept — prompts, tools, permissions, CLAUDE.md, models, hooks, skills, MCP servers, IDE integrations, headless mode, agent teams, and the workflow patterns that make it all click. Claude Code isn't just a tool; it's a new way to write software.
Frequently Asked Questions
Common questions about Claude Code, answered.
What is Claude Code?
Claude Code is Anthropic's agentic command-line tool. Unlike chatbots, it's an AI agent that lives in your terminal and can read your codebase, edit files, run shell commands, manage git, and create PRs — all through natural language prompts. It uses Claude's intelligence to understand your project and take real actions.
Is Claude Code free?
Claude Code requires either a Claude Max subscription ($100/month for 5x usage or $200/month for 20x usage) or Anthropic API credits (pay-per-token). There's no free tier for Claude Code specifically. For heavy daily use (10+ sessions/day), Max is more cost-effective; for occasional use, the API is cheaper.
What is a CLAUDE.md file?
CLAUDE.md is a Markdown file that Claude Code loads automatically at the start of every session. Place it in your project root (./CLAUDE.md) for project-specific rules, or in ~/.claude/CLAUDE.md for global preferences. It typically contains coding conventions, architecture decisions, tech stack details, and workflow rules. Think of it as onboarding docs for Claude.
What is the context window in Claude Code?
The context window (~200K tokens) is Claude's working memory — everything it can see at once. It holds your conversation history, files it has read, command outputs, CLAUDE.md instructions, and system prompts. When it fills up, Claude auto-compacts by summarizing older content. Use /compact to manually free space, or /clear to start completely fresh.
What are MCP servers?
MCP (Model Context Protocol) is an open standard — like USB-C for AI — that lets Claude Code connect to external tools, databases, and APIs. You add MCP servers with 'claude mcp add', and Claude gains new capabilities. For example, a GitHub MCP server lets Claude create PRs, a Figma server lets it read designs, and a PostgreSQL server lets it query databases. Over 3,000 community servers are available.
What is the difference between Haiku, Sonnet, and Opus?
These are Claude's three model tiers. Haiku is the fastest and cheapest ($1/$5 per million tokens) — great for simple tasks like file searches and quick edits. Sonnet is the balanced default ($3/$15) — handles 80% of development work well. Opus is the most capable ($5/$25) — best for complex reasoning, architecture decisions, and hard debugging. Switch between them mid-session with /model.
What are hooks in Claude Code?
Hooks are shell commands that execute automatically at specific lifecycle events: before/after tool calls, on session start/end, and on permission prompts. Unlike prompts (which Claude might interpret differently), hooks guarantee execution. The most popular hook: running Prettier on every file Claude edits (PostToolUse hook with matcher 'Edit|Write').
What is extended thinking?
Extended thinking lets Claude generate hidden chain-of-thought tokens — an internal scratchpad where it reasons step by step before answering. It's enabled by default with maximum budget. Keywords like 'think', 'megathink', and 'ultrathink' were historically used to hint at reasoning depth, but you no longer need them — Claude automatically uses the right amount of thinking based on problem complexity.
What are Agent Teams and worktrees?
Agent Teams let a lead Claude agent coordinate multiple specialist agents working in parallel. Each agent gets its own git worktree — an isolated copy of your repo on a separate branch. This means multiple agents can edit files simultaneously without conflicts. The lead assigns tasks, agents work independently, and results are merged at the end.
Can Claude Code run without human interaction?
Yes — headless mode. Run 'claude -p "your prompt"' for non-interactive execution. Combine with '--output-format stream-json' for machine-readable output and '--allowedTools Read,Grep' to restrict what Claude can do. This makes Claude Code perfect for CI/CD pipelines, GitHub Actions, cron jobs, and automation scripts.
Does Claude Code work in VS Code and JetBrains?
Yes. There's an official VS Code extension by Anthropic and a JetBrains plugin that works in IntelliJ, WebStorm, PyCharm, and all JetBrains IDEs. They use the same Claude Code engine, so CLAUDE.md, skills, hooks, and MCP servers all work the same way. You can highlight code, right-click, and ask Claude to explain or refactor it.
How do checkpoints and undo work?
Claude Code automatically saves a checkpoint before every file edit. Press Esc twice or use /rewind to open the rewind menu, where you can restore code, conversation, or both to any previous state. It's a safety net for experimentation. One limitation: only direct file edits are tracked, not files modified by bash commands.
What are skills and custom commands?
Skills are reusable Markdown prompt templates stored in .claude/skills/. They're invoked as slash commands (like /deploy). Custom commands live in .claude/commands/ — each .md file becomes a slash command. Both are shared via git, so your whole team gets the same workflows.
Can Claude Code work with monorepos?
Yes. Use the --add-dir flag to give Claude access to multiple directories: 'claude --add-dir ../packages/shared --add-dir ../packages/ui'. This lets Claude see and edit code across packages while keeping the main context focused on your current directory.
What's the difference between CLAUDE.md, Skills, and Commands?
CLAUDE.md contains always-on rules loaded every session (like 'use TypeScript strict mode'). Skills (.claude/skills/) are multi-step workflow recipes invoked with /skillname (like /deploy that runs test, build, push). Commands (.claude/commands/) are simple prompt templates invoked with /commandname. Rule of thumb: always-on → CLAUDE.md, multi-step recipe → Skill, one-off instruction → Command.
Can I run multiple Claude Code sessions at once?
Yes. Open multiple terminal tabs and run separate Claude sessions in parallel. Each gets its own context window. A common pattern: Tab 1 for your main feature work, Tab 2 for quick questions, Tab 3 for debugging. You can also use the 'c' alias for quick launch and 'cq' (claude -p) for one-shot questions that don't need a full session.
Keep exploring
Dive deeper into the technology behind Claude Code.