Claude Code cho người mới bắt đầu
Hướng dẫn toàn diện cho người mới: từ đặt câu hỏi đầu tiên đến quản lý permission, git workflow và best practices khi dùng Claude Code.
Claude Code là một AI coding agent chạy trực tiếp trong terminal. Nó đọc được toàn bộ codebase, sửa file, chạy lệnh và giúp bạn hoàn thành task — tất cả bằng ngôn ngữ tự nhiên. Bài này hướng dẫn từ zero đến làm việc hiệu quả.
Claude Code là gì?
Claude Code không phải chatbot thông thường. Nó là agentic coding tool — có thể đọc file, chạy command, sửa code, tạo commit, và tự giải quyết vấn đề trong khi bạn quan sát hoặc rời đi.
Terminal CLI: đầy đủ tính năng, phù hợp power user
IDE extension: VS Code, JetBrains — inline diffs, @-mentions
Desktop app: visual diff, multi-session, scheduled tasks
Web: chạy trên browser, cloud sessions
Bắt đầu làm việc
Sau khi cài đặt (xem Hướng dẫn cài đặt), mở terminal trong thư mục dự án:
cd /path/to/your/project
claudeGiao diện hiện ra với version, model, và working directory. Bây giờ bạn có thể đặt câu hỏi:
what does this project do?Claude sẽ phân tích files và trả lời. Thử thêm:
what technologies does this project use?
where is the main entry point?
explain the folder structureCác lệnh shell cơ bản
Đây là các lệnh chạy từ terminal để khởi động hoặc quản lý Claude Code:
claude
Khởi động interactive mode
claude
claude "task"
Chạy 1 task rồi thoát
claude "fix the build error"
claude -p "query"
Chạy query rồi exit
claude -p "explain this function"
claude -c
Tiếp tục session gần nhất
claude -c
claude -r
Chọn session để resume
claude -r
One-shot mode với pipe
Rất hữu ích cho scripting, CI/CD, và automation.
Slash commands thiết yếu
Bên trong Claude Code, gõ / để xem toàn bộ commands. Đây là các lệnh quan trọng nhất:
/help
Hiển thị tất cả commands
/clear
Xóa toàn bộ conversation context
/compact
Nén context để tiết kiệm token
/init
Tạo file CLAUDE.md cho project
/memory
Quản lý project memory
/context
Xem mức sử dụng context
/diff
Xem các thay đổi hiện tại
/resume
Chọn session trước đó để tiếp tục
/login
Đăng nhập lại hoặc chuyển tài khoản
/exit hoặc Ctrl+D×2
Thoát Claude Code
Permission modes
Claude Code có 4 chế độ permission, quyết định khi nào cần hỏi bạn trước khi thực thi:
default
Hỏi trước mỗi thay đổi file/command
acceptEdits
Tự động approve file edits, vẫn hỏi về bash
plan
Chỉ đọc và đề xuất, không sửa file
auto
Classifier tự review, block lệnh risky
Nhấn Shift+Tab để chuyển giữa các mode. Thanh trạng thái hiển thị mode hiện tại.
Làm việc với Git
Claude Code tích hợp sâu với Git. Bạn có thể yêu cầu bằng ngôn ngữ tự nhiên:
Claude sẽ:
Chạy
git status,git diffđể hiểu thay đổiTạo commit message mô tả
Stage files và commit
Push nếu bạn yêu cầu
Sử dụng @ reference files
Thay vì mô tả đường dẫn, dùng @ để include trực tiếp file hoặc directory vào conversation:
@path/to/file— include toàn bộ nội dung file@path/to/dir— hiển thị directory listingGõ
@để mở suggestion menu, Enter để accept
Dùng images trong Claude Code
Bạn có thể paste screenshot hoặc drag-and-drop image vào Claude Code:
Hoặc reference file image:
Mẹo cho người mới
Be specific
Break tasks thành steps
Để Claude explore trước khi code
Course-correct sớm
Esc: dừng Claude giữa chừng, giữ contextEsc + Eschoặc/rewind: quay lại checkpoint trước"Undo that": yêu cầu revert changes
Tóm tắt workflow cho người mới
cd vào project →
claudeExplore:
give me an overview of this codebaseTask: mô tả task bằng ngôn ngữ tự nhiên
Verify: yêu cầu chạy test/lint sau khi sửa
Commit:
commit my changesClear:
/clearkhi chuyển task mới
Tài liệu tham khảo
Cập nhật lần cuối