llm-prompt-optimizer – skill Agent & Tự động hóa cho agent AI
Dùng khi cải thiện prompt cho bất kỳ LLM nào. Áp dụng các kỹ thuật prompt engineering đã được kiểm chứng để tăng chất lượng đầu ra, giảm ảo giác và cắt giảm số token sử dụng.
Cài skill llm-prompt-optimizer bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/llm-prompt-optimizer-99730.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /llm-prompt-optimizer – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/llm-prompt-optimizer-99730.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $llm-prompt-optimizer – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/llm-prompt-optimizer-99730.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /llm-prompt-optimizer – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/llm-prompt-optimizer-99730.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /llm-prompt-optimizer – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
LLM Prompt Optimizer
Overview
This skill transforms weak, vague, or inconsistent prompts into precision-engineered instructions that reliably produce high-quality outputs from any LLM (Claude, Gemini, GPT-4, Llama, etc.). It applies systematic prompt engineering frameworks — from zero-shot to few-shot, chain-of-thought, and structured output patterns.
When to Use This Skill
- Use when a prompt returns inconsistent, vague, or hallucinated results
- Use when you need structured/JSON output from an LLM reliably
- Use when designing system prompts for AI agents or chatbots
- Use when you want to reduce token usage without sacrificing quality
- Use when implementing chain-of-thought reasoning for complex tasks
- Use when prompts work on one model but fail on another
Step-by-Step Guide
1. Diagnose the Weak Prompt
Before optimizing, identify which problem pattern applies:
| Problem | Symptom | Fix |
|---------|---------|-----|
| Too vague | Generic, unhelpful answers | Add role + context + constraints |
| No structure | Unformatted, hard-to-parse output | Specify output format explicitly |
| Hallucination | Confident wrong answers | Add "say I don't know if unsure" |
| Inconsistent | Different answers each run | Add few-shot examples |
| Too long | Verbose, padded responses | Add length constraints |
2. Apply the RSCIT Framework
Every optimized prompt should have:
- R — Role: Who is the AI in this interaction?
- S — Situation: What context does it need?
- C — Constraints: What are the rules and limits?
- I — Instructions: What exactly should it do?
- T — Template: What should the output look like?
Before (weak prompt):
Explain machine learning.After (optimized prompt):
You are a senior ML engineer explaining concepts to a junior developer.
Context: The developer has 1 year of Python experience but no ML background.
Task: Explain supervised machine learning in simple terms.
Constraints:
- Use an analogy from everyday life
- Maximum 200 words
- No mathematical formulas
- End with one actionable next step
Format: Plain prose, no bullet points.3. Chain-of-Thought (CoT) Pattern
For reasoning tasks, ask for a concise explanation, key assumptions and checkable result rather than private internal chain-of-thought:
Solve the problem and give the final answer with a concise explanation of the key steps and verification.
Problem: [your problem here]
Thinking process:
Step 1: [identify what's given]
Step 2: [identify what's needed]
Step 3: [apply logic or formula]
Step 4: [verify the answer]
Final Answer:4. Few-Shot Examples Pattern
Provide 2-3 examples to establish the pattern:
Classify the sentiment of customer reviews as POSITIVE, NEGATIVE, or NEUTRAL.
Examples:
Review: "This product exceeded my expectations!" -> POSITIVE
Review: "It arrived broken and support was useless." -> NEGATIVE
Review: "Product works as described, nothing special." -> NEUTRAL
Now classify:
Review: "[your review here]" ->5. Structured JSON Output Pattern
Extract the following information from the text below and return it as valid JSON only.
Do not include any explanation or markdown — just the raw JSON object.
Schema:
{
"name": string,
"email": string | null,
"company": string | null,
"role": string | null
}
Text: [input text here]6. Reduce Hallucination Pattern
Answer the following question based ONLY on the provided context.
If the answer is not contained in the context, respond with exactly: "I don't have enough information to answer this."
Do not make up or infer information not present in the context.
Context:
[your context here]
Question: [your question here]7. Prompt Compression Techniques
Reduce token count without losing effectiveness:
# Verbose (expensive)
"Please carefully analyze the following code and provide a detailed explanation of
what it does, how it works, and any potential issues you might find."
# Compressed (efficient, same quality)
"Analyze this code: explain what it does, how it works, and flag any issues."Best Practices
- ✅ Do: Always specify the output format (JSON, markdown, plain text, bullet list)
- ✅ Do: Use delimiters (
- ✅ **Do:** Test prompts with edge cases (empty input, unusual data)
- ✅ **Do:** Version your system prompts in source control
- ✅ **Do:** Add "think step by step" for math, logic, or multi-step tasks
- ❌ **Don't:** Use negative-only instructions ("don't be verbose") — add positive alternatives
- ❌ **Don't:** Assume the model knows your codebase context — always include it
- ❌ **Don't:** Use the same prompt across different models without testing — they behave differently
## Prompt Audit Checklist
Before using a prompt in production:
- [ ] Does it have a clear role/persona?
- [ ] Is the output format explicitly defined?
- [ ] Are edge cases handled (empty input, ambiguous data)?
- [ ] Is the length appropriate (not too long/short)?
- [ ] Has it been tested on 5+ varied inputs?
- [ ] Is hallucination risk addressed for factual tasks?
## Troubleshooting
**Problem:** Model ignores format instructions
**Solution:** Use supported structured-output/schema constraints where available and validate responses with a parser. Prompt wording alone cannot guarantee valid JSON; bound retries and handle refusal or truncation.
**Problem:** Inconsistent results between runs
**Solution:** Lower the temperature setting (0.0-0.3 for factual tasks). Add more few-shot examples.
**Problem:** Prompt works in playground but fails in production
**Solution:** Check if system prompt is being sent correctly. Verify token limits aren't being exceeded (use a token counter).
**Problem:** Output is too long
**Solution:** Add explicit word/sentence limits: "Respond in exactly 3 bullet points, each under 20 words."
## Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.Skill liên quan
- loki-mode – Quy trình đa tác nhân phiên bản 2.35.x (cũ) để biến PRD đã giới hạn phạm vi thành triển…
- longbridge-derivatives – Hướng dẫn tuyển chọn từ nguồn gốc cho Longbridge Derivatives; dùng khi quy trình phù hợp…
- longbridge-quant – Hướng dẫn tuyển chọn từ nguồn gốc cho Longbridge Quant; dùng khi quy trình phù hợp với…
- lore – Bộ nhớ dự án Markdown cho AI agent. Dùng cho quyết định, kiến trúc, quy ước, phạm vi…
- m365-agents-dotnet – Microsoft 365 Agents SDK cho .NET. Xây dựng agent đa kênh cho Teams/M365/Copilot Studio…
- m365-agents-py – Microsoft 365 Agents SDK cho Python. Xây dựng agent đa kênh cho Teams/M365/Copilot…
- m365-agents-ts – Microsoft 365 Agents SDK cho TypeScript/Node.js.
- mailchimp-automation – Tự động hóa email marketing trên Mailchimp, bao gồm chiến dịch, danh sách người nhận…