Two years ago, AI coding assistants lived inside your IDE — autocompleting lines, suggesting snippets, occasionally getting things right. In 2026, the game has fundamentally changed. Claude Code dropped the IDE training wheels entirely and moved straight into your terminal, where it reads your entire codebase, edits files across your project, runs commands, creates commits, and even opens pull requests — all from natural language instructions.
Whether you're a seasoned developer looking to 10x your workflow or someone just getting started with AI-powered coding, this guide walks you through everything you need to know about Claude Code. By the end of this 45-minute read, you'll go from installation to advanced automation workflows, with real examples at every step.
Claude Code is Anthropic's terminal-native agentic coding tool. It understands your entire codebase, edits multiple files, runs terminal commands, manages Git workflows, and integrates with external tools via MCP — all through natural language. This guide covers installation, core commands, workflows, CLAUDE.md configuration, MCP integration, security, and advanced automation tips.
What you'll learn:
- How to install and configure Claude Code on any platform
- Essential commands and keyboard shortcuts
- Core workflows: coding, debugging, testing, Git, and PR creation
- Advanced features: CLAUDE.md, custom commands, MCP, headless mode
- Security and permission management
- Cost optimization strategies
- How Claude Code compares to Cursor, GitHub Copilot, and other tools
Prerequisites:
- A terminal or command prompt
- Basic familiarity with the command line
- A Claude subscription (Pro, Max, Teams, or Enterprise) or Anthropic Console account
- A code project to work with
Estimated time to complete each section:
| Section | Time |
|---|---|
| Installation & Setup | 5 min |
| Essential Commands | 5 min |
| Core Workflows | 15 min |
| Advanced Features | 10 min |
| Permissions & Security | 5 min |
| Real-World Example | 5 min |
What Is Claude Code? Why Should You Care?
Before diving into the tutorial, let's establish what makes Claude Code different from the dozen other AI coding tools on the market.
Claude Code is Anthropic's agentic coding tool — and that word "agentic" is key. Unlike traditional code assistants that react to your cursor position with suggestions, Claude Code operates as an autonomous agent. You describe what you want in plain English, and it figures out the plan: which files to read, what changes to make, which commands to run, and in what order.
How It Works
At its core, Claude Code runs an agentic loop:
- You provide a task in natural language
- Claude analyzes your codebase, reading relevant files
- Claude plans the approach (you can review this in Plan Mode)
- Claude executes — editing files, running commands, creating commits
- You review and approve the changes
This loop runs in your terminal, with Claude having direct access to your filesystem and command line — within the permission boundaries you set.
What Sets It Apart
| Feature | Claude Code | Traditional AI Assistants |
|---|---|---|
| Environment | Terminal-native | IDE plugins |
| Context | Reads entire codebase | Current file + limited context |
| Editing | Multi-file autonomous edits | Single-file suggestions |
| Commands | Executes terminal commands | No terminal access |
| Git | Full Git workflow automation | Limited or none |
| Extensibility | MCP, hooks, custom commands | Plugin marketplace |
Where Claude Code Shines
- Reads and understands your entire project structure
- Edits multiple files in a single operation
- Runs tests, build commands, and scripts directly
- Automates Git workflows (commits, branches, PRs)
- Works across 6 platforms: Terminal, VS Code, JetBrains, Desktop, Web, Slack
- Extensible via MCP, hooks, and custom commands
- Supports parallel sessions with Git worktrees
- Requires a paid subscription (no free tier for terminal use)
- Terminal-first UX has a learning curve for non-CLI users
- Token consumption can add up on large codebases
- Requires internet connection (no offline mode)
- Currently in active development — features change rapidly
Pricing Overview
| Plan | Price | Best For |
|---|---|---|
| Pro | $20/month | Individual developers, light usage |
| Max (5x) | $100/month | Regular users, moderate daily usage |
| Max (20x) | $200/month | Power users, heavy daily usage |
| Teams | $30/user/month | Small to medium teams |
| Enterprise | Custom | Large organizations with security needs |
| API (Console) | Pay-per-use | CI/CD, automation, custom integrations |
You can also access Claude Code through Amazon Bedrock, Google Vertex AI, or Microsoft Foundry if your organization uses these cloud providers.
Who Is Claude Code For?
Claude Code isn't for everyone — and that's by design. Here's who gets the most value:
- Backend developers who spend most of their time in the terminal
- Full-stack engineers building features that span multiple files and layers
- DevOps/Platform engineers who need to automate repetitive tasks
- Tech leads who review PRs, manage Git workflows, and maintain code quality
- Open-source maintainers who need to triage issues and generate documentation
Installation & Setup
Getting Claude Code running takes about 5 minutes. Here's how to do it on every supported platform.
System Requirements
- macOS: 10.15 Catalina or later
- Linux: Ubuntu 20.04+, Debian 10+, or equivalent
- Windows: Windows 10+ with WSL2, or native support via installer
- Node.js: Not required for native install (self-contained binary)
Choose the installation method that fits your system:
macOS / Linux (Recommended — Native Install):
curl -fsSL https://claude.ai/install.sh | bash
Windows (PowerShell):
irm https://claude.ai/install.ps1 | iex
Windows (CMD):
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
macOS via Homebrew:
brew install --cask claude-code
Windows via WinGet:
winget install Anthropic.ClaudeCode
To verify the installation:
claude --version
Launch Claude Code for the first time:
claude
You'll be prompted to log in. Choose your authentication method:
- Claude Pro/Max/Teams/Enterprise (recommended) — Log in with your claude.com account
- Anthropic Console — Use pre-paid API credits. A "Claude Code" workspace is automatically created for cost tracking
- Third-party providers — Amazon Bedrock, Google Vertex AI, or Microsoft Foundry
If you need to switch accounts later, use:
/login
Navigate to your project directory and launch:
cd /path/to/your/project
claude
Claude Code will start an interactive session. You should see a prompt where you can type natural language instructions.
Try your first command:
what does this project do?
Claude will scan your project structure, read key files, and give you a summary. Other useful first commands:
explain the folder structure
what technologies does this project use?
where is the main entry point?
Claude Code also works inside your IDE. Install the extension for:
- VS Code / Cursor: Search "Claude Code" in the Extensions marketplace, or press
Cmd+Shift+P→ "Claude Code: Open" - JetBrains: Install the Claude Code plugin from the marketplace
- Desktop App: Download from claude.com for macOS or Windows
- Web: Visit claude.ai/code to use it in your browser
All surfaces share the same engine — your CLAUDE.md files, settings, and MCP servers work across all of them.
While Claude Code now has native Windows support, the experience is best on macOS and Linux. Windows users should consider running Claude Code inside WSL2 (Windows Subsystem for Linux) for full compatibility with Unix-based toolchains and shell commands. The native Windows installer works well for basic use, but some advanced features like Git worktrees and certain MCP servers may have edge cases on Windows.
To install in WSL2:
# Inside your WSL2 terminal
curl -fsSL https://claude.ai/install.sh | bash
Verifying Your Setup
Before moving on, make sure everything is working:
# Check installation
claude --version
# Check authentication
claude -p "say hello"
# Check project access
cd /path/to/your/project
claude -p "list the top-level files in this project"
If all three commands succeed, you're ready to start using Claude Code for real work. If you encounter issues, run /doctor inside a Claude Code session for automated diagnostics.
Getting Started: Essential Commands
Now that Claude Code is installed, let's master the commands you'll use every day.
Launch Modes
# Interactive mode — start a conversation
claude
# Quick task — run a single task and return
claude "fix the build error in src/app.ts"
# Print mode — non-interactive, output to stdout
claude -p "explain the authentication flow"
# Continue last session
claude -c
# Resume with session picker
claude -r
# Start with a specific task
claude commit
Slash Commands
Once inside an interactive session, slash commands control Claude Code's behavior:
| Command | Description |
|---|---|
/help |
Show all available commands |
/clear |
Clear conversation context |
/compact |
Compress context to save tokens |
/status |
Show current session status |
/cost |
Show token usage and cost |
/login |
Switch authentication |
/model |
Switch AI model |
/agents |
View and manage subagents |
/hooks |
Configure automation hooks |
/review |
Review recent code changes |
/pr-comments |
Address PR review comments |
/init |
Initialize CLAUDE.md for your project |
/terminal-setup |
Configure terminal integration |
/doctor |
Diagnose common issues |
/teleport |
Pull a web/mobile session into terminal |
/desktop |
Hand off session to Desktop app |
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
? |
Show all keyboard shortcuts |
Tab |
Command/file completion |
↑ |
Command history |
/ |
Open command palette |
Ctrl+O |
Toggle extended thinking mode |
Ctrl+C |
Cancel current operation |
Esc |
Dismiss, go back |
Understanding the Permission Prompt
When Claude Code wants to perform an action that could modify your system, you'll see a permission prompt like this:
Claude wants to run: npm test
Allow? [y]es / [n]o / [a]lways allow / [d]eny always
Here's what each option does:
- y (yes) — Allow this one time. Claude proceeds, but will ask again next time.
- n (no) — Block this action. Claude will try an alternative approach.
- a (always allow) — Auto-approve this exact action for the rest of the session. Great for repetitive commands like
npm test. - d (deny always) — Permanently block this action pattern. Useful for destructive commands you never want to run.
The permission system is your safety net. In the early days, take time to read each prompt before approving. As you build trust with Claude Code's behavior on your project, you can pre-configure allowlists in .claude/settings.json (covered in the Permissions & Security section) to skip prompts for safe commands.
For commands you trust (like running tests, linting, or git operations), use the "always allow" option. This dramatically speeds up your workflow without compromising safety. You can also pre-configure these in your project settings:
{
"permissions": {
"allow": ["Bash(npm test)", "Bash(npm run lint)", "Bash(git *)"]
}
}
Reference specific files or directories in your prompts with the @ prefix:
Explain the logic in @src/utils/auth.js
What's the structure of @src/components?
Compare @package.json and @package-lock.json
When you use @ references, Claude automatically loads the corresponding CLAUDE.md files in that file's directory and parent directories for additional context.
Core Workflows: What You'll Do Every Day
This is where Claude Code earns its keep. Let's walk through the five workflows that make up 90% of daily usage.
Workflow 1: Writing & Generating Code
The most common use case — describe what you want, and Claude builds it.
Simple function generation:
create a utility function that validates email addresses using regex,
handles edge cases, and includes JSDoc documentation
Multi-file feature implementation:
1. create a new database table for user profiles
2. create an API endpoint to get and update user profiles
3. build a webpage that allows users to see and edit their information
Claude will:
- Analyze your existing project structure and conventions
- Create or modify multiple files
- Show you a diff of proposed changes
- Wait for your approval before writing
Full-stack feature with database, API, and UI:
Build a complete "user notifications" feature:
1. Create a notifications table in the database with columns:
id, user_id, type, title, message, read, created_at
2. Create a NotificationService in src/services/ with methods:
create, markAsRead, getUnread, getAll
3. Add REST endpoints: GET /api/notifications, PATCH /api/notifications/:id/read
4. Build a notification bell component in React that shows unread count
and a dropdown with the latest 10 notifications
5. Add WebSocket support so new notifications appear in real-time
6. Write tests for the service and API layers
This kind of multi-layered prompt is where Claude Code's agentic approach truly outperforms autocomplete-style tools. Claude plans the entire feature across database, backend, and frontend layers, ensuring consistency between them — something that's difficult when you're generating code one file at a time.
Generating boilerplate for repetitive patterns:
I need CRUD endpoints for these 4 resources: products, categories, reviews, and wishlists.
Follow the exact same patterns as the existing users resource in @src/routes/users.ts,
@src/services/userService.ts, and @src/repositories/userRepository.ts.
Include validation, error handling, and pagination for list endpoints.
Claude reads the reference implementation once, then applies the same pattern four times — adapting table names, field types, and validation rules for each resource. This is dramatically faster than copy-pasting and modifying boilerplate manually.
The more detail you provide, the better the output. Instead of "add authentication", try:
add JWT-based authentication using the existing Express app in src/server.ts.
Use bcrypt for password hashing, create a /api/auth/login and /api/auth/register endpoint,
and store tokens in HTTP-only cookies. Follow the patterns in @src/routes/users.ts
Reference existing files with @ to help Claude match your project's patterns.
Workflow 2: Understanding & Navigating Code
When you're joining a new project or exploring unfamiliar code, Claude Code acts as your guide.
Get a project overview:
what does this project do?
explain the architecture and key design decisions
Trace execution flow:
trace the request flow from when a user clicks "Submit Order"
to when the order confirmation email is sent
Find relevant code:
find all places where we handle user authentication
where is the database connection configured?
which components use the useAuth hook?
Claude uses agentic search to explore your codebase — it doesn't just grep for strings. It reads imports, follows function calls, and understands the relationships between files.
Understand a specific file in depth:
explain @src/middleware/auth.ts line by line.
What edge cases does this code handle? What could go wrong?
Compare approaches:
compare the error handling approach in @src/routes/users.ts
vs @src/routes/orders.ts. Which is better and why?
This is especially powerful when onboarding to a new team — instead of spending days reading code, you can have a guided conversation with Claude about the architecture, patterns, and potential issues.
Workflow 3: Fixing Bugs
Bug fixing is where Claude Code really shines. Instead of spending 30 minutes tracing a stack trace, paste it in and let Claude handle it.
Share the error:
I'm seeing this error when running npm test:
TypeError: Cannot read properties of undefined (reading 'map')
at UserList (/src/components/UserList.tsx:15:23)
at renderWithHooks (/node_modules/react-dom/...)
Claude will:
- Read the file mentioned in the stack trace
- Understand the surrounding context
- Identify the root cause
- Propose a fix with explanation
- Apply the fix after your approval
Always paste error messages in their original English form, even if you're working in a different language. This helps Claude match exact error patterns and makes it easier for you to search for solutions later.
Reproduce and fix automatically:
run npm test, find any failing tests, and fix them
Claude will execute the test suite, parse the output, identify failures, read the relevant source code, and apply fixes — iterating until tests pass.
Debug complex issues step by step:
The checkout page shows a blank screen on mobile devices but works fine on desktop.
1. Check the responsive CSS and media queries in the checkout components
2. Look for any JavaScript errors that might be viewport-dependent
3. Check if any third-party scripts block rendering on mobile
4. Suggest and apply fixes
Fix from a git diff:
review the changes in my last commit and check if I introduced any bugs
Claude reads the diff, cross-references the changed code with the rest of the codebase, and flags potential issues — catching things like missing null checks, broken imports, or logic errors that automated linters miss.
Workflow 4: Testing
Claude Code can build your entire test suite from scratch or fill in gaps in existing coverage.
Find untested code:
find functions in the auth module that don't have test coverage
Generate tests:
write comprehensive unit tests for src/services/payment.ts
including edge cases and error scenarios
Test-driven development:
1. write a failing test for a function that calculates shipping costs
based on weight, distance, and delivery speed
2. implement the function to make the test pass
3. add edge case tests for invalid inputs
4. run all tests and fix any failures
Claude follows the red-green-refactor cycle naturally. It writes the test first, implements the minimum code to pass, then refactors.
Run and iterate:
run the new tests and fix any failures
Integration and end-to-end testing:
write integration tests for the user registration flow that test:
1. successful registration with valid data
2. duplicate email rejection
3. weak password rejection
4. email verification token generation
Use the existing test database setup in @tests/setup.ts
Coverage analysis:
analyze the test coverage for the src/services/ directory.
Which functions have no tests? Which have only happy-path tests?
Prioritize by risk and suggest which tests to add first.
Claude can also run your coverage tool (like istanbul or c8), parse the output, and generate tests specifically targeting uncovered branches and edge cases.
Workflow 5: Git & Pull Requests
Claude Code handles the entire Git workflow — from staging changes to creating pull requests.
Smart commits:
commit my changes with a descriptive message
Claude analyzes the diff, understands the semantic meaning of your changes, and generates a meaningful commit message — not just "update files".
Branch management:
create a new branch called feature/user-profiles
what files have I changed?
show me the last 5 commits
help me resolve merge conflicts
Pull request creation:
create a pr
Claude will:
- Summarize all changes across files
- Generate a descriptive PR title and body
- Include context about what changed and why
- Use
gh pr createto push the PR to GitHub
Code review from a PR:
# Start Claude from an existing PR
claude --from-pr 42
This loads the PR diff as context, letting you review, comment, or request changes.
Address PR review comments:
/pr-comments
Claude reads the review comments on your open PR and helps you address each one — making code changes, responding to feedback, and pushing updates.
Cherry-pick and backport:
cherry-pick the fix from commit abc123 into the release/2.1 branch
and resolve any merge conflicts
Rebase and clean up history:
interactive rebase the last 5 commits into 2 logical commits:
one for the database migration and one for the API changes
Claude handles the complex Git operations that most developers dread — rebasing, conflict resolution, and history cleanup — with clear explanations of what it's doing and why.
Here's a typical session combining multiple Git operations:
> create a new branch called feature/add-search
> add fuzzy search to the product listing page using Fuse.js
> write tests for the search functionality
> run the tests and fix any failures
> commit my changes with a descriptive message
> create a pr with a detailed description
Claude handles all six steps sequentially, maintaining context across the entire workflow.
Advanced Features
Once you've mastered the basics, these features take your productivity to the next level.
CLAUDE.md: Your Project's AI Configuration
CLAUDE.md is the single most impactful feature for improving Claude Code's output quality. It's a Markdown file that tells Claude about your project — and it reads it automatically at the start of every session.
Project-level CLAUDE.md (in your project root):
# Project: E-commerce API
## Tech Stack
- Node.js 20 + TypeScript 5.4
- Express.js with Zod validation
- PostgreSQL + Prisma ORM
- Jest for testing
## Coding Conventions
- Use functional components and hooks (no class components)
- All API responses follow the { data, error, meta } pattern
- Error handling uses custom AppError class in src/utils/errors.ts
- All database queries go through the repository pattern in src/repositories/
## Commands
- `npm run dev` — start development server
- `npm test` — run all tests
- `npm run lint` — run ESLint
- `npm run build` — production build
## Architecture
- src/routes/ — Express route handlers
- src/services/ — business logic
- src/repositories/ — database access
- src/middleware/ — Express middleware
- src/utils/ — shared utilities
## Important Notes
- Always use parameterized queries, never string interpolation for SQL
- API endpoints must have rate limiting middleware
- All new endpoints need integration tests in tests/integration/
User-level CLAUDE.md (~/.claude/CLAUDE.md):
# Personal Preferences
- Use TypeScript strict mode
- Prefer const over let
- Use early returns instead of nested if/else
- Write concise commit messages in conventional commit format
- Always add JSDoc comments to public functions
- Start with
/init— Claude Code generates a starter CLAUDE.md based on your project - Be specific — "Use Prisma" is less helpful than "Use Prisma ORM with the schema at prisma/schema.prisma"
- Include commands — Tell Claude how to run tests, lint, build, and deploy
- Document patterns — Show Claude your conventions so it follows them
- Keep it updated — Add notes as your project evolves
- Use directory-level files — Add
CLAUDE.mdin subdirectories for context specific to that area
Hooks: Automate Workflows on Events
Hooks let you run custom scripts when specific events happen in Claude Code — like when Claude asks for permission, finishes a task, or encounters an error.
Set up hooks via the interactive menu:
/hooks
Available hook events:
| Event | When It Triggers |
|---|---|
permission_prompt |
Claude asks for permission to act |
idle_prompt |
Claude is waiting for your input |
auth_success |
Authentication completes |
elicitation_dialog |
Claude needs additional information |
Example: Desktop notifications when Claude needs attention (macOS):
osascript -e 'display notification "Claude Code needs your attention" with title "Claude Code"'
Example: Desktop notifications on Linux:
notify-send 'Claude Code' 'Claude Code needs your attention'
Example: Play a sound when a long task finishes:
afplay /System/Library/Sounds/Glass.aiff
Hooks are saved in your user settings, so they persist across sessions and projects. You can also create project-specific hooks for team workflows — like automatically running linters after Claude edits a file, or sending a Slack notification when a PR is created.
Custom Slash Commands (Skills)
You can create reusable commands that appear in the / menu:
Project-level custom command (.claude/commands/review-pr.md):
Review the current PR changes for:
1. Security vulnerabilities (SQL injection, XSS, CSRF)
2. Performance issues (N+1 queries, missing indexes)
3. Error handling gaps
4. Test coverage for new code
5. Adherence to our coding standards in CLAUDE.md
Output a structured review with severity levels (critical/warning/info).
Now you can run /review-pr in any session and Claude executes this workflow.
User-level custom command (~/.claude/commands/daily-standup.md):
Analyze the git log for the last 24 hours and generate a standup summary:
- What was completed yesterday
- What files were modified
- Any pending TODOs or FIXMEs added
Subagents
Claude Code can spawn specialized sub-agents for complex tasks:
> /agents
This shows available agents. Claude automatically delegates to subagents when appropriate — for example, using a code-reviewer subagent for security analysis.
Create custom subagents in .claude/agents/:
{
"id": "api-designer",
"description": "Designs RESTful API endpoints following our conventions",
"tools": ["Read", "Grep", "Glob", "AskUserQuestion"],
"systemPrompt": "You are an API design specialist. Follow REST best practices and the conventions in CLAUDE.md..."
}
MCP (Model Context Protocol) Integration
MCP is an open standard that lets Claude Code connect to external tools and data sources beyond your local filesystem.
Configure MCP servers in your project's .mcp.json:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "your-token-here"
}
},
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgresql://localhost:5432/mydb"
}
},
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/docs"]
}
}
}
With MCP configured, you can:
> Show me the data from @github:repos/owner/repo/issues
> Query the database for users who signed up this week
> Search the documentation for authentication patterns
Common MCP servers:
| Server | Purpose |
|---|---|
server-github |
Access GitHub repos, issues, PRs |
server-postgres |
Query PostgreSQL databases |
server-filesystem |
Access files outside project directory |
server-slack |
Read/send Slack messages |
server-puppeteer |
Browser automation |
server-memory |
Persistent key-value storage |
MCP servers run with the same permissions as your user account. Be careful with database access tokens and API keys. Store sensitive values in environment variables, not directly in .mcp.json.
Headless Mode & CI/CD Integration
Claude Code isn't just for interactive use. The -p (print) flag enables non-interactive mode, perfect for automation.
Basic headless usage:
# Explain a function
claude -p "explain the main function in src/index.ts"
# Generate code and output to file
claude -p "generate a migration to add a status column to orders" > migration.sql
# Pipe input for analysis
git diff main | claude -p "review these changes for security issues"
# Monitor logs
tail -f app.log | claude -p "alert me if you see any anomalies"
GitHub Actions integration:
name: Claude Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Claude Code
run: curl -fsSL https://claude.ai/install.sh | bash
- name: Review PR
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
git diff origin/main...HEAD | claude -p "Review this diff for bugs, security issues, and code style problems. Output in GitHub-compatible markdown."
SDK integration for building custom tools:
// TypeScript SDK
import { ClaudeCode } from "@anthropic-ai/claude-code";
const claude = new ClaudeCode();
const result = await claude.run({
prompt: "analyze the test coverage and suggest missing tests",
workingDirectory: "./my-project",
});
console.log(result.output);
Extended Thinking Mode
For complex problems that need deeper reasoning, toggle extended thinking:
- Keyboard shortcut:
Ctrl+Oduring a session - CLI flag: Available through model configuration
Extended thinking gives Claude more "thinking time" before responding, improving accuracy on:
- Complex refactoring across many files
- Architecture decisions
- Debugging subtle race conditions
- Optimization problems
Git Worktrees: Parallel Sessions
Need to work on multiple features simultaneously? Use Git worktrees:
# Start Claude in a named worktree
claude --worktree feature-auth
# Start another parallel session
claude --worktree bugfix-123
# Auto-generate a worktree name
claude --worktree
Each worktree gets its own branch and working directory at <repo>/.claude/worktrees/<name>, so you can run multiple Claude Code sessions without conflicts.
Plan Mode: Safe Analysis
When you want Claude to analyze without making changes:
> use plan mode to analyze the database schema and suggest optimizations
In Plan Mode, Claude can only read files and ask you questions — it cannot edit files or run commands. This is useful for:
- Architecture reviews
- Security audits
- Performance analysis
- Learning a new codebase
You can set Plan Mode as the default in your settings if you prefer a review-first workflow.
Remote Control & Cross-Device Workflows
One of Claude Code's most unique features is the ability to work across devices seamlessly.
Start a task on the web, finish in the terminal:
- Go to claude.ai/code and start a coding task from your browser or the iOS app
- When you're back at your desk, type
/teleportin your terminal session - The web session transfers into your terminal with full context
Hand off to the Desktop app for visual review:
/desktop
This transfers your current terminal session to the Claude Code Desktop app, where you get visual diff previews, file tree navigation, and a richer UI for reviewing changes.
Slack integration:
Mention @Claude in a Slack channel with a bug report, and Claude Code can create a pull request directly. This is powerful for team workflows where non-developers can report issues and get automated fixes.
Use cases for cross-device workflows:
- Start a long-running refactoring task on the web from your phone during a commute
- Review Claude's proposed changes in the Desktop app with visual diffs
- Have team members trigger automated fixes from Slack without touching the terminal
- Use the Chrome extension to send code from any webpage into a Claude Code session
Unix-Style Piping & Scripting
Claude Code works as a first-class Unix citizen. You can pipe data in, pipe data out, and chain it with other tools.
Pipe input for analysis:
# Review changed files for security issues
git diff main --name-only | claude -p "review these changed files for security issues"
# Analyze log files
tail -100 error.log | claude -p "what patterns do you see in these errors?"
# Process data
cat data.csv | claude -p "find anomalies in this CSV data and output a summary"
Pipe output to files or tools:
# Generate a migration and save it
claude -p "generate a SQL migration to add indexes to the users table" > migration.sql
# Generate documentation in a specific format
claude -p "generate API documentation for @src/routes/ in OpenAPI format" --output-format json > api-docs.json
Chain with other CLI tools:
# Find TODO comments and prioritize them
grep -rn "TODO" src/ | claude -p "prioritize these TODOs by severity and suggest an order to address them"
# Automated translation in CI
claude -p "translate the new strings in @src/locales/en.json into French and raise a PR for review"
This makes Claude Code invaluable for scripting, automation, and CI/CD pipelines where you need AI-powered analysis as part of a larger workflow.
Permissions & Security
Claude Code has direct access to your filesystem and terminal — which is exactly what makes it powerful. But it also means you need to understand the permission system.
Permission Model
When Claude Code wants to perform an action (edit a file, run a command, access the network), it asks for your permission. You have three ways to respond:
| Response | Behavior |
|---|---|
| Allow once | Permit this specific action |
| Allow always | Auto-approve this action type going forward |
| Deny | Block this action |
Configuring Permissions in settings.json
For more granular control, configure permissions in your project's .claude/settings.json:
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"AskUserQuestion",
"Bash(npm test)",
"Bash(npm run lint)",
"Bash(git *)"
],
"deny": ["Bash(rm -rf *)", "Bash(curl *)", "WebFetch"]
}
}
Permission Categories
| Category | What It Controls | Default |
|---|---|---|
| Read | Reading file contents | Auto-allowed |
| Edit | Modifying files | Requires approval |
| Bash | Running terminal commands | Requires approval |
| WebFetch | Making HTTP requests | Requires approval |
| MCP | Using MCP server tools | Requires approval |
For teams and enterprise environments:
- Use Teams/Enterprise plans with centralized permission policies
- Configure organization-wide
.claude/settings.jsontemplates - Enable audit logging for compliance
- Use Plan Mode by default for sensitive codebases
- Restrict Bash commands to a specific allowlist
Best Practices for Security
- Start restrictive — Only allow commands you actually need
- Use wildcards carefully —
Bash(git *)is safer thanBash(*) - Deny destructive commands — Always deny
rm -rf,DROP TABLE, etc. - Review before approving — Read Claude's proposed changes before accepting
- Use Plan Mode for audits — When reviewing sensitive code, use Plan Mode to prevent modifications
- Rotate API keys — If using MCP with external services, rotate keys regularly
Data Privacy Considerations
Understanding how Claude Code handles your code is important, especially in professional environments:
- Session-based processing — Claude Code processes your code during active sessions. It reads files on demand, not by uploading your entire codebase.
- No training on your code — According to Anthropic's usage policies, code processed through Claude Code on paid plans is not used to train models.
- Local execution — File edits and terminal commands execute locally on your machine. Claude sends instructions; your system runs them.
- Network requests — Claude Code only makes network requests when you approve them (via WebFetch or MCP tools). You can deny all network access in your permission settings.
- Enterprise controls — Enterprise plans offer additional data governance features including audit logging, data residency options, and centralized policy management.
For highly sensitive codebases, consider these additional measures:
- Use Plan Mode for initial analysis (read-only, no execution)
- Deny all Bash and WebFetch permissions, only allowing Read and Edit
- Review the
.claude/settings.jsonto ensure no unintended permissions are granted - Use environment-specific CLAUDE.md files to avoid leaking production credentials into prompts
Real-World Example: Building a CLI Tool with Claude Code
Let's put everything together with a practical example. We'll build a simple CLI tool for managing TODO items — from initialization to a working, tested application.
Start a new session:
mkdir todo-cli && cd todo-cli
claude
Give Claude the task:
Initialize a new Node.js project with TypeScript for a CLI tool called "todo-cli".
Set up the project with:
- TypeScript with strict mode
- Vitest for testing
- Commander.js for CLI argument parsing
- A src/ directory structure
- A proper tsconfig.json and package.json
Claude will create all the files, install dependencies, and set up the project structure.
/init
Then enhance the generated CLAUDE.md:
update CLAUDE.md to add:
- this is a CLI tool for managing TODO items stored in a local JSON file
- use Commander.js for all CLI commands
- all commands should have --json flag for machine-readable output
- tests should use Vitest with in-memory storage
- follow functional programming patterns, avoid classes
implement the core todo functionality:
1. add command - add a new todo with title and optional priority (low/medium/high)
2. list command - list all todos with filtering by status and priority
3. done command - mark a todo as completed by ID
4. remove command - delete a todo by ID
5. store todos in a local JSON file at ~/.todo-cli/todos.json
Each command should support a --json flag for machine-readable output.
Make sure to handle edge cases like missing files, invalid IDs, and empty lists.
Claude will create multiple files:
src/index.ts— CLI entry point with Commander.jssrc/commands/— Individual command handlerssrc/storage.ts— JSON file storage layersrc/types.ts— TypeScript interfaces
write comprehensive tests for all commands including:
- adding todos with various priorities
- listing with filters
- marking as done
- removing todos
- edge cases: invalid ID, empty list, corrupted file
- the --json output format
Use an in-memory storage mock so tests don't touch the filesystem.
run all tests and fix any failures
Claude will execute npx vitest run, read the output, identify any failures, and fix them — iterating until all tests pass.
1. add a colorful table output for the list command using chalk and cli-table3
2. add input validation with helpful error messages
3. add a --help description for every command and option
4. update the README with installation and usage instructions
5. add a "stats" command that shows completion rate and priority breakdown
commit all changes with a descriptive message, then create a PR
that describes the features, architecture decisions, and how to test
Claude generates a comprehensive commit message and PR description based on everything it built.
The result: A fully functional, tested CLI tool — built in a single Claude Code session. What might take 2-3 hours of manual coding takes about 15-20 minutes with Claude Code handling the boilerplate, edge cases, and test infrastructure.
What Makes This Workflow Powerful
This example demonstrates several key principles that apply to any project:
- Declarative, not procedural — You describe what you want, not how to build it. Claude figures out the file structure, import paths, and boilerplate.
- Iterative refinement — Each step builds on the previous one. Claude maintains context about what it already created, so step 6 references code from step 3.
- Test-first verification — By writing tests before polishing, you catch issues early and Claude can auto-fix failures.
- CLAUDE.md as project memory — After running
/initand adding your conventions, every subsequent command produces output that's consistent with your project's patterns. - Git as a safety net — Frequent commits mean you can always roll back if something goes wrong. Claude's auto-generated commit messages make the history readable.
You can apply this same pattern to any project: REST APIs, React applications, microservices, data pipelines, or CLI tools. The key is breaking the work into clear, sequential steps and letting Claude handle the implementation details.
Tips & Best Practices
After working extensively with Claude Code, here are the strategies that consistently produce the best results.
Prompting Strategies
❌ "fix the bug" ✅ "fix the TypeError in src/components/UserList.tsx where users array might be undefined when the API returns empty data"
❌ "add a feature" ✅ "add a search feature to the product listing page that filters by name and category, following the same patterns as the existing user search in @src/components/UserSearch.tsx"
❌ "build the whole thing" ✅ "1. create the database schema 2. create the API endpoints 3. build the frontend components 4. write tests for each layer"
❌ Jump straight into "change X in file Y" ✅ "analyze the authentication flow first, then suggest improvements" — let Claude understand before it acts
Context Management
Long sessions consume tokens and can cause Claude to lose focus. Here's how to manage context effectively:
- Use
/compactregularly — Compresses the conversation to save tokens while preserving key context - Start focused sessions — One task per session produces better results than a marathon session
- Reference files explicitly — Use
@filenameinstead of describing file contents - Use
/clearfor topic switches — When changing tasks, clear the context to avoid confusion - Name your sessions — Use descriptive session names for easy resumption with
/resume
Cost Optimization
| Strategy | Impact | How |
|---|---|---|
| Use Max plan | High | Unlimited usage eliminates per-token worries |
| Be specific | Medium | Reduces back-and-forth, fewer tokens per task |
Use /compact |
Medium | Compresses context, reduces token count |
| Batch related tasks | Medium | Context reuse across related changes |
Use -p for simple queries |
Low | Avoids session overhead for one-off questions |
Monitor with /cost |
Low | Awareness helps you adjust behavior |
Common Pitfalls to Avoid
- Don't approve without reading — Always review Claude's proposed changes before accepting
- Don't ignore test failures — If Claude's changes break tests, fix them before moving on
- Don't skip CLAUDE.md — 5 minutes of setup saves hours of corrections
- Don't use overly broad prompts — "Refactor everything" will produce inconsistent results
- Don't forget to commit frequently — Smaller, more frequent commits make it easier to revert if needed
- Don't share API keys in prompts — Use environment variables for sensitive data
Team Workflow Tips
When using Claude Code across a team:
- Standardize CLAUDE.md — Keep it in version control so everyone gets the same context
- Share custom commands — Put team-specific
/commandsin.claude/commands/and commit them - Define shared agents — Create team subagents in
.claude/agents/for consistent workflows - Set up CI integration — Use headless mode in your CI pipeline for automated review
- Document MCP configurations — Share
.mcp.jsontemplates with the team (but not secrets)
Advanced Prompt Patterns
Beyond basic tips, these advanced patterns unlock Claude Code's full potential:
The "Analyze Then Act" pattern:
First, analyze the current authentication implementation in @src/auth/.
Then, identify any security vulnerabilities.
Finally, fix the issues you found, prioritizing by severity.
This three-phase approach — understand, diagnose, fix — consistently produces better results than jumping straight to "fix the auth."
The "Reference Implementation" pattern:
Look at how pagination is implemented in @src/routes/users.ts.
Now implement the same pagination pattern for @src/routes/products.ts
and @src/routes/orders.ts.
By pointing Claude to a reference file, you ensure consistency across your codebase without repeating detailed specifications.
The "Constraint-First" pattern:
Refactor the payment service with these constraints:
- Must maintain backward compatibility with the existing API
- Must not change the database schema
- Must keep all existing tests passing
- Should reduce code duplication by at least 50%
Defining constraints upfront prevents Claude from making sweeping changes that break other parts of your system.
The "Rubber Duck" pattern:
I'm trying to decide between using Redis and PostgreSQL for our session store.
Walk me through the tradeoffs for our specific use case:
- 10,000 daily active users
- Sessions need to persist for 30 days
- We already run PostgreSQL but not Redis
- Our infrastructure is on AWS
Claude Code excels at this kind of contextual analysis because it can read your actual codebase, check your dependencies, and factor in your specific technical context — not just give generic advice.
The "Documentation-Driven Development" pattern:
1. Write the API documentation for a new /api/v2/notifications endpoint
including request/response schemas, error codes, and examples
2. Generate the implementation based on the documentation
3. Write tests that validate the implementation matches the docs
Starting with docs forces Claude to think through the design before coding, resulting in cleaner APIs.
Claude Code vs the Competition
How does Claude Code stack up against other AI coding tools? Here's an honest comparison based on real usage.
Feature Comparison
| Feature | Claude Code | Cursor | GitHub Copilot | Windsurf | Aider |
|---|---|---|---|---|---|
| Environment | Terminal + IDE + Web | IDE (VS Code fork) | IDE plugin | IDE (VS Code fork) | Terminal |
| Agentic editing | ✅ Full | ✅ Full | ✅ Agent mode | ✅ Full | ✅ Full |
| Multi-file edits | ✅ | ✅ | ✅ | ✅ | ✅ |
| Terminal commands | ✅ Native | ✅ Integrated | ✅ In IDE | ✅ Integrated | ✅ Native |
| Git automation | ✅ Full workflow | ⚠️ Basic | ⚠️ Basic | ⚠️ Basic | ✅ Good |
| MCP support | ✅ | ✅ | ❌ | ✅ | ❌ |
| Custom commands | ✅ Skills system | ✅ Rules | ⚠️ Limited | ✅ Rules | ❌ |
| CI/CD mode | ✅ Headless | ❌ | ✅ Copilot CLI | ❌ | ✅ |
| Desktop app | ✅ | N/A (is desktop) | N/A | N/A (is desktop) | ❌ |
| Web interface | ✅ | ❌ | ❌ | ❌ | ❌ |
| Mobile access | ✅ Remote Control | ❌ | ❌ | ❌ | ❌ |
| Free tier | ❌ | ✅ Limited | ✅ Limited | ✅ Limited | ✅ (BYOK) |
| Starting price | $20/month | $20/month | $10/month | $15/month | Free (API costs) |
When to Choose Claude Code
- You live in the terminal — Claude Code is built for terminal-first developers. If you prefer CLI over GUI, this is your tool.
- You need Git automation — No other tool matches Claude Code's end-to-end Git workflow (branch → code → test → commit → PR).
- You want multi-platform access — Terminal, VS Code, JetBrains, Desktop, Web, Slack, and mobile. No other tool offers this breadth.
- You need CI/CD integration — Headless mode with
-pis purpose-built for automation pipelines. - You want extensibility — MCP, hooks, custom commands, and subagents provide a complete customization layer.
When to Choose Alternatives
- You want a visual IDE experience — Cursor and Windsurf offer rich visual diff previews, inline suggestions, and GUI-driven workflows that Claude Code's terminal interface doesn't match.
- You're on a budget — GitHub Copilot starts at $10/month and Aider is free (you pay only for API usage).
- You need offline access — None of these tools work fully offline, but IDE-based tools can still function for basic editing without AI.
- You prefer inline suggestions — If you mainly want autocomplete-style suggestions as you type, Copilot and Cursor are more fluid.
Head-to-Head: Claude Code vs Cursor
Since Cursor is the most popular AI IDE and Claude Code's closest competitor, here's a deeper comparison:
| Aspect | Claude Code | Cursor |
|---|---|---|
| UX paradigm | Conversation-driven — you describe tasks in natural language | Hybrid — inline suggestions + chat panel + Composer for multi-file |
| Context window | Reads files on demand via agentic search; entire codebase accessible | Indexes codebase for @-mentions; limited by model context |
| Multi-file edits | Native — Claude plans and edits across files in one pass | Composer mode — multi-file edits with visual diff preview |
| Learning curve | Steeper — requires terminal comfort and prompt crafting skill | Gentler — familiar VS Code interface with AI overlay |
| Customization | CLAUDE.md + custom commands + hooks + MCP + subagents | .cursorrules + custom instructions |
| Best for | Complex refactoring, Git automation, CI/CD, terminal-native developers | Real-time coding assistance, visual workflows, IDE-native developers |
The bottom line: Cursor excels at real-time coding assistance within the IDE. Claude Code excels at autonomous task execution across your entire project. Many power users run both — Cursor for moment-to-moment coding, Claude Code for larger tasks like "refactor the auth module and update all tests."
Many developers use Claude Code alongside an IDE-based tool. For example, use Cursor for real-time inline suggestions while coding, and switch to Claude Code for larger tasks like refactoring, test generation, or PR creation.
Frequently Asked Questions
What is Claude Code and how does it differ from GitHub Copilot?
Claude Code is Anthropic's agentic coding tool that runs natively in your terminal, reading your entire codebase, editing files, and executing commands through natural language. Unlike GitHub Copilot which primarily offers inline code suggestions within an IDE, Claude Code operates as a full autonomous agent capable of multi-file edits, Git workflows, and running terminal commands.
Is Claude Code free to use?
Claude Code requires a paid subscription. You can use it with a Claude Pro ($20/month), Max ($100–200/month), Teams ($30/user/month), or Enterprise plan. Alternatively, you can use pre-paid API credits through the Anthropic Console, or access it through Amazon Bedrock, Google Vertex AI, or Microsoft Foundry.
Can Claude Code work with any programming language?
Yes, Claude Code works with virtually any programming language since it reads and edits files as text and executes terminal commands. It excels with popular languages like Python, JavaScript/TypeScript, Go, Rust, Java, and C++, but can handle any language your development environment supports.
How do I set up CLAUDE.md for my project?
Create a CLAUDE.md file in your project root with project-specific instructions: tech stack, coding conventions, testing commands, and architecture notes. Claude Code automatically reads this file at the start of every session. You can also create a global ~/.claude/CLAUDE.md for personal preferences that apply across all projects. Run /init to generate a starter file.
What is MCP and how does it work with Claude Code?
MCP (Model Context Protocol) is an open standard that lets Claude Code connect to external tools and data sources. You configure MCP servers in your project's .mcp.json file, giving Claude access to databases, APIs, documentation, and other resources beyond your local filesystem.
Can I use Claude Code in CI/CD pipelines?
Yes, Claude Code supports headless mode with the -p flag for non-interactive execution, making it ideal for CI/CD integration. You can use it in GitHub Actions, GitLab CI/CD, and other pipelines for automated code review, test generation, and documentation updates.
How do I control costs when using Claude Code?
Use the /cost command to monitor spending during sessions, the /compact command to compress context and reduce token usage, be specific in your prompts to minimize back-and-forth, and consider using the Max plan for heavy usage. For automation, use the -p flag for single-task execution to avoid session overhead.
Is Claude Code safe to use with proprietary code?
Claude Code provides granular permission controls for file editing, command execution, and network access. You can configure allowlists and deny lists for tools, use Plan Mode for read-only analysis, and Enterprise plans offer additional security features. Your code is processed according to Anthropic's data usage policies.
Can Claude Code work with my IDE?
Yes. Claude Code integrates with VS Code, Cursor, and JetBrains IDEs through extensions. It also has a standalone Desktop app and a Web interface. All surfaces share the same engine, so your CLAUDE.md files, settings, and MCP servers work across all of them.
How does Claude Code handle large codebases?
Claude Code uses agentic search to intelligently navigate large projects. It doesn't load your entire codebase into memory — instead, it reads files on demand, follows imports, and uses grep-like tools to find relevant code. For very large monorepos, a well-structured CLAUDE.md with architecture notes helps Claude navigate more efficiently.
Conclusion & Next Steps
You've now covered everything from installing Claude Code to building a project with it, configuring advanced features like MCP and custom commands, and optimizing your workflow for speed and cost.
- Setup: Install Claude Code on macOS, Linux, or Windows in under 5 minutes
- Core commands: Interactive mode, quick tasks, print mode, and session management
- 5 daily workflows: Code generation, codebase navigation, bug fixing, testing, and Git automation
- Advanced features: CLAUDE.md configuration, custom commands, subagents, MCP integration, headless mode, and Git worktrees
- Security: Permission model, settings configuration, and enterprise best practices
- Optimization: Prompting strategies, context management, and cost control
- Comparison: How Claude Code fits alongside Cursor, GitHub Copilot, Windsurf, and Aider
Recommended Next Steps
- Start small — Pick one current task (a bug fix, a test to write, a PR to create) and try it with Claude Code
- Set up CLAUDE.md — Run
/initon your main project and customize it - Learn the shortcuts — Press
?in a session to see all keyboard shortcuts - Try MCP — Connect one external tool (GitHub, database, or Slack) to expand Claude's capabilities
- Explore custom commands — Create a
/review-pror/daily-standupcommand for your daily workflow - Join the community — Visit the Claude Code GitHub repository for plugins, examples, and discussions
Keep Learning
- Official Claude Code Documentation — Source: Claude Code Docs. The most up-to-date reference for all features and configurations.
- Anthropic Engineering Blog — Source: Anthropic. Deep dives into best practices and advanced patterns.
- r/ClaudeAI on Reddit — Source: Reddit. Active community sharing tips, workflows, and troubleshooting.
Troubleshooting Common Issues
If you run into problems getting started, here are the most common issues and their fixes:
| Problem | Cause | Solution |
|---|---|---|
command not found: claude |
Installation not in PATH | Run the install script again or add ~/.local/bin to your PATH |
| Authentication loop | Token expired or network issue | Run /login to re-authenticate, check your internet connection |
| Claude can't find files | Wrong working directory | Make sure you cd into your project root before running claude |
| Slow responses | Large context or complex query | Use /compact to reduce context, or break your prompt into smaller tasks |
| Permission denied errors | File system permissions | Check that Claude has read/write access to your project directory |
| MCP server won't start | Missing dependencies | Run npx -y @modelcontextprotocol/server-<name> manually to check for errors |
| High token usage | Broad prompts or long sessions | Be more specific in prompts, use /clear between tasks, monitor with /cost |
| Claude edits the wrong file | Ambiguous file references | Use @ with full relative paths like @src/components/auth/Login.tsx |
Run the built-in diagnostic:
/doctor
This command checks your installation, authentication, permissions, and common configuration issues — providing actionable fixes for anything it finds.
Keeping Claude Code Updated
Claude Code is under active development with frequent updates. Stay current:
Native install update:
curl -fsSL https://claude.ai/install.sh | bash
Homebrew update:
brew upgrade claude-code
WinGet update:
winget upgrade Anthropic.ClaudeCode
Check your current version anytime with:
claude --version
New releases often include performance improvements, new tools, expanded MCP support, and bug fixes. The Claude Code changelog tracks every release.
This guide is regularly updated as Claude Code evolves. Bookmark it, and check back for new features, workflows, and best practices as they're released.
Last updated: March 2026


