ComChien TIL
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

STTTên TipsMô tả ngắn gọnVí dụ Prompt
1Step-by-stepYêu cầu AI phân tích và xử lý theo từng bước, rõ ràngHãy chia nhỏ task thành từng bước, chỉ thực hiện bước 1 trước.
2Role PlayingGá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.
3Ask before actYêu cầu AI hỏi lại trước khi thực hiện nếu chưa đủ dữ kiệnTrước khi generate code, hãy hỏi tôi framework hoặc kiến trúc tôi đang dùng.
4Explain before codeYê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.
5Compare optionsSo sánh giải pháp (lib, cách code...) trước khi chọnSo sánh cách paginate với JPA và QueryDSL, ưu nhược điểm từng cách.
6Minimal outputChỉ hiển thị phần code chính, không giải thích lan manChỉ hiện code cần thiết, bỏ qua lời giải thích.
7Test-drivenYêu cầu viết test trước, rồi mới viết code chínhViết test cho chức năng upload ảnh, rồi sinh code thực thi cho test pass.
8Refactor thisYêu cầu tối ưu, sửa lại mã cũ theo clean codeRefactor đoạn code này để dễ test và áp dụng SOLID.
9Debug thisGử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.
10Add commentsBả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 promptHành động chínhVí dụ cụ thểLoại hành động (Prompt Type)
Generate a...Sinh code mới, template, classGenerate a DTO for user registration.🧱 Generate / Create
Create an API for...Tạo API REST/GraphQLCreate 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ẩnRefactor this method using Java Stream API.🔄 Convert / Refactor
Explain what this doesGiải thích đoạn codeExplain what this lambda expression does.📖 Explain / Analyze
Analyze this...Phân tích lỗi, hiệu năng, logicAnalyze this method for potential null pointer issues.📖 Explain / Analyze
Read and summarize...Đọc hiểu và tóm tắtRead and summarize the purpose of this service class.📖 Explain / Analyze
Research and suggest...Tìm hiểu và đề xuấtResearch ways to optimize Spring Boot startup time and suggest changes.📚 Research / Review
Add support for...Mở rộng chức năngAdd 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 YSo 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ểmList pros and cons of using Docker Compose in local development.📚 Research / Compare
Act as a...Giao vai trò kỹ thuật cho AIAct as a senior DevOps engineer and review this Helm chart.🎭 Role Acting
Suggest best practice for...Gợi ý clean code, chuẩn kỹ thuậtSuggest 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 độngMô tảTừ khóa prompt thường dùng
🧱 Generate / CreateTạo mới file, class, module, API,...generate, create, build, scaffold, construct
🔄 Convert / RefactorChuyển đổi kỹ thuật, clean code, viết lại tốt hơnconvert, refactor, rewrite, restructure
📖 Explain / AnalyzeĐọc hiểu, giải thích, phân tích logic, bug, performanceexplain, read, analyze, inspect, understand
🧪 Test / ValidateViết test, thêm validation, mock datawrite test, validate, mock, generate unit test
📚 Research / CompareTìm hiểu, đánh giá, so sánh giải phápresearch, compare, pros and cons, review, audit
🎯 Improve / OptimizeTối ưu hóa logic, tăng hiệu năng, giảm độ phức tạpoptimize, reduce complexity, improve readability, simplify
💬 Comment / DocumentThêm tài liệu, mô tả code, doc, Swaggeradd comment, document, javadoc, generate docs
📦 Add Feature / SupportThêm tính năng, tích hợp hoặc mở rộng logicadd support, extend, integrate with, enhance
🎭 Role ActingĐóng vai chuyên gia kỹ thuật để AI gợi ý sâu hơnact as, pretend you are, simulate role