After years of working with AI coding assistants, the community has distilled principles that help maximize efficiency and minimize risks.
Sau nhiều năm làm việc với AI coding assistants, cộng đồng đã đúc kết được những nguyên tắc giúp tối đa hóa hiệu quả và giảm thiểu rủi ro.
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.
Luôn đọc và hiểu những gì Claude đề xuất trước khi approve. AI thông minh nhưng không hoàn hảo - nó có thể hiểu sai yêu cầu hoặc tạo code có lỗi logic tinh vi.
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!Commit after each small milestone. This creates safe restore points if Claude goes wrong in subsequent steps.
Commit sau mỗi milestone nhỏ. Điều này tạo điểm khôi phục an toàn nếu Claude đi sai hướng ở các bước tiếp theo.
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?Focus on one task before moving to another. This makes debugging and rollback easier.
Tập trung vào một tác vụ trước khi chuyển sang tác vụ khác. Điều này giúp dễ debug và rollback hơn.
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"Invest time in writing a good CLAUDE.md. This file is read at startup, so important conventions will always be followed.
Đầu tư thời gian viết CLAUDE.md tốt. File này được đọc mỗi khi bắt đầu, nên các quy ước quan trọng sẽ luôn được tuân thủ.
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 testsChoose the appropriate skill for the task instead of always using autopilot for everything.
Chọn skill phù hợp với tác vụ thay vì luôn dùng autopilot cho mọi thứ.
1# Task matching2Simple bug fix → Direct or /ralph3Code review → /review4Commit message → /commit5Full feature → /autopilot6Multiple parallel → /ultrawork7Planning only → /planDon't blindly trust AI output. Always verify results, especially for code involving security, database, or payment.
Đừng tin tưởng mù quáng vào output của AI. Luôn verify kết quả, đặc biệt với code liên quan đến security, database, hoặc payment.
Don't paste the entire codebase into one prompt. Claude works better with focused, relevant context.
Đừng paste toàn bộ codebase vào một prompt. Claude hoạt động tốt hơn với context tập trung, có liên quan.
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"Vague requests lead to unexpected results. The more specific, the better.
Yêu cầu mơ hồ dẫn đến kết quả không như mong đợi. Càng cụ thể càng tốt.
Don't skip tests because 'AI-written code must be correct'. AI can create code that looks right but has unhandled edge cases.
Đừng bỏ qua tests vì 'code AI viết chắc đúng rồi'. AI có thể tạo code trông đúng nhưng có edge cases không xử lý.
- Never paste API keys, passwords, or secrets into prompts.
Không paste API keys, passwords hoặc secrets vào prompts.
- Carefully review any code related to authentication.
Review carefully bất kỳ code nào liên quan đến authentication.
- Don't auto-approve bash commands you don't understand.
Đừng auto-approve các lệnh bash mà bạn không hiểu.
- Use sandbox or separate branch for risky experiments.
Sử dụng sandbox hoặc branch riêng cho các thử nghiệm rủi ro.
Claude được thiết kế để từ chối các yêu cầu gây hại, nhưng bạn vẫn là người chịu trách nhiệm cuối cùng về code được deploy.
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
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?
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.
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
.mdWhy 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?