Prompt Library Minimal
Overview
คลัง prompts ที่ optimize แล้วให้ใช้ token น้อยที่สุด แต่ยังคงประสิทธิภาพ - เหมาะสำหรับ production ที่ต้องการลด cost
Why This Matters
- •Cost savings: ลด token usage 50-70%
- •Speed: น้อย token = response เร็วขึ้น
- •Proven: Tested และใช้งานจริง
- •Reusable: Copy-paste ได้เลย
Code Review
Verbose (❌ 85 tokens)
code
I would like you to please review this code carefully and provide detailed feedback on potential bugs, performance issues, security vulnerabilities, and code quality concerns. Please also suggest improvements and best practices that could be applied.
Minimal (✅ 12 tokens)
code
Review for bugs, performance, security. Suggest improvements.
Savings: 86%
Bug Fix
Verbose (❌ 120 tokens)
code
I'm experiencing an issue where the login function is not working properly. When users try to log in, they receive an error message. Could you please help me identify what might be causing this problem and suggest a solution? Here is the relevant code...
Minimal (✅ 18 tokens)
code
Login fails with error. Fix: [code] Expected: successful login Actual: error message
Savings: 85%
Code Generation
Verbose (❌ 95 tokens)
code
Please write a function that will calculate the sum of two numbers. The function should accept two parameters and return their sum. Please include proper error handling and add comments explaining what the code does.
Minimal (✅ 15 tokens)
code
Function: sum two numbers Include: error handling, comments Language: TypeScript
Savings: 84%
Refactoring
Verbose (❌ 110 tokens)
code
I have this code that works but I think it could be improved. Could you please refactor it to make it more readable, maintainable, and efficient? Please follow best practices and modern coding standards. Also, please explain the changes you make.
Minimal (✅ 8 tokens)
code
Refactor for readability, efficiency: [code]
Savings: 93%
Documentation
Verbose (❌ 75 tokens)
code
Please write comprehensive documentation for this function including a description of what it does, the parameters it accepts, what it returns, and provide usage examples.
Minimal (✅ 6 tokens)
code
Document function: [code]
Savings: 92%
Testing
Verbose (❌ 90 tokens)
code
I need you to write unit tests for this function. The tests should cover normal cases, edge cases, and error cases. Please use Jest as the testing framework and follow testing best practices.
Minimal (✅ 10 tokens)
code
Jest tests (normal, edge, error): [code]
Savings: 89%
Debugging
Verbose (❌ 100 tokens)
code
I'm getting an error in my code and I can't figure out what's wrong. The error message says "Cannot read property 'name' of undefined". Can you help me understand what's causing this and how to fix it?
Minimal (✅ 12 tokens)
code
Error: Cannot read property 'name' of undefined Code: [snippet] Fix?
Savings: 88%
Optimization
Verbose (❌ 85 tokens)
code
This code is running slowly and I need to optimize it for better performance. Can you analyze it and suggest ways to make it faster? Please focus on algorithmic improvements and best practices.
Minimal (✅ 8 tokens)
code
Optimize for speed: [code]
Savings: 91%
Template Library
Code Review Template
code
Review for [aspects]: [code]
Bug Fix Template
code
[Issue] fails with [error] Code: [snippet] Expected: [behavior] Actual: [behavior]
Feature Request Template
code
Add [feature]: - Input: [description] - Output: [description] - Edge cases: [list]
Refactor Template
code
Refactor for [goals]: [code]
Test Template
code
[Framework] tests ([cases]): [code]
Output Format Specifications
JSON Output
code
Output JSON:
{
"field1": "...",
"field2": "..."
}
List Output
code
List 5 items: 1. ...
Code Only
code
Code only, no explanation: [requirements]
Summary
code
Summary (≤50 words): [content]
Constraints
Length Constraints
code
Max 100 words Max 10 lines ≤3 bullet points
Format Constraints
code
TypeScript only No comments Use async/await
Style Constraints
code
Functional style No loops (use map/filter) Immutable
Best Practices
1. Use Imperative Mood
code
❌ "Could you please write..." ✅ "Write..." ❌ "I would like you to..." ✅ "Create..."
2. Specify Output Format
code
❌ "Explain this code" ✅ "Explain in 3 bullet points"
3. Be Specific
code
❌ "Make it better" ✅ "Optimize for speed"
4. Remove Pleasantries
code
❌ "Thank you for your help" ✅ [omit] ❌ "Please and thank you" ✅ [omit]
5. Use Abbreviations
code
❌ "TypeScript" ✅ "TS" ❌ "JavaScript" ✅ "JS" ❌ "database" ✅ "DB"
Quick Reference
Common Tasks
| Task | Minimal Prompt | Tokens |
|---|---|---|
| Code review | Review for bugs, performance: | 4 |
| Bug fix | Fix: [error] | 2 |
| Generate | Function: [description] | 2 |
| Refactor | Refactor for [goal]: | 3 |
| Test | Tests ([cases]): | 2 |
| Document | Document: | 1 |
| Optimize | Optimize for [metric]: | 3 |
| Debug | Error: [message]. Fix? | 3 |
Measurement
Before Optimization
code
Average prompt: 95 tokens Cost per 1000 requests: $4.75
After Optimization
code
Average prompt: 15 tokens Cost per 1000 requests: $0.75 Savings: 84%
Summary
Prompt Library Minimal: Prompts ที่ใช้ token น้อยที่สุด
Savings:
- •Code review: 86%
- •Bug fix: 85%
- •Generation: 84%
- •Refactoring: 93%
- •Documentation: 92%
Principles:
- •Imperative mood
- •No pleasantries
- •Specify format
- •Be specific
- •Use abbreviations
Average savings: 85-90%
Usage:
code
Copy template → Fill in details → Use