Skip to content
DocsUse AIadvancedBest Practices
Chapter 15 of 15·advanced·10 min read

Best Practices

Thực Hành Tốt Nhất

Tips, patterns, and anti-patterns for AI-assisted development

Hover or tap any paragraph to see Vietnamese translation

Golden Rules

After years of working with AI coding assistants, the community has distilled principles that help maximize efficiency and minimize risks.

1. Review Before Approve

Always read and understand what Claude proposes before approving. AI is smart but not perfect - it can misunderstand requirements or create code with subtle logic errors.

Review Before Approve
1# Good practice2> Claude wants to run: rm -rf node_modules3> [Review] This is safe, just cleaning dependencies4> [A]pprove56# Bad practice7> Claude wants to run: git push --force origin main8> [Blindly approve without thinking]9> ❌ You just overwrote production!

2. Commit Often

Commit after each small milestone. This creates safe restore points if Claude goes wrong in subsequent steps.

Commit Often
1# Good workflow21. Claude implements feature A32. You review and test43. /commit54. Claude implements feature B65. Something goes wrong76. git reset --hard HEAD~1  # Easy to recover!89# Risky workflow101. Claude implements A, B, C, D, E112. Bug somewhere in the middle123. Where do you even start?

3. One Thing at a Time

Focus on one task before moving to another. This makes debugging and rollback easier.

One at a Time
1# Good2"add login endpoint"3# verify it works4"add logout endpoint"5# verify it works67# Risky8"add login, logout, password reset,92FA, and OAuth all at once"

Working Efficiently

Use CLAUDE.md

Invest time in writing a good CLAUDE.md. This file is read at startup, so important conventions will always be followed.

CLAUDE.md Example
1# Good CLAUDE.md structure2# CLAUDE.md34## Quick Reference5- Build: `npm run build`6- Test: `npm test`78## Code Style9- TypeScript strict mode10- Prefer named exports11- Use React Query for data fetching1213## Don't14- Don't modify .env files15- Don't add console.log in production code16- Don't skip tests

Use the Right Skill

Choose the appropriate skill for the task instead of always using autopilot for everything.

Skill Selection
1# Task matching2Simple bug fix     → Direct or /ralph3Code review        → /review4Commit message     → /commit5Full feature       → /autopilot6Multiple parallel  → /ultrawork7Planning only      → /plan

Anti-patterns to Avoid

1. Blind Trust

Don't blindly trust AI output. Always verify results, especially for code involving security, database, or payment.

2. Context Overload

Don't paste the entire codebase into one prompt. Claude works better with focused, relevant context.

Context Focus
1# Bad2"here's my entire 50 file codebase, fix the bug"34# Good5"the bug is in UserService.ts line 45.6Here's the relevant function: [paste function]7It should return filtered users but returns empty array"

3. Vague Requests

Vague requests lead to unexpected results. The more specific, the better.

4. Skipping Tests

Don't skip tests because 'AI-written code must be correct'. AI can create code that looks right but has unhandled edge cases.

Security Best Practices

  • Never paste API keys, passwords, or secrets into prompts.
  • Carefully review any code related to authentication.
  • Don't auto-approve bash commands you don't understand.
  • Use sandbox or separate branch for risky experiments.
Warning
Claude is designed to refuse harmful requests, but you are ultimately responsible for deployed code.

Debugging with AI

Bug Report Template
1# Effective bug report to Claude2"Bug: Users can't login after password reset34Steps to reproduce:51. Reset password via email link62. Set new password (succeeds)73. Try to login with new password84. Get 401 Unauthorized910Expected: Login succeeds11Actual: 401 error1213Relevant code: [paste auth.ts login function]14Error log: [paste relevant error]"

Key Takeaways

Điểm Chính

  • Always review before approving - AI is not perfectLuôn review trước khi approve - AI không hoàn hảo
  • Commit often to create safe restore pointsCommit thường xuyên để tạo điểm khôi phục an toàn
  • Invest in a good CLAUDE.md for consistent behaviorĐầu tư vào CLAUDE.md tốt cho hành vi nhất quán
  • Never skip tests or security review for AI-generated codeKhông bao giờ bỏ qua tests hoặc security review cho code AI tạo

Practice

Test your understanding of this chapter

Quiz

What should you do before approving Claude's suggested changes?

Bạn nên làm gì trước khi approve thay đổi Claude đề xuất?

True or False

You should paste your entire codebase to give Claude maximum context.

Bạn nên paste toàn bộ codebase để cho Claude context tối đa.

Code Challenge

Complete the filename for project-specific AI guidelines

Hoàn thành tên file chứa hướng dẫn AI cho dự án

.md
Quiz

Why should you commit often when working with AI?

Tại sao nên commit thường xuyên khi làm việc với AI?

← → to navigate chapters
Built: 4/8/2026, 12:01:11 PM