Claude Code — Complete Guide 2026
Claude Code is Anthropic's official agentic CLI that brings Claude directly into your terminal. It reads and edits files, runs shell commands, manages git, and navigates entire codebases — all through natural language. This guide covers everything from first install to advanced power-user workflows.
What Is Claude Code?
Unlike a chat interface, Claude Code is an autonomous agent that operates inside your project directory. It can plan and execute multi-step tasks, spawn parallel sub-agents, hook into your git workflow, and remember project context across sessions — without you having to copy-paste code back and forth.
Installation & Free Setup
Claude Code requires a Claude Pro ($20/mo) or Max subscription by default. But you can route it through OpenRouter's free models to use it at no cost — great for experimentation.
Standard Install
- Install via npm:
npm install -g @anthropic-ai/claude-code - Run
claudein your project directory - Sign in with your Anthropic account on first launch
Free Setup via OpenRouter
Create or edit .claude/settings.local.json in your project (gitignored by default):
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "any-string-here",
"ANTHROPIC_BASE_URL": "https://openrouter.ai/api",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "minimax/minimax-m2.5:free"
}
}
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Shift + Enter | New line without sending |
Shift + Tab | Cycle permission modes |
Ctrl + C | Cancel current operation |
Cmd/Meta + T | Toggle Extended Thinking |
Cmd/Meta + P | Open model picker |
Permission System
Claude Code uses a tiered approach so you're never surprised by unexpected file changes:
- Read-only tools (file reads, grep, glob) — no approval needed
- File edits — approved per session
- Bash commands — approved per project
Permission mode is set in .claude/settings.json (shared via git) or ~/.claude/settings.json (personal). Modes: default, plan (read-only analysis), auto (AI decides), acceptEdits (auto-approve file edits).
Essential Slash Commands
| Command | Purpose |
|---|---|
/init | Initialize project — creates CLAUDE.md |
/compact | Compress conversation context |
/clear | Wipe context and start fresh |
/diff | Interactive diff viewer |
/model | Switch between Opus / Sonnet |
/plan | Plan before coding |
/memory | Manage saved context |
CLAUDE.md — Project Memory
Claude Code reads CLAUDE.md at the start of every session. Think of it as a permanent briefing document for the AI. Include:
- Tech stack and versions
- Build and test commands
- Architecture overview
- Code style rules
- Any project-specific constraints
Keep it under 200 lines. For larger projects, split rules into .claude/rules/ files. Run /init to generate a starter version automatically.
Hooks — Automation at Every Step
Hooks let you run shell commands at specific lifecycle points. Configure them in settings.json:
- PreToolUse — runs before a tool call; exit code 2 blocks the action
- PostToolUse — runs after success (auto-format, lint, run tests)
- Notification — desktop alerts when Claude needs input
Example: auto-run prettier after every file edit, or eslint --fix after JS changes.
MCP Servers
Model Context Protocol servers extend Claude Code with external integrations — browsers, databases, APIs, design tools. Add one with:
claude mcp add --transport stdio playwright -- npx @playwright/mcp@latest
Install plugins from the marketplace with /plugin install. Popular MCP servers: Playwright (browser automation), Figma, Postgres, filesystem extensions.
Model Selection
| Model | Best for | Cost |
|---|---|---|
| Opus 4.6 | Complex, multi-step tasks | $$$ |
| Sonnet 4.6 | Daily coding (recommended default) | $$ |
| MiniMax M2.7 | Strong coding, budget-friendly | $ |
| DeepSeek V3 | Simple tasks, cheapest option | ¢ |
Use /model to switch mid-session. Non-Anthropic models require routing through CC Switch or OpenRouter as shown in the free setup above.
Recommended Workflow
The three pillars of effective Claude Code use:
- Modular structure — split files at ~300 lines so Claude has focused context
- One task per session — plan → code → test → commit →
/clear - Understand before prompting — know the building blocks of what you're asking
Power Prompts
Force planning before coding
"Analyze the structure, list every file you'll touch, explain the changes you plan to make, then wait for my approval before writing any code."
Root-cause debugging
"Find the root cause of this bug — don't just fix the symptom. Explain exactly what's wrong, fix it properly, then run the tests."
Parallel sub-agents
"Split this into 3 independent tasks and run them in parallel using sub-agents: [task A], [task B], [task C]."
Clarify before starting
End any complex prompt with: "Ask me any clarifying questions before you start." This prevents Claude from making wrong assumptions on large tasks.
IDE Integration
Claude Code integrates with VS Code, Cursor, JetBrains IDEs (IntelliJ, PyCharm, WebStorm), and any terminal. In VS Code, install the Claude Code extension for inline diffs and a dedicated panel. In Cursor, it works alongside Cursor's own AI features.
Custom Commands & Skills
Skills (recommended): Markdown files at .claude/skills/name/SKILL.md with YAML frontmatter. They auto-trigger based on context and can bundle resources.
Legacy commands: Still supported at .claude/commands/. Use $ARGUMENTS to accept input when invoked via /command-name.
Frequently Asked Questions
Does Claude Code require a paid subscription?
Yes — by default it requires Claude Pro ($20/mo) or Max. The free workaround via OpenRouter (described above) works well for lighter use.
What happens when context gets full?
Claude Code auto-compacts when the context window fills. You can also run /compact manually to summarize the conversation, or /clear to start fresh (losing history but freeing all context).
Can I use it without an internet connection?
No — Claude Code requires a connection to the model API. For local/offline use, consider routing to a local model via Ollama or LM Studio through the ANTHROPIC_BASE_URL override.
Is it safe to use on sensitive codebases?
The permission system gives you full control. Use plan mode for read-only analysis, review every bash command before approval, and keep secrets in gitignored settings.local.json.
Browse all AI coding tools at aistro.online · See also: Best AI Coding Assistants 2026 · Cursor vs GitHub Copilot