Trung cấpguide Claude CodeCộng đồng

Mastering Claude Code: Best Practices thực sự hiệu quả — Thinking hierarchy, Plan Mode, và .claude files

Nghe bài viết
00:00

Điểm nổi bật

Nhấn để đến mục tương ứng

  1. 1 Directory-specific context CLAUDE.md mẫu hiệu quả Ví dụ từ Dinanjana về CLAUDE.md của anh: File CLAUDE.md không chỉ là configuration — đây là "brain implant" cho Claude về project của bạn. Global settings áp dụng cho mọi project your-project/CLAUDE.md :.
  2. 2 Đây là cách các best practices kết hợp trong một feature development cycle: "Before we start, ask me about requirements" Plan Mode : Review architecture trước khi touch code Appropriate thinking level : "think hard" cho feature này CLAUDE.md check :.
  3. 3 sau khi áp dụng consistent, implementations "shift from requiring extensive debugging to being remarkably close to production-ready." Không phải vì Claude thông minh hơn — mà vì process tốt hơn dẫn đến context tốt hơn, dẫn đến output tốt hơn.
  4. 4 Rồi anh phát hiện ra điều gì đó quan trọng — chất lượng output không phụ thuộc vào "AI thông minh" mà phụ thuộc vào process của bạn . Dinanjana Gunaratne đã trải qua giai đoạn mà hầu hết developer trải qua khi mới dùng Claude Code:.
  5. 5 Claude Code có 4 levels của "thinking" — mỗi level tăng computational resources và quality, nhưng cũng tăng token cost:.
yellow and green electric wires

Từ vibe coding đến production-ready: Tư duy đúng

Dinanjana Gunaratne đã trải qua giai đoạn mà hầu hết developer trải qua khi mới dùng Claude Code: gõ prompts vague vào Claude, nhận code về, debug mãi vẫn không xong. Rồi anh phát hiện ra điều gì đó quan trọng — chất lượng output không phụ thuộc vào "AI thông minh" mà phụ thuộc vào process của bạn.

Bài viết này tổng hợp những best practices của Dinanjana đã chuyển đổi workflow của anh từ "spend hours debugging" sang "production-ready từ lần đầu".

Best Practice #1: Thinking Hierarchy — Match effort với problem

Claude Code có 4 levels của "thinking" — mỗi level tăng computational resources và quality, nhưng cũng tăng token cost:

Level Dùng khi nào Ví dụ
think Straightforward features, bug fixes đơn giản Add a new API endpoint
think hard Complex business logic, multi-file architecture Redesign authentication flow
think harder Performance optimization, security-sensitive code Optimize database queries
ultrathink Legacy integration, complex algorithms, stuck problems Migrate from monolith to microservices

"There's no point burning thinking tokens on a variable rename." — Dinanjana Gunaratne

Mistake phổ biến nhất: default về "ultrathink" cho mọi thứ. Đây là waste tokens và thời gian. Bắt đầu với "think" cho simple tasks, escalate lên khi cần thiết.

Best Practice #2: Plan Mode — Architect trước, code sau

Nhấn Shift+Tab hai lần để vào Plan Mode. Đây là mode Claude analyze codebase mà không modify bất kỳ file nào — hoạt động như architect thay vì coder.

Khi nào bắt buộc dùng Plan Mode?

  • Bắt đầu feature mới — "non-negotiable" theo Dinanjana
  • Complex multi-file refactoring
  • Debugging vấn đề không rõ nguyên nhân
  • Architectural decisions ảnh hưởng nhiều components

Workflow với Plan Mode

  1. Enter Plan Mode (Shift+Tab twice)
  2. Mô tả objective: "I want to add user authentication with JWT tokens"
  3. Review Claude's comprehensive plan — files sẽ touched, approach, potential risks
  4. Refine nếu cần: "Actually, use session-based auth instead"
  5. Exit Plan Mode và execute

Lợi ích: bạn review plan trước khi Claude bắt đầu thay đổi code. Tránh được rabbit holes và sai direction sau khi đã làm được 80%.

Best Practice #3: .claude Files — Project memory bank

File CLAUDE.md không chỉ là configuration — đây là "brain implant" cho Claude về project của bạn. Cấu trúc hierarchical:

  • ~/.claude/CLAUDE.md: Global settings áp dụng cho mọi project
  • your-project/CLAUDE.md: Project-level context
  • your-project/src/api/CLAUDE.md: Directory-specific context

CLAUDE.md mẫu hiệu quả

Ví dụ từ Dinanjana về CLAUDE.md của anh:

## Code Style
- TypeScript only (no JavaScript)
- Functional components with hooks
- 2-space indentation
- Prefer named exports

## Architecture
- State management: Zustand
- API calls: custom hooks in src/hooks/
- No business logic in components

## Hard Rules
- No class components
- Functions max 50 lines
- No files over 300 lines
- Tests required for all utilities

"The magic isn't in the format — it's in being specific about what matters for your project." — Dinanjana

Best Practice #4: Encourage Clarifying Questions

Đây là insight breakthrough lớn nhất của Dinanjana: explicitly prompt Claude để hỏi thay vì assume.

Thay vì:

"Build me an authentication system"

Dùng:

"Before starting the authentication system, ask me questions about requirements to ensure we're building exactly what's needed."

Claude sẽ hỏi: Social login hay email/password? Sessions hay JWT? Password reset flow như thế nào? Rate limiting? 2FA?

Kết quả: output chính xác ngay từ đầu thay vì làm lại 3 lần vì missed requirements.

Best Practice #5: External Memory Files

Context của Claude reset sau mỗi session — nhưng files của bạn không reset. Tận dụng điều này:

  • plan.md: Master plan với checkboxes — Claude và bạn cùng track progress
  • architecture.md: High-level system design — đọc lại khi cần context
  • todo.md: Current working checklist
  • decisions.md: Record architectural choices và lý do đằng sau chúng

Pattern hiệu quả: khi bắt đầu session mới, prompt: "Read plan.md and architecture.md, then we'll continue from where we left off."

Best Practice #6: Active Collaboration, không phải Autonomous Mode

Treat Claude như "fast junior developer" cần direction tốt — không phải autonomous system tự làm mọi thứ.

Practices cụ thể:

  • Review mọi plan trước execution — đừng just hit enter và đi pha cà phê
  • Course-correct sớm — dùng Escape key nếu Claude đang đi sai hướng
  • Break complex changes thành steps — mỗi step có thể verify độc lập
  • Challenge assumptions: "Are you sure this is the right approach? What alternatives did you consider?"

Combining practices: Workflow thực tế

Đây là cách các best practices kết hợp trong một feature development cycle:

  1. Clarifying questions first: "Before we start, ask me about requirements"
  2. Plan Mode: Review architecture trước khi touch code
  3. Appropriate thinking level: "think hard" cho feature này
  4. CLAUDE.md check: Claude đã load project conventions
  5. External memory: Update decisions.md sau khi chọn approach
  6. Active review: Không approve blindly — đọc và hiểu

Kết quả thực tế

Dinanjana báo cáo: sau khi áp dụng consistent, implementations "shift from requiring extensive debugging to being remarkably close to production-ready."

Không phải vì Claude thông minh hơn — mà vì process tốt hơn dẫn đến context tốt hơn, dẫn đến output tốt hơn.

Liên kết với broader Claude Code ecosystem

Những practices này bổ sung hoàn hảo với:

  • Agent Teams: CLAUDE.md tốt = agents làm việc với nhau hiệu quả hơn nhiều
  • MCP Servers: Plan Mode kết hợp với external data = better planning
  • CLAUDE.md nâng cao: Deep dive vào cấu trúc và patterns

Tổng kết

Core philosophy của Dinanjana: "The secret isn't in the prompts — it's in the process."

Plan first, think appropriately hard, collaborate actively, và teach Claude về project của bạn qua .claude files. Đây không phải hacks hay tricks — đây là fundamentals của working effectively với AI pair programmer.

Nguồn tham khảo

Tính năng liên quan:CLAUDE.mdPlan ModeExtended thinkingClaude Code

Bai viet co huu ich khong?

Bản quyền thuộc về tác giả. Vui lòng dẫn nguồn khi chia sẻ.

Bình luận (0)
Ảnh đại diện
Đăng nhập để bình luận...
Đăng nhập để bình luận
  • Đang tải bình luận...

Đăng ký nhận bản tin

Nhận bài viết hay nhất về sản phẩm và vận hành, gửi thẳng vào hộp thư của bạn.

Bảo mật thông tin. Hủy đăng ký bất cứ lúc nào. Chính sách bảo mật.