Claude Code,
explained simply.
An agentic coding tool that reads your codebase, edits files, runs commands, and plugs into your dev tools — from the terminal, your IDE, a desktop app, or the browser. This guide covers everything from first install to advanced automation, in plain words with copy-ready examples.
What is Claude Code?
Think of Claude Code as a coding partner that lives inside your project. Instead of copy-pasting snippets into a chat window, you point it at a real folder of real code and talk to it in plain English. It can read your files, write and change code across many files at once, run commands in your shell, run your tests, use git, and even talk to outside tools like Jira or Slack.
The key word is agentic: you describe a goal, and it plans the steps, does the work, checks the result, and iterates — pausing to ask you before anything risky. It is not autocomplete; it is closer to handing a task to a capable junior engineer who happens to type very fast.
Where it runs
One engine, many surfaces — the same CLAUDE.md files, settings, and connected tools follow you everywhere: the Terminal CLI, a VS Code / Cursor / JetBrains extension, a standalone Desktop app, and the web (including the Claude iOS app).
Installing Claude Code
Most surfaces need a paid Claude subscription or an Anthropic Console account. Pick your environment below.
The native installer auto-updates in the background. This is the recommended route.
macOS · Linux · WSL
curl -fsSL https://claude.ai/install.sh | bashWindows PowerShell
irm https://claude.ai/install.ps1 | iexThen drop into any project and start a session:
cd your-project
claudeYou'll be prompted to log in on first use. Other options exist too — Homebrew (brew install --cask claude-code), WinGet (winget install Anthropic.ClaudeCode), and Linux package managers (apt, dnf, apk).
brew upgrade claude-code or winget upgrade Anthropic.ClaudeCode.The VS Code / Cursor extension adds inline diffs, @-mentions of files, plan review, and conversation history right inside the editor.
- Open the Extensions view —
Cmd+Shift+X(Mac) orCtrl+Shift+X(Windows/Linux). - Search for "Claude Code" and install.
- Open the Command Palette (
Cmd/Ctrl+Shift+P), type "Claude Code", and choose Open in New Tab.
CLAUDE.md and settings shared with the CLI.A standalone app for running Claude Code outside your terminal or IDE. Review diffs visually, run several sessions side by side, schedule recurring tasks, and kick off cloud sessions.
- Download for macOS (Intel + Apple Silicon), Windows x64, or Windows ARM64 from the official overview page.
- Launch, sign in, then click the Code tab. A paid subscription is required.
Run Claude Code in your browser with zero local setup. Great for long-running tasks you check back on, repos you don't have locally, or several tasks in parallel.
https://claude.ai/codeAvailable on desktop browsers and the Claude iOS app. You can later pull a web session into your terminal with claude --teleport.
A plugin for IntelliJ IDEA, PyCharm, WebStorm, and the rest of the JetBrains family — with interactive diff viewing and selection-context sharing.
- Install the Claude Code plugin from the JetBrains Marketplace.
- Restart your IDE.
Your first session
Starting is just typing claude inside a project folder. From there it's a conversation. Here's the natural rhythm of a first sitting:
# 1. Get oriented — let it map the project for you
> What does this project do? Summarize the structure.
# 2. Understand one file before you touch it
> Read src/auth.py and explain it step by step.
# 3. Ask for a change in plain language
> Add input validation to the login endpoint and write a test for it.
# 4. Let it run the test and fix what breaks
> Run the tests and fix any failures.
# 5. Ship it
> Commit with a descriptive message and open a PR.That is the loop: you describe what you want, Claude writes and runs, you review and iterate. You don't have to know the exact files, function names, or commands up front — describing the symptom or goal is usually enough.
employment.csv, compute monthly growth by sector, and plot a time series" is strong.How it actually thinks
Three ideas explain almost everything about getting good results.
The context window
Every turn, the entire conversation so far — your prompts, Claude's replies, every file it read, every command output — gets bundled and sent to the model together. That bundle is the context window, and it has a fixed size measured in tokens (roughly ¾ of a word). When it fills up with irrelevant history, quality drops and cost rises.
Why this matters in practice
- Start fresh for new tasks. Use
/clearto reset the conversation while keeping your project instructions. - Compact long sessions.
/compactsummarizes history so far and frees up room; you can tell it what to keep. - Keep scope tight. One focused task per session beats one sprawling marathon.
CLAUDE.md — its long-term memory
A markdown file at your project root that Claude reads at the start of every session. Put your coding standards, architecture decisions, preferred libraries, and review checklists here once, and Claude follows them reliably without you repeating yourself. (Full details in Section 09.)
The everyday workflow
These are the jobs Claude Code is built to absorb. Expand any card for an example.
✦Automate the work you keep putting off›
claude "write tests for the auth module, run them, and fix any failures"⚒Build features & fix bugs›
⎇Commits & pull requests›
claude "commit my changes with a descriptive message"⚙Pipe, script & chain (Unix-style)›
# Scan recent logs for anomalies
tail -200 app.log | claude -p "flag any anomalies"
# Security-review only the changed files
git diff main --name-only | claude -p "review these for security issues"⧉Run agent teams›
Slash commands
Slash commands are typed inside a running session to control Claude's behavior. Type / to see the live list (plugins and skills add more). Type /help for everything available in your install. Here are the ones you'll reach for most — filter to find one fast.
| Command | What it does |
|---|---|
/help | List every slash command available right now. |
/clear | Reset the conversation to a clean context while keeping your CLAUDE.md. |
/compact | Summarize the session so far to free up context. Add an argument to say what to keep, e.g. /compact keep the error-handling notes. |
/model | Switch the model mid-session (one of the few settings changeable live). |
/permissions | View and change permission rules in place during the session. |
/resume | Open a picker to jump back into an earlier session. |
/rename | Rename the current session; the name shows on the prompt bar. |
/init | Generate a starter CLAUDE.md by scanning your project. |
/mcp | View and manage connected Model Context Protocol servers. |
/plugins | See and manage installed plugins. |
/schedule | Create a routine that runs Claude on a recurring schedule. |
/loop | Repeat a prompt within the session for quick polling. |
/desktop | Hand off the current terminal session to the Desktop app for visual diff review. |
/effort | Adjust how hard the model works on the task (low → max). |
/diff | Show pending code changes as a diff. |
.claude/commands/ (shared via git) or ~/.claude/commands/ (personal, all projects) and it becomes a slash command. Use $ARGUMENTS or positional $1 $2 placeholders to pass input.# Create a reusable /optimize command
mkdir -p .claude/commands
echo "Analyze this code for performance issues:" > .claude/commands/optimize.md
# now type /optimize inside any session in this repoCLI commands
These run in your shell to start or manage sessions (as opposed to slash commands, which run inside a session). Filter the table below.
| Command | What it does | Example |
|---|---|---|
claude | Start an interactive session. | claude |
claude "query" | Start interactively with an opening prompt. | claude "explain this project" |
claude -p "query" | One-shot: print the answer and exit (no session). | claude -p "explain this function" |
cat f | claude -p | Process piped content. | cat logs.txt | claude -p "explain" |
claude -c | Continue the most recent conversation in this folder. | claude -c |
claude -r "id" "q" | Resume a session by ID or name. | claude -r "auth-refactor" "finish this PR" |
claude update | Update to the latest version. | claude update |
claude install [ver] | Install/reinstall a specific version, or stable/latest. | claude install stable |
claude auth login | Sign in. --console bills via Anthropic Console instead of a subscription. | claude auth login --console |
claude auth status | Show login status (exit 0 if signed in). | claude auth status |
claude mcp | Add and manage MCP servers. | claude mcp list |
claude plugin | Install and manage plugins. | claude plugin install code-review@… |
claude agents | Open agent view to monitor/dispatch parallel background sessions. | claude agents --json |
claude setup-token | Generate a long-lived OAuth token for CI and scripts. | claude setup-token |
claude --teleport | Pull a web session down into your local terminal. | claude --teleport |
claude udpate prints "Did you mean claude update?".The most useful CLI flags
Flags are passed when you launch and configure the session before it starts. There are dozens; these are the ones that earn their keep. Note claude --help doesn't list every flag.
| Flag | What it does |
|---|---|
--model | Set the model — sonnet, opus, or a full model name. |
--permission-mode | Start in a mode: default, plan, acceptEdits, auto, dontAsk, or bypassPermissions. |
--effort | How hard to work: low, medium, high, xhigh, max (depends on model). |
-p, --print | Non-interactive: print the response and exit. The backbone of scripting. |
-c, --continue | Load the most recent conversation in this directory. |
-r, --resume | Resume a session by ID/name, or open a picker. |
-w, --worktree | Run in an isolated git worktree so experiments don't touch your main branch. |
--add-dir | Grant read/edit access to extra directories beyond the project root. |
--allowedTools | Tools that run without asking, e.g. "Bash(git log *)" "Read". |
--disallowedTools | Deny rules; scoped rules like Bash(rm *) block only matching calls. |
--tools | Restrict which built-in tools are available at all, e.g. "Bash,Edit,Read". |
--append-system-prompt | Add extra rules on top of the default prompt, e.g. "Always use TypeScript". |
--mcp-config | Load MCP servers from a JSON file or string. |
--max-turns | Cap agentic turns in print mode — a safety brake for scripts. |
--max-budget-usd | Stop after spending this much on API calls (print mode). |
--output-format | Print-mode output as text, json, or stream-json. |
--fallback-model | Auto-switch model if the default is overloaded (print/background). |
--dangerously-skip-permissions | Skip permission prompts. Powerful and risky — use only on trusted tasks. |
--verbose | Show full turn-by-turn output. |
-v, --version | Print the version number. |
--dangerously-skip-permissions lets Claude run commands and edit files without asking. It's genuinely useful for sandboxed, trusted, repetitive work — but never aim it at anything you can't afford to have changed without review.CLAUDE.md & memory
This is the single highest-leverage thing you can set up. CLAUDE.md lives at your project root and is read at the start of every session. Write your conventions once; Claude honors them every time.
# Project: Powertrain Calibration Toolkit
## Conventions
- Language: Python 3.11; type hints required.
- Style: run `ruff format` before any commit.
- Tests: pytest; every new function needs a test.
## Architecture
- src/core/ holds pure logic (no I/O).
- Never edit generated files in build/.
## Review checklist
- No hard-coded calibration constants — pull from config/.
- Flag any change touching the FOC current loop.Practical rules
- Keep it lean. It loads into every session, so don't paste your whole wiki. State the rules; link out to details.
- Generate a starter with
/init, then prune it. - Auto memory also accumulates as Claude works — build commands, debugging insights — and carries across sessions without you writing anything.
Permissions & safety
By default, Claude asks before doing anything consequential — editing a file, running a shell command. You control how much it asks via permission modes, cycled live with Shift+Tab or set at launch with --permission-mode.
default
Asks before edits and commands. The safe baseline.
plan
Claude proposes a plan and waits for approval before acting. Great for big changes.
acceptEdits
Auto-accepts file edits but still gates other actions.
auto
A built-in classifier decides what's safe to run unprompted.
bypassPermissions
Skips checks entirely. Maximum speed, maximum caution required.
Fine-grained rules
You can allow or deny specific tool calls with pattern syntax. For example, allow read-only git but block destructive commands:
claude --allowedTools "Bash(git log *)" "Bash(git diff *)" "Read" \
--disallowedTools "Bash(rm *)"Connecting tools with MCP
The Model Context Protocol (MCP) is an open standard for plugging AI tools into outside data sources. With MCP servers connected, Claude Code can read design docs in Google Drive, update Jira tickets, pull from Slack, or call your own internal tooling — all from inside a session.
# Add a GitHub MCP server, scoped to your user profile
claude mcp add github -s user \
-e GITHUB_PERSONAL_ACCESS_TOKEN=your-token \
-- npx -y @modelcontextprotocol/server-github
# Confirm it registered
claude mcp listInside a session, /mcp shows connected servers and their tools. Because settings are shared across surfaces, an MCP server you add once is available in the CLI, IDE, and desktop app alike.
Skills, hooks & subagents
Three mechanisms turn Claude Code from a smart assistant into a customized team member.
Skills
Package a repeatable workflow your team can share and invoke like a command — /review-pr, /deploy-staging. Skills bundle instructions (and optionally scripts) so everyone runs the process the same way.
Hooks
Run your own shell commands at specific points in Claude's workflow — event-driven automation. Common uses: auto-format after every file edit, run lint before a commit, or block a tool call that violates policy.
PreToolUse— fires before Claude uses a tool (e.g. before writing a file).PostToolUse— fires after, e.g. to format what was just written.SessionStart/ setup hooks — prepare the environment before work begins.
Subagents & agent teams
For big tasks, Claude can spawn focused subagents, each with its own context window, so the main session doesn't get bloated. Agent teams coordinate several full agents on different parts of a job. For fully custom orchestration, the Agent SDK lets you build your own agents on top of Claude Code's tools, with control over permissions and tool access.
Automation & CI
Because the CLI is scriptable, Claude Code slots into pipelines and schedules.
In CI/CD
Automate code review and issue triage with GitHub Actions or GitLab CI/CD, and get automatic review on every PR with GitHub Code Review. For non-interactive runs, generate a token with claude setup-token and call claude -p with guardrails:
# Translate new strings and open a PR — capped and bounded
claude -p "translate new strings into French and raise a PR" \
--max-turns 6 --max-budget-usd 2.00 --output-format jsonOn a schedule
- Routines run on Anthropic-managed infrastructure, so they fire even when your computer is off — morning PR reviews, overnight CI-failure analysis, weekly dependency audits. Create with
/schedule. - Desktop scheduled tasks run on your machine with access to local files and tools.
- /loop repeats a prompt within a session for quick polling.
Working from anywhere
A session isn't tied to one screen. You can move work between environments as your context changes.
Phone / browser
Keep working from any browser or your phone with Remote Control while a session runs on your machine.
Web → terminal
Kick off a long task on the web or iOS app, then pull it into your terminal with claude --teleport.
Terminal → desktop
Hand a terminal session to the Desktop app with /desktop for visual diff review.
From team chat
Mention @Claude in Slack with a bug report and get a pull request back.
Best practices that compound
- Invest in CLAUDE.md early. Five minutes writing conventions saves hours of correcting the same mistakes.
- Be specific about goals. State the what and the why; let Claude figure out the how.
- Use plan mode for anything big. Approve the plan before code is written.
- Manage context deliberately.
/clearbetween unrelated tasks;/compactwhen a session runs long; split very large jobs across focused sessions. - Let it run the feedback loop. Ask it to run tests and fix failures itself rather than reporting back to you each round.
- Review diffs, don't rubber-stamp. Speed is the point; oversight is still yours.
- Reach for worktrees (
-w) for experimental refactors so your main branch stays clean.
/clear paste a two-line recap: "We're building X. Done: Y. Next: Z." Fresh context, full continuity.Common gotchas
- Bloated context = worse answers. If quality drops mid-session, you've probably filled the window with irrelevant history.
/clearor/compact. - Homebrew/WinGet don't auto-update. Stale installs miss features and fixes — upgrade manually.
- Privacy. Claude Code sends code to Anthropic's API to work. Anthropic has stated that data from Claude Pro/Max subscriptions is not used to train models; for sensitive code, confirm your plan's terms and your org's policy.
- PowerShell vs CMD confusion on Windows. If
irmisn't recognized you're in CMD; if&&errors you're in PowerShell. Your prompt showsPS C:\in PowerShell. - Flags are one-shot. Most launch flags can't change mid-session — exceptions are
/modeland/permissions.
Keyboard shortcuts & the prompt line
This is where casual users and power users diverge. The terminal prompt is a full editing environment, and a handful of keys save minutes every session. Filter for the move you need.
| Shortcut | What it does |
|---|---|
Esc | Interrupt Claude mid-turn so you can redirect — the work done so far is kept. Use this, not Ctrl+C, to stop a response. |
Esc Esc | On empty input, opens the rewind menu to restore code/conversation from an earlier checkpoint. On a draft, clears it and saves it to history. |
Shift+Tab | Cycle permission modes live — default → acceptEdits → plan → any others you've enabled. Twice gets you straight to plan mode. |
Ctrl+C | Interrupt a running operation; if idle, first press clears input, second exits the session. |
Ctrl+D | Exit the session (EOF). |
Ctrl+G | Open your prompt in your default $EDITOR — ideal for long, structured instructions. |
Ctrl+O | Toggle the transcript viewer for detailed tool usage; also expands collapsed MCP calls. |
Ctrl+R | Reverse-search prompt history. Ctrl+S cycles scope through session / project / all. |
Ctrl+B | Push a running bash command or agent to the background and keep working. (Tmux users press twice.) |
Ctrl+T | Toggle the task list in the status area during multi-step work. |
Ctrl+X Ctrl+K | Kill all running background subagents — press twice within 3 seconds to confirm. A lifesaver for a runaway agent burning tokens. |
Ctrl+L | Redraw the screen if the display becomes garbled. History is kept. |
Ctrl+V | Paste an image from the clipboard; inserts an [Image #N] chip you can reference in the prompt. |
Alt/Option+P | Switch model without clearing your prompt. |
Alt/Option+T | Toggle extended thinking on or off. |
Alt/Option+O | Toggle fast mode. |
Tab | Accept the greyed-out prompt suggestion, then Enter to run it. |
Option/Alt shortcuts need Option set as "Meta" in your terminal (iTerm2: Profiles → Keys → Left/Right Option = "Esc+"; VS Code: "terminal.integrated.macOptionIsMeta": true).Three prefixes that change everything
What you type at the start of the line decides how Claude Code reads it:
/ commands
Built-in commands, skills, and commands from plugins and MCP servers. Type /, then filter.
! shell mode
Run a shell command directly without Claude interpreting or approving it — its output is added to context. Tab autocompletes from your ! history.
@ file mention
Autocomplete a path. @src/ pulls in a whole directory; @https://… fetches a URL read-only.
Multiline input
\ + Enter works in every terminal, and so does Ctrl+J. Shift+Enter is native in many terminals; in VS Code, Cursor, or Zed run /terminal-setup once to install the binding.
Power moves
The patterns that separate "I use Claude for code" from "Claude Code is my development environment." Several of these come straight from Anthropic's own team.
1 · Plan before you build
The most expensive mistake is letting Claude write code before you agree on what to build. A feature with 20 decision points — each 80% likely correct — fully succeeds only about 1% of the time. Planning collapses those into a reviewed spec where each call is already made.
- Press
Shift+Tabtwice for plan mode (or launch with--permission-mode plan). Claude reads and proposes but edits nothing until you approve. - Iterate with the guard phrase: "address all notes, don't implement yet." Without "don't implement yet," Claude starts coding immediately.
- Plans persist across context resets, so ending a session doesn't lose the planning work.
- Skip the plan when you could describe the exact diff in one sentence — over-planning trivial changes wastes time too.
2 · Paste the error, don't describe it
Describing a bug in words is slow — you watch Claude guess and correct. Paste the raw stack trace, CI output, or Slack thread directly and say "fix." Claude traces it through your codebase far faster than it can interrogate your paraphrase.
3 · Protect your context window
- /clear between tasks. A clean session with a sharp prompt beats a messy three-hour one; sessions degrade as old context drowns out new instructions. The five seconds to clear and re-prompt saves you 30 minutes of diminishing returns.
- Delegate exploration to subagents. Reading a big codebase fills context with file dumps — a subagent does the reading and only the findings return. One task per subagent keeps the main thread clean.
- The task list survives compaction, so Claude stays organized on long jobs. Share one across sessions with
CLAUDE_CODE_TASK_LIST_ID=my-proj claude.
4 · /btw — side questions that don't pollute context
Ask a quick question without adding to the conversation. /btw sees the full session but has no tools, answers once in a dismissible overlay, and never enters history — and it even runs while Claude is working. Press f to fork the answer into a real session with full tool access.
/btw what was the name of that config file again?It's the mirror image of a subagent: /btw knows everything but can't act; a subagent can act but starts blank.
5 · Rewind instead of starting over
Claude Code checkpoints every file edit automatically. Double-tap Esc to open the rewind menu and roll back — restore code only (keeping the conversation) for trial-and-error refactoring, or roll back both code and chat together.
6 · Run many sessions in parallel with worktrees
Launch an isolated git worktree so parallel sessions never collide on the same branch:
claude -w feature-authAnthropic's team runs 10–15 sessions at once this way — terminal tabs, the web, and a phone. Add .claude/worktrees/ to your .gitignore so they don't show up as untracked files.
7 · The self-improvement loop
The golden rule from Claude Code's creator: whenever Claude does something wrong, add a line to CLAUDE.md so it never repeats. Keep the file lean — about 100 focused lines beat 1,000 of filler — and check it into git so the whole team benefits. Treat it as a living document, updated weekly.
8 · Show, don't tell
Pasting a real example of existing code alongside your request noticeably improves output. Claude works better from a concrete reference than an abstract description — building a webhook handler? Show it one you already have.
9 · Vim mode & external editor
Prefer modal editing? Turn on vim mode in /config → Editor mode for full NORMAL / INSERT / VISUAL motions, text objects, and operators right in the prompt. For very long instructions, Ctrl+G drops you into your real editor instead.
10 · Images & screenshots
Paste a screenshot of a broken UI, a design mockup, or an error dialog straight into the prompt with Ctrl+V. Claude reads it as an [Image #N] you can reference — perfect for design-to-code and visual debugging.
Config, env vars & model tricks
Diagnose & configure
/config— interactive settings: vim mode, session recap, theme, prompt suggestions, and more./doctor— surfaces keybinding warnings and config problems in one place; the fastest way to find why a shortcut isn't firing.claude --debug "api,mcp"— see what's happening under the hood, including hook execution.- Custom keybindings live in
~/.claude/keybindings.json— remap any shortcut, and chain multi-key chords with a space, e.g.ctrl+k ctrl+s.
Model selection
Switch mid-session with /model (or Alt+P). On Max, Team, and Enterprise plans some models offer a 1M-token window — request it explicitly with /model opus[1m] or /model sonnet[1m]. If you're worried about quality at large context sizes, start smaller and work up.
Environment variables worth knowing
| Variable | What it controls |
|---|---|
CLAUDE_CODE_SUBAGENT_MODEL | Run subagents on a cheaper, faster model while the orchestrator stays on Opus — large token savings on subagent-heavy work. |
CLAUDE_CODE_TASK_LIST_ID | Share a named task list across sessions (stored under ~/.claude/tasks/). |
CLAUDE_CODE_AUTO_COMPACT_WINDOW | Control when automatic compaction kicks in. |
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE | Set the percentage threshold that triggers auto-compaction. |
CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION | Toggle the greyed-out prompt suggestions; set to false to disable. |
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS | Set to 1 to disable all background-task functionality. |
Settings files & precedence
Settings load from user, project, and local scopes (control which with --setting-sources). A project-level .claude/settings.json is the place for team-shared config — for example a shared plansDirectory so everyone's plans land in the same spot after they clone the repo.
/clear between tasks, delegate exploration to subagents, and keep CLAUDE.md lean. Most waste is stale context — not the work itself.References
Claude Code ships updates frequently. When in doubt, these official sources are the source of truth.
- code.claude.com/docs — Overview
- Quickstart — your first real task, end to end.
- CLI reference — every command and flag.
- Memory & CLAUDE.md
- MCP integration
- Permission modes
- Interactive mode — shortcuts, vim, shell mode, /btw, task list.
- Checkpointing — rewind edits and restore states.
- Subagents & worktrees
- Common workflows & best practices
- Agent SDK — build custom agents.
- llms.txt — full machine-readable docs index.
- npm package