Claude Code Complete Guide: From Setup to Advanced Workflows
The complete Claude Code tutorial. From installation to advanced features including CLAUDE.md, Hooks, MCP, and Custom Agents. Perfect for beginners to advanced users.
This is the most comprehensive Claude Code tutorial available. Whether you’re new to AI-assisted development or looking to master advanced features, this guide has you covered.
What is Claude Code?
Claude Code is Anthropic’s official AI coding assistant. What makes it different from other tools:
- Terminal Native: Runs in the terminal, not tied to any editor
- Project-Level Understanding: Understands your entire codebase, not just single files
- Agent Architecture: Can autonomously execute tasks, not just answer questions
Why Choose Claude Code?
| Feature | Claude Code | Cursor | GitHub Copilot |
|---|---|---|---|
| Interface | Terminal | IDE | Editor Plugin |
| Autonomy | High (Agent) | Medium | Low |
| Customization | Very High | Medium | Low |
| Best For | Complex tasks, automation | GUI preference | Simple completion |
Choose Claude Code if you love the terminal, want maximum control, and need to handle complex tasks.
Installation & Setup
System Requirements
- macOS: 10.15+
- Linux: Ubuntu 20.04+ / Debian 10+
- Windows: Windows 10+ (requires WSL or Git for Windows)
Installation Methods
Method 1: Official Install Script (Recommended)
# macOS / Linux / WSL
curl -fsSL https://claude.ai/install.sh | bash
Method 2: npm Installation
# Requires Node.js 18+
npm install -g @anthropic-ai/claude-code
First-Time Setup
After installation, run:
claude
The first run will guide you through:
- Authentication: Log in to your Anthropic account or enter API Key
- Plan Selection: Free / Pro / Max
- Permission Settings: Decide what operations Claude can perform
Verify Installation
claude --version
# Should display version, e.g., claude-code version 2.1.12
Basic Usage
Starting a Conversation
Run in any project directory:
cd /path/to/your/project
claude
Claude will automatically scan the project structure and build understanding.
Basic Commands
| Command | Function |
|---|---|
claude | Start interactive conversation |
claude "do something" | Single task execution |
claude --help | View all options |
/help | Get help during conversation |
/clear | Clear conversation history |
Ctrl+C | Interrupt current operation |
Escape twice | Exit Claude |
Conversation Mode
In conversation, describe tasks in natural language:
You: Create a date formatting utility function in src/utils/
Claude: I'll create that utility function...
[Claude shows the file and content to create, waits for confirmation]
Plan Mode
Press Shift+Tab to enter Plan Mode:
You: [Shift+Tab] Implement user login feature
Claude: Let me analyze the requirements and plan the implementation...
[Claude researches the codebase, proposes a plan, but doesn't modify any files]
Plan Mode is ideal for: Complex features, when you’re unsure how to proceed
CLAUDE.md Configuration
CLAUDE.md is Claude Code’s most important configuration file. It tells Claude your project rules.
Creating CLAUDE.md
Create CLAUDE.md in your project root:
# Project Name
## Tech Stack
- Node.js + TypeScript
- React + Tailwind CSS
- PostgreSQL
## Development Rules
- Use pnpm as package manager
- All code must have TypeScript types
- Run `pnpm lint && pnpm test` before committing
## Directory Structure
- `src/` - Main source code
- `tests/` - Test files
- `docs/` - Documentation
## Forbidden Actions
- Don't use any type
- Don't delete existing tests
- Don't push directly to main branch
Quick Initialization
Use the built-in command to auto-generate:
claude
/init
Claude will analyze the project structure and generate an appropriate CLAUDE.md.
CLAUDE.md Locations
| Location | Purpose |
|---|---|
project-root/CLAUDE.md | Project-specific rules |
~/.claude/CLAUDE.md | Personal global rules |
Advanced Features
1. Hooks (Automation Triggers)
Hooks let you automatically execute scripts at specific events.
Common Use Cases:
- Auto-format after editing files
- Run tests after every modification
- Block dangerous commands
Configuration Example (.claude/settings.json):
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "pnpm lint --fix $CLAUDE_FILE_PATHS"
}
]
}
]
}
}
👉 Detailed guide: Claude Code Hooks Complete Guide
2. MCP (Model Context Protocol)
MCP lets Claude connect to external tools and data sources.
Common MCP Servers:
memory- Cross-conversation memoryfilesystem- Enhanced file operationsgithub- GitHub integration
Installation Example:
# Install memory server
claude mcp add memory -- npx -y @anthropic-ai/mcp-server-memory
👉 Detailed guide: Claude Code MCP Setup Guide
3. Custom Agents
Create agents specialized for specific tasks.
Creation Method:
claude
/agents
# Select "Generate with Claude"
# Describe the agent you want
Common Agent Types:
- Code Reviewer - Code quality review
- Debugger - Error analysis
- Test Writer - Test creation
👉 Detailed guide: Claude Code Agents Complete Guide
4. Custom Skills
Skills are reusable command templates.
Creation Method:
Create Markdown files in .claude/skills/:
# my-deploy.md
---
name: deploy
description: "Deploy to production"
user-invocable: true
---
Execute the following deployment steps:
1. Run tests
2. Build project
3. Deploy to Cloudflare Pages
Usage: /deploy
👉 Detailed guide: Claude Code Skills Complete Guide
Best Practices
1. Keep Context Clean
Use /clear to clear conversation history after completing each task
Old conversation history consumes tokens and can confuse Claude.
2. Use Plan Mode
For complex tasks, enter Plan Mode first (Shift+Tab)
Let Claude research before taking action
3. Give Clear Instructions
Bad: “Improve this function”
Good: “Refactor the calculateTotal function to use reduce instead of a for loop, and add TypeScript types”
4. Use Test-Driven Development
You: Write tests first, confirm they fail, then implement the feature to make tests pass
Claude performs best when it has clear test targets.
5. Use Built-in Tools
| Command | Purpose |
|---|---|
/init | Initialize CLAUDE.md |
/cost | Check token usage |
/memory | Manage memory |
/model | Switch models |
FAQ
Q: Claude won’t execute my command?
A: Check permission settings. Claude may be waiting for your confirmation. Type y or a (accept all).
Q: How to reduce costs?
A:
- Use
/clearto clear unnecessary history - Use
Shift+Tabto plan before executing - Use Haiku model for simple tasks
Q: Claude’s generated code has errors?
A:
- Provide more context (related files)
- Use test-driven development
- Clearly indicate errors, let Claude fix them
Q: How to use with a team?
A:
- Add
CLAUDE.mdto version control - Add
.claude/directory to version control (excludesettings.local.json) - Use
projectscope for MCP settings
Q: Which programming languages are supported?
A: Claude Code supports all major programming languages, including but not limited to:
- JavaScript/TypeScript
- Python
- Go
- Rust
- Java/Kotlin
- C/C++
- Swift
- PHP
- Ruby
Next Steps
Congratulations on completing the Claude Code basics! Recommended reading:
- Hooks Complete Guide - Build automated workflows
- MCP Setup Guide - Extend Claude’s capabilities
- Agents Complete Guide - Create custom agents
- Director Mode Methodology - Advanced development mode
Resources
Last updated: 2026-01-19