Claude Code = CLI agent cho coding. Sống trong terminal, tích hợp với filesystem, shell, git, web.
- Install Claude Code trên máy
- Login lần đầu
- Biết các tính năng built-in
- Setup đầu tiên cho 1 project
Tính năng built-in
Ready to use ngay sau install.
┌──────────────────────────────────────────┐ │ │ │ CLAUDE CODE TOOLS (built-in) │ │ │ │ File ops: │ │ - Glob (tìm file) │ │ - Grep (search content) │ │ - Read (đọc file) │ │ - Edit (sửa file) │ │ - Write (tạo file) │ │ │ │ Shell: │ │ - Bash (chạy command) │ │ │ │ Web: │ │ - WebFetch │ │ - WebSearch │ │ │ │ Agent: │ │ - Task (sub-agent) │ │ - TodoWrite │ │ │ │ Plus: MCP servers (extend) │ │ │ └──────────────────────────────────────────┘
Install (3 bước)
Bước 1: Node.js
Check đã có chưa:
Nếu error → install Node:
Bước 2: Claude Code
- macOS: brew install node
- Linux: nodesource instructions
- Windows: Download từ nodejs.org
npm helpBước 2: Claude Code
Có thể cần sudo trên Linux/macOS.
Bước 3: Login
npm install -g @anthropic-ai/claude-codeBước 3: Login
First run → prompt login. Đăng nhập account Anthropic (same as console.anthropic.com).
claudeSubscription
Claude Code có 2 cách billing:
Option 1: Claude Max subscription
Option 2: API key billing
Check subscription options: anthropic.com/pricing
- $100-200/tháng
- Include Claude Code usage
- Best cho individual / small team
- Pay-per-use
- Scale với traffic
- Best cho CI/CD, headless usage
First session
Output:
cd my-project
claudeFirst session (tiếp)
Try:
Welcome to Claude Code (v1.x)
Connected to: my-project
Type your request, or /help for commands.
> First session (tiếp)
Claude Code scan codebase → answer.
> What does this project do? Give me 3-bullet summary.Useful commands (slash)
/init đặc biệt quan trọng — bài tiếp theo.
| Command | Purpose |
|---|---|
| /help | List all commands |
| /clear | Reset conversation |
| /init | Scan codebase, create CLAUDE.md |
| /compact | Summarize history to save tokens |
| /cost | Show session cost |
| /exit | Quit |
command cho CLAUDE.md
Type # + rule → saved to CLAUDE.md:
Claude Code asks to add to project / local / user CLAUDE.md.
- Project: shared team, commit git
- Local: your notes, gitignored
- User: cross-projects
# Always use type hints in Python code
# Prefer list comprehensions over map/filterCheck install
claude --version
# Output: 1.x.x
claude --help
# Show all flagsConfig
Config file: ~/.claude/settings.json
permissions control what Claude Code can do without confirm. Important for safety.
{
"defaultModel": "claude-sonnet-5-20260205",
"permissions": {
"allow": ["Bash(git:*)", "Read(**)"],
"ask": ["Write(**)", "Bash(**)"]
}
}MCP extend (from bài 6.77)
Add tools beyond built-in:
MCP servers available in all Claude Code sessions.
claude mcp add sentry npx @sentry/mcp-server
claude mcp list
claude mcp remove sentryTroubleshoot install
command not found: claude
Fix:
Login fail
Fix:
Permission denied
Fix: npm global install cần privilege.
- Check $PATH includes npm global bin
- npm bin -g → add to PATH
- Or reinstall: npm uninstall -g && npm install -g @anthropic-ai/claude-code
- Check internet
- Try different browser for OAuth
- Clear local: rm -rf ~/.claude/cache (careful with settings!)
- macOS/Linux: sudo npm install -g ...
- Or use nvm/fnm for user-level node.
Best first session
cd interesting-project
claudeBest first session (tiếp)
Claude scan code → create CLAUDE.md. Review + commit.
> /initBest first session (tiếp)
Get overview.
> Summarize the main components of this projectBest first session (tiếp)
Claude identify complexity. Useful cho onboarding.
> What are the 3 most complex files? Why?Compared với alternatives
Claude Code best cho agent-driven workflows.
| Claude Code | Cursor | GitHub Copilot | ChatGPT desktop | |
|---|---|---|---|---|
| Interface | Terminal | IDE integrated | IDE inline | Standalone app |
| Agent mode | Yes (full) | Yes | No | Limited |
| File ops | Full | Full | Suggest only | Manual copy |
| MCP | Native | Yes | No | No |
| Cost | $100+/mo OR API | $20/mo | $10/mo | $20/mo |
| Best for | Agent workflows, power users | IDE users | Line-by-line | Chat-like |
Safety warning
Claude Code có full filesystem + shell access. Treat with respect:
Use in sandboxed/dev environments for experiments.
- ✅ Use on projects you own
- ✅ Commit often (easy rollback)
- ✅ Review plans before complex ops
- ❌ Don't give production creds
- ❌ Don't run untrusted prompts (prompt injection via README)
Áp dụng ngay
Bài tập: Install + run (20 phút)
Verify flow. Tomorrow: use cho real task.
- Install Claude Code
- Navigate to 1 of your projects
- claude
- /init — create CLAUDE.md
- Ask 3 questions about project
- Quit
Tóm tắt
🎯 Claude Code = CLI agent cho coding.
🎯 Install 3 bước: Node.js → npm install → claude login.
🎯 Built-in tools: file ops, bash, web, agent.
🎯 Slash commands: /help, /init, /clear, /cost.
🎯 MCP extend cho custom tools.