Claude Code Complete Guide
Claude Code is an AI-powered coding agent from Anthropic that can understand a codebase, edit files, run commands, work with Git, connect to external tools through MCP, and automate development workflows.
Unlike a traditional autocomplete tool, Claude Code can work across an entire repository and perform multi-step tasks such as investigating bugs, modifying multiple files, running tests, reviewing changes, and creating commits.
This guide covers everything you need to get started with Claude Code from installation to advanced workflows.
What You Need
Claude Code currently supports:
- macOS 13+
- Windows 10 1809+ / Windows Server 2019+
- Ubuntu 20.04+
- Debian 10+
- Alpine Linux 3.19+
- x64 and ARM64 processors
- At least 4 GB RAM
- Internet connection
- Bash, Zsh, PowerShell or CMD
On Windows, Claude Code can run natively or through WSL 2. Git for Windows is optional for native Windows, but installing it enables Claude Code's Bash tool through Git Bash.
1. Installing Claude Code
macOS, Linux or WSL
Open your terminal and run:
curl -fsSL https://claude.ai/install.sh | bash
Windows PowerShell
Open PowerShell and run:
irm https://claude.ai/install.ps1 | iex
Windows CMD
Run:
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
Make sure you use the correct command for the terminal you're using.
PowerShell normally starts with:
PS C:\>
CMD normally starts with:
C:\>
The current official installation documentation recommends the native installer for most users.
2. Verify Installation
After installation:
claude --version
You should see the installed Claude Code version.
For a deeper installation and configuration diagnostic:
claude doctor
claude doctor performs read-only diagnostics from the terminal and can identify installation, configuration and PATH problems.
3. Start Claude Code
Navigate into your project:
cd my-project
Then start Claude Code:
claude
On the first launch, you'll be asked to authenticate.
You can also start Claude with an initial instruction:
claude "Explain this project to me"
For example:
claude "Analyze this codebase and explain the architecture"
4. Authentication
Claude Code can authenticate through supported Claude/Anthropic accounts and supported third-party providers.
You can also explicitly log in:
claude auth login
Check authentication:
claude auth status
Log out:
claude auth logout
Claude Code can also use an ANTHROPIC_API_KEY environment variable.
5. Your First Claude Code Prompt
Instead of immediately asking Claude to modify code, start by asking it to understand the project.
Good first prompt:
Analyze this entire project.
Do not modify anything yet.
Explain:
1. The framework being used
2. The folder structure
3. The main entry points
4. How authentication works
5. How the database is connected
6. How API calls are organized
7. How the frontend communicates with the backend
8. How the project is built and deployedThis gives Claude context before making changes.
6. Give Claude a Task
Once Claude understands the project, you can ask it to implement something.
Example:
Add dark mode to the application.
First inspect the existing styling architecture.
Reuse the existing design tokens and components.
Do not introduce a new UI library.
After implementing it, run the relevant tests and report what changed.Claude Code can inspect the repository, edit multiple files, execute commands and verify its work.
7. CLAUDE.md
One of the most useful Claude Code features is CLAUDE.md.
Create one in your project's root:
CLAUDE.md
You can use it to provide persistent project instructions.
Example:
# Project Instructions
## Stack
- Next.js
- TypeScript
- Tailwind CSS
- PostgreSQL
## Rules
- Use TypeScript.
- Do not use `any` unless absolutely necessary.
- Reuse existing components.
- Do not introduce dependencies without asking.
- Keep components small and reusable.
- Run tests after significant changes.
## Git
- Never push directly to main.
- Use descriptive commit messages.
- Do not modify unrelated files.Claude Code reads CLAUDE.md at the beginning of sessions and can use it for coding standards, architecture decisions and project-specific instructions.
8. Initialize CLAUDE.md Automatically
Inside Claude Code:
/init
This initializes a project guide and can create a starter CLAUDE.md.
9. Most Important Claude Code Commands
Start Claude
claude
Start an interactive session.
Start with a prompt
claude "Explain this project"
Non-interactive mode
claude -p "Explain this function"
Continue the previous conversation
claude -c
or:
claude --continue
Resume a specific session
claude -r "session-name"
Update Claude Code
claude update
Check installation
claude doctor
Check authentication
claude auth status
Configure MCP
claude mcp
View background-session logs
claude logs <id>
Stop a background session
claude stop <id>
Attach to a background session
claude attach <id>
Start a cloud session
claude --cloud "Fix the login bug"
Select a model
claude --model sonnet
Select effort
claude --effort high
Enable Chrome integration
claude --chrome
Run in print mode
claude -p "Review this code"
Output JSON
claude -p "Analyze this project" --output-format json
Limit agentic turns
claude -p "Fix the tests" --max-turns 3
Set a budget limit
claude -p "Fix the issue" --max-budget-usd 5
The official CLI reference contains the complete current command and flag reference, including newer commands for background agents, cloud sessions, MCP, plugins, remote control and more.
10. Important Slash Commands
Inside a Claude Code session, type / to open the command menu.
Some of the most useful commands are:
| Command | Purpose |
|---|---|
/help | Show available commands |
/init | Initialize project instructions |
/clear | Start a fresh conversation |
/compact | Reduce conversation context |
/context | Inspect context usage |
/model | Change model |
/effort | Change reasoning effort |
/plan | Enter plan mode |
/permissions | Manage permissions |
/memory | Manage project memory |
/mcp | Manage MCP servers |
/skills | List available skills |
/plugin | Manage plugins |
/diff | Review current changes |
/review | Review code changes |
/code-review | Perform code review |
/security-review | Check changes for security issues |
/doctor | Diagnose configuration |
/debug | Debug Claude Code |
/tasks | View background work |
/background | Continue work in background |
/fork | Create a background copy |
/subtask | Delegate a task |
/run | Run and inspect the application |
/verify | Verify an application change |
/rewind | Rewind code/conversation |
/resume | Resume a previous session |
/export | Export conversation |
/usage | View usage information |
/status | View session status |
/rename | Rename the session |
/login | Sign in |
/logout | Sign out |
/exit | Exit Claude Code |
Claude Code's command availability can vary depending on platform, plan and environment, so the / menu inside your installation is the authoritative list for your session.
11. Useful Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+C | Interrupt current operation |
Ctrl+D | Exit |
Ctrl+L | Redraw terminal |
Ctrl+O | Toggle transcript viewer |
Ctrl+R | Search command history |
Ctrl+B | Background a running task |
Ctrl+T | Toggle task checklist |
Esc | Stop current response |
Esc + Esc | Rewind / clear draft |
Shift+Tab | Change permission mode |
Alt+P | Switch model on Windows/Linux |
Option+P | Switch model on macOS |
12. Shell Mode
Claude Code can execute shell commands directly when you prefix a command with !.
Examples:
! git status
! npm test
! ls -la
This allows you to run a command directly and add its output to the current Claude Code context.
13. Git Workflow
Claude Code works directly with Git.
For example:
Review my current Git changes.
Find any bugs.
Fix the issues you find.
Run the tests.
Then create a descriptive commit.Claude Code can inspect diffs, create commits, work with branches and help prepare pull requests.
Always review generated changes before pushing them.
14. Plan Mode
For large changes, ask Claude to plan before modifying files.
Use:
/plan
Or:
/plan migrate the authentication system from Firebase to Supabase
This is useful when the change affects multiple parts of a codebase.
15. MCP
MCP stands for Model Context Protocol.
It allows Claude Code to connect to external tools and data sources.
Examples include:
- databases
- project management tools
- documentation
- GitHub
- Slack
- custom internal tools
You can manage MCP servers with:
/mcp
Claude Code's documentation describes MCP as a way to connect external data sources and tools to Claude Code.
16. Background Agents
Claude Code can run work in the background.
Useful for:
- long-running tests
- builds
- research
- multiple development tasks
- parallel work
You can inspect background work with:
/tasks
You can also start a background session from the CLI:
claude --bg "Investigate the failing authentication tests"
17. Code Review
Claude Code includes workflows for reviewing changes.
For example:
/code-review
Security-focused review:
/security-review
You can also ask:
Review the current diff.
Look specifically for:
- authentication vulnerabilities
- authorization issues
- SQL injection
- XSS
- exposed secrets
- insecure API endpoints
- sensitive information leaks18. Common Prompt Pattern
A good Claude Code prompt usually contains:
CONTEXT
What project/file/system are we working on?
GOAL
What should change?
CONSTRAINTS
What should NOT change?
IMPLEMENTATION
What approach should be followed?
VALIDATION
How should the result be tested?Example:
CONTEXT:
This is a Next.js TypeScript application using PostgreSQL.
GOAL:
Add password reset functionality.
CONSTRAINTS:
Do not change the existing authentication provider.
Reuse the existing email service.
IMPLEMENTATION:
First inspect the current authentication architecture.
Then implement the reset-token flow.
VALIDATION:
Run the relevant tests and verify the complete flow.
Do not modify unrelated files.19. Safety Tips
Do not blindly approve every command Claude wants to run.
Be especially careful with:
rm -rf
database deletion commands, production deployments, credential changes and commands that modify large parts of a repository.
Claude Code provides permission modes and permission rules for controlling tool access.
Avoid using:
--dangerously-skip-permissions
unless you fully understand the consequences and are operating in an appropriately isolated environment. The flag explicitly skips permission prompts.
20. Recommended First Workflow
For a new project:
1. Install Claude Code
2. Open your project
3. Run claude
4. Ask Claude to analyze the repository
5. Run /init
6. Review CLAUDE.md
7. Start with /plan for large changes
8. Implement one feature at a time
9. Review /diff
10. Run tests
11. Run /code-review
12. Commit the changesQuick Reference
Installation
# macOS / Linux / WSL
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
# Verify
claude --version
# Diagnostics
claude doctorStarting
claude
claude "Analyze this project"
claude -p "Review this code"Sessions
claude -c
claude -r "session-name"
claude --cloud "Fix this bug"Authentication
claude auth login
claude auth status
claude auth logoutDevelopment
/init
/plan
/diff
/review
/code-review
/security-review
/verifyContext
/compact
/context
/memory
/clearIntegrations
/mcp
/plugin
/skillsBackground work
/tasks
/background
/fork
/subtaskOfficial Documentation
For the latest installation instructions and command reference, always check the official Claude Code documentation because commands and features can change between releases.


