A prompt is how you communicate with AI. A good prompt helps Claude understand exactly what you need, while vague prompts lead to unexpected results.
Prompt là cách bạn giao tiếp với AI. Một prompt tốt giúp Claude hiểu chính xác những gì bạn cần, trong khi prompt mơ hồ dẫn đến kết quả không như mong đợi.
Prompting skill is not about learning 'magic words' - it's about communicating clearly, providing appropriate context, and setting correct expectations.
Kỹ năng prompting không phải về việc học các 'magic words' - mà là về việc giao tiếp rõ ràng, cung cấp context phù hợp và đặt kỳ vọng đúng đắn.
Instead of generic requests, describe exactly what you want. Include details about input, output, and constraints.
Thay vì yêu cầu chung chung, hãy mô tả chính xác những gì bạn muốn. Bao gồm chi tiết về input, output và các ràng buộc.
1# Bad - Too vague2"fix the bug"34# Good - Specific5"fix the login bug where users get 401 error after password reset"67# Bad - No context8"add validation"910# Good - With context11"add email validation to the signup form -12check format and show error below the input field"Claude works better when it understands the big picture. Explain why you need this and where it fits in the system.
Claude làm việc tốt hơn khi hiểu bức tranh toàn cảnh. Giải thích tại sao bạn cần điều này, nó nằm trong phần nào của hệ thống.
1# Without context2"create a user model"34# With context5"create a user model for our e-commerce app.6Users can have multiple addresses, a shopping cart,7and order history. We use PostgreSQL with Prisma."Instead of requesting a complex feature in one prompt, break it into smaller steps. This helps Claude focus and lets you review each part.
Thay vì yêu cầu một tính năng phức tạp trong một prompt, hãy chia thành các bước nhỏ hơn. Điều này giúp Claude tập trung và bạn có thể review từng phần.
1# One big request (risky)2"build a complete authentication system with3login, signup, password reset, and OAuth"45# Step by step (better)61. "create the user database schema for auth"72. "add signup endpoint with email validation"83. "add login endpoint with JWT tokens"94. "add password reset flow with email"105. "add Google OAuth integration"Asking Claude to explain before acting helps confirm it understands the problem correctly.
Yêu cầu Claude giải thích trước khi hành động giúp bạn xác nhận nó hiểu đúng vấn đề.
1"explain how the current caching system works,2then suggest improvements for handling cache invalidation"34"analyze the performance bottleneck in the search function,5then propose a solution"Providing examples of desired input/output helps Claude understand exactly the format and style you need.
Cung cấp ví dụ về input/output mong muốn giúp Claude hiểu chính xác format và style bạn cần.
1"convert this data to the following format:23Input:4{ name: 'John', age: 30 }56Expected output:7<user>8 <name>John</name>9 <age>30</age>10</user>1112Now convert this: { name: 'Jane', age: 25, role: 'admin' }"Setting clear constraints helps Claude produce code that fits your technical requirements.
Đặt ra các ràng buộc rõ ràng giúp Claude tạo ra code phù hợp với yêu cầu kỹ thuật của bạn.
1"create a rate limiter with these constraints:2- max 100 requests per minute per user3- use Redis for storage4- return 429 status when limit exceeded5- include retry-after header6- must be middleware compatible with Express"1# Avoid2"make it better"3"fix the errors"4"improve performance"56# Instead7"reduce the API response time from 2s to under 500ms"8"fix the TypeScript errors in UserService.ts"9"add index to speed up user lookup by email"1# Avoid - overwhelming2"refactor the entire codebase to use TypeScript,3add tests, improve error handling, and optimize for performance"45# Instead - one thing at a time6"convert utils/helpers.js to TypeScript"7# then after completion:8"add unit tests for utils/helpers.ts"1# Missing context2"why isn't this working?"34# With context5"this function should return filtered users but returns empty array.6Here's the input data: [...]7Here's the function: [...]8What's wrong?"Asking Claude to think step by step helps with complex problems requiring logical analysis.
Yêu cầu Claude suy nghĩ từng bước giúp với các vấn đề phức tạp cần phân tích logic.
1"analyze this algorithm step by step:21. identify the time complexity of each loop32. find any redundant operations43. suggest optimizations54. show the improved version with explanations"Putting Claude in a specific role can help it approach problems from the right perspective.
Đặt Claude vào một vai trò cụ thể có thể giúp nó tiếp cận vấn đề từ góc nhìn phù hợp.
1"as a security expert, review this authentication code2and identify potential vulnerabilities"34"as a senior React developer, review this component5for best practices and performance issues"Prompting là kỹ năng - bạn sẽ tốt hơn theo thời gian. Đừng ngại thử nghiệm và học từ những gì hiệu quả.
Key Takeaways
Điểm Chính
- Be specific - include details about input, output, and constraintsCụ thể - bao gồm chi tiết về input, output và ràng buộc
- Provide context - explain why and where it fits in the systemCung cấp context - giải thích tại sao và nó nằm ở đâu trong hệ thống
- Break down large tasks into smaller, reviewable stepsChia nhỏ tác vụ lớn thành các bước nhỏ hơn, có thể review
- Show examples when you need specific formatsĐưa ví dụ khi bạn cần format cụ thể
Practice
Test your understanding of this chapter
Which prompt is more effective?
Prompt nào hiệu quả hơn?
You should always ask for an entire feature in one prompt to save time.
Bạn nên luôn yêu cầu toàn bộ tính năng trong một prompt để tiết kiệm thời gian.
Complete the prompting pattern name for providing sample input/output
Hoàn thành tên pattern prompting cho việc cung cấp input/output mẫu
Show What is 'Chain of Thought' prompting?
'Chain of Thought' prompting là gì?