Vibe
Extended Prompt Cheatsheet for Developers
Tips, Tricks, and Prompt Structures for AI-Powered Coding
✅ Bảng 1: Prompt Tips cho Developer khi Coding với AI
| STT | Tên Tips | Mô tả ngắn gọn | Ví dụ Prompt |
|---|---|---|---|
| 1 | Step-by-step | Yêu cầu AI phân tích và xử lý theo từng bước, rõ ràng | Hãy chia nhỏ task thành từng bước, chỉ thực hiện bước 1 trước. |
| 2 | Role Playing | Gán vai trò cho AI để đưa ra câu trả lời chuyên sâu | Đóng vai senior backend engineer, giúp tôi tối ưu đoạn code Spring Boot sau. |
| 3 | Ask before act | Yêu cầu AI hỏi lại trước khi thực hiện nếu chưa đủ dữ kiện | Trước khi generate code, hãy hỏi tôi framework hoặc kiến trúc tôi đang dùng. |
| 4 | Explain before code | Yêu cầu AI giải thích logic trước, rồi mới sinh mã | Giải thích ý tưởng, rồi hãy generate code TypeScript tương ứng. |
| 5 | Compare options | So sánh giải pháp (lib, cách code...) trước khi chọn | So sánh cách paginate với JPA và QueryDSL, ưu nhược điểm từng cách. |
| 6 | Minimal output | Chỉ hiển thị phần code chính, không giải thích lan man | Chỉ hiện code cần thiết, bỏ qua lời giải thích. |
| 7 | Test-driven | Yêu cầu viết test trước, rồi mới viết code chính | Viết test cho chức năng upload ảnh, rồi sinh code thực thi cho test pass. |
| 8 | Refactor this | Yêu cầu tối ưu, sửa lại mã cũ theo clean code | Refactor đoạn code này để dễ test và áp dụng SOLID. |
| 9 | Debug this | Gửi log/error và yêu cầu AI phân tích & sửa lỗi | Đây là lỗi khi chạy build, giải thích & gợi ý cách sửa. |
| 10 | Add comments | Bảo AI thêm mô tả, doc, annotation, Swagger... | Thêm mô tả tiếng Việt cho các API dưới dạng Swagger annotation. |
✅ Bảng 2: Prompt Action + Mẫu câu thường dùng (kèm phân loại hành động)
📘 Bảng 2.1: Câu Prompt Thường Dùng Cho Developer (kèm loại hành động)
| Mẫu câu prompt | Hành động chính | Ví dụ cụ thể | Loại hành động (Prompt Type) |
|---|---|---|---|
| Generate a... | Sinh code mới, template, class | Generate a DTO for user registration. | 🧱 Generate / Create |
| Create an API for... | Tạo API REST/GraphQL | Create an API for uploading images with metadata. | 🧱 Generate / Create |
| Convert this to... | Chuyển đổi định dạng, công nghệ | Convert this SQL query to QueryDSL. | 🔄 Convert / Refactor |
| Refactor this to... | Tối ưu mã theo chuẩn | Refactor this method using Java Stream API. | 🔄 Convert / Refactor |
| Explain what this does | Giải thích đoạn code | Explain what this lambda expression does. | 📖 Explain / Analyze |
| Analyze this... | Phân tích lỗi, hiệu năng, logic | Analyze this method for potential null pointer issues. | 📖 Explain / Analyze |
| Read and summarize... | Đọc hiểu và tóm tắt | Read and summarize the purpose of this service class. | 📖 Explain / Analyze |
| Research and suggest... | Tìm hiểu và đề xuất | Research ways to optimize Spring Boot startup time and suggest changes. | 📚 Research / Review |
| Add support for... | Mở rộng chức năng | Add support for pagination and sorting in this endpoint. | 📦 Add Feature / Support |
| Write unit test for... | Viết kiểm thử | Write unit test for FileStorageService using Mockito. | 🧪 Test / Validate |
| Compare X vs Y | So sánh giữa 2 công nghệ | Compare Redis vs Memcached for caching session tokens. | 📚 Research / Compare |
| List pros and cons of... | Phân tích ưu – nhược điểm | List pros and cons of using Docker Compose in local development. | 📚 Research / Compare |
| Act as a... | Giao vai trò kỹ thuật cho AI | Act as a senior DevOps engineer and review this Helm chart. | 🎭 Role Acting |
| Suggest best practice for... | Gợi ý clean code, chuẩn kỹ thuật | Suggest best practice for DTO validation in Spring Boot. | 📚 Research / Review |
📊 Bảng 2.2: Tổng Hợp Các Loại Hành Động Prompt (Prompt Action Types)
| Loại hành động | Mô tả | Từ khóa prompt thường dùng |
|---|---|---|
| 🧱 Generate / Create | Tạo mới file, class, module, API,... | generate, create, build, scaffold, construct |
| 🔄 Convert / Refactor | Chuyển đổi kỹ thuật, clean code, viết lại tốt hơn | convert, refactor, rewrite, restructure |
| 📖 Explain / Analyze | Đọc hiểu, giải thích, phân tích logic, bug, performance | explain, read, analyze, inspect, understand |
| 🧪 Test / Validate | Viết test, thêm validation, mock data | write test, validate, mock, generate unit test |
| 📚 Research / Compare | Tìm hiểu, đánh giá, so sánh giải pháp | research, compare, pros and cons, review, audit |
| 🎯 Improve / Optimize | Tối ưu hóa logic, tăng hiệu năng, giảm độ phức tạp | optimize, reduce complexity, improve readability, simplify |
| 💬 Comment / Document | Thêm tài liệu, mô tả code, doc, Swagger | add comment, document, javadoc, generate docs |
| 📦 Add Feature / Support | Thêm tính năng, tích hợp hoặc mở rộng logic | add support, extend, integrate with, enhance |
| 🎭 Role Acting | Đóng vai chuyên gia kỹ thuật để AI gợi ý sâu hơn | act as, pretend you are, simulate role |