Claude Code Complete Tutorial
From installation to mastery — A comprehensive guide to Claude Code covering setup, core features, model selection, practical examples and best practices
Claude Code Complete Tutorial¶
This is a comprehensive Claude Code tutorial designed for developers. Whether you're new to AI coding tools or migrating from other tools, this guide will help you master Claude Code — the most powerful AI coding assistant in 2026.
1. What is Claude Code¶
An Agentic Coding Assistant, Not Code Completion¶
Claude Code is Anthropic's official CLI agentic coding assistant. Unlike traditional code completion tools (like GitHub Copilot), Claude Code works like an experienced developer:
- Autonomous planning: Describe your task, it creates an execution plan
- Direct code operations: Read, edit, and create any file in your project
- Terminal execution: Run tests, install dependencies, execute builds
- Deep project understanding: 200K token context window (Opus 4.6 supports up to 1M)
- Sub-agent delegation: Break complex tasks into parallel sub-agents
2025-2026 Key Updates¶
| Update | Description |
|---|---|
| Plan Mode | Analyze first, plan second, fewer mistakes |
| Agent Teams | Multi-agent parallel collaboration with git worktree isolation |
| Voice Mode | Push-to-talk, 20 languages supported |
| Computer Use | Operate desktop, browser, dev tools |
| Hooks System | 17 lifecycle events for automation |
| MCP Protocol | Connect external tools and services |
| Skills | Reusable knowledge modules |
| Extended Thinking | Deep internal reasoning for complex problems |
| Opus 4.6 | Most powerful coding model |
Why Use QCode.cc¶
Through QCode.cc you get:
- Asia-Pacific low-latency nodes, no VPN needed
- Up to 80% cost savings compared to official pricing
- Claude Code & Codex share plan quota — one plan, two tools
- High availability across multiple nodes
2. Installation & Setup¶
System Requirements¶
| Requirement | Details |
|---|---|
| OS | macOS 12+, Ubuntu 20.04+, Windows 10+ (WSL2) |
| Node.js | v22 LTS or higher |
| Git | 2.x or higher |
Install¶
npm install -g @anthropic-ai/claude-code
Configure QCode.cc¶
# Add to ~/.bashrc or ~/.zshrc
export ANTHROPIC_BASE_URL=https://asia.qcode.cc/api
export ANTHROPIC_API_KEY=cr_your_api_key
Verify¶
claude --version
claude -p "Hello, introduce yourself"
3. First Use¶
Start Claude Code¶
cd ~/my-project
claude
Permission Modes¶
| Mode | Description | Use Case |
|---|---|---|
| Default | Confirm each operation | First use, sensitive projects |
--allowedTools |
Specify allowed tools | Scoped automation |
--dangerously-skip-permissions |
Skip all confirmations | Docker/CI only |
Your First Task¶
> Analyze this project's architecture and explain the main modules
Claude will automatically read package.json, browse source files, and provide a structured analysis.
4. Core Features¶
Plan Mode¶
> /plan
> I want to add user authentication using JWT
Claude will analyze, propose a plan, then execute after your approval.
Extended Thinking¶
Opus 4.6 performs deep internal reasoning for complex problems:
> This concurrency bug has been investigated for two days. Analyze the race condition in src/worker.ts
Sub-agents¶
> Review this PR and check for security vulnerabilities simultaneously
Claude spawns parallel sub-agents for independent tasks.
Key Commands¶
| Command | Function |
|---|---|
/model |
Switch model |
/plan |
Enter plan mode |
/compact |
Compress context |
/cost |
View current costs |
/clear |
Clear context |
/init |
Generate CLAUDE.md |
/review |
Code review |
/help |
Show help |
Context Management¶
/cost # Check usage
/compact # Compress (keeps key info)
/clear # Fresh session
Best practice: /compact when context > 70%, /clear between different tasks.
5. CLAUDE.md — Project Configuration¶
Create with /init, or manually:
# MyApp
## Tech Stack
- React 19 + TypeScript + Vite + Tailwind CSS
## Commands
- Dev: `pnpm dev`
- Test: `pnpm test`
- Build: `pnpm build`
## Coding Standards
- Functional components only, no class components
- No `any` types
- Commit format: feat: / fix: / docs:
Full guide: CLAUDE.md Configuration Guide
6. Model Selection¶
| Model | Strength | Price (input) | Best For |
|---|---|---|---|
| Opus 4.6 | Strongest reasoning | $5.00/M | Architecture, complex debugging |
| Sonnet 4.6 | Best balance | $3.00/M | Daily coding, bug fixes |
| Haiku 4.5 | Fastest, cheapest | $1.00/M | Formatting, simple tasks |
/model opus # Switch to Opus
/model sonnet # Switch to Sonnet
/model haiku # Switch to Haiku
Recommended strategy: Sonnet 70% (daily work) + Opus 15% (key decisions) + Haiku 15% (simple tasks).
7. Advanced Tips¶
Hooks¶
Auto-format after file changes:
{
"hooks": {
"PostToolUse": [{
"matcher": "Write|Edit",
"hooks": [{ "type": "command", "command": "npx prettier --write $FILEPATH" }]
}]
}
}
MCP Servers¶
Connect external tools:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "ghp_xxx" }
}
}
}
Full guides: Hooks System | MCP Servers
8. Practical Examples¶
Example 1: Understand a New Codebase¶
> Analyze this project: tech stack, core modules, data flow, and draw an ASCII architecture diagram
Example 2: Feature Implementation with Plan Mode¶
> /plan
> Add rate limiting: 60 requests/min per user, Redis-backed, 429 with Retry-After header
Example 3: Complex Bug Debugging¶
/model opus
> Users report inventory going negative under concurrent orders. Analyze the race condition.
Example 4: Batch Refactoring¶
> Refactor all class components in src/components/ to functional components with Hooks
Example 5: CI/CD Integration¶
claude -p "Review this PR for security and performance issues" \
--output-format json --max-turns 3 --allowedTools Read,Glob,Grep
9. Claude Code + Codex Together¶
| Aspect | Claude Code | Codex CLI |
|---|---|---|
| Style | Interactive pair programming | Autonomous execution |
| Best for | Deep reasoning, planning | Batch execution, automation |
| Model | Claude Opus/Sonnet | GPT-5.4 |
| Config | CLAUDE.md | AGENTS.md |
Best combo: Claude Code plans and reviews, Codex executes and automates.
QCode.cc: one plan, both tools share quota, zero switching cost. See Codex vs Claude Code Comparison for details.
10. FAQ¶
Q: Installation permission errors?
sudo npm install -g @anthropic-ai/claude-code
# Or use nvm (recommended)
Q: Connection timeout?
echo $ANTHROPIC_BASE_URL # Should be https://asia.qcode.cc/api
curl -I https://asia.qcode.cc/api/health
Q: Cost concerns?
- Use Sonnet for daily work (60% cheaper than Opus)
- Use
/costto monitor spending - Use Haiku for simple tasks
Q: Claude doesn't understand my project?
Create a CLAUDE.md file — see Chapter 5.
Related Docs¶
- CLAUDE.md Configuration — Project config guide
- Hooks System — Automation hooks
- Automation & CI/CD — Headless mode
- Model Selection — Detailed model comparison
- Codex Complete Tutorial — Codex CLI guide
- Pricing Plans — QCode.cc plans