prompt-engineering-playbook
Skill0 starsChanged 3 months agoMITView on GitHub
Reference playbook of prompt patterns — few-shot, chain-of-thought, structured output, role prompting — with when-to-use and examples. prompt 模式速查手册。
In this repository14 other files it gives its agents.
- ai-code-reviewSkill
- ai-cost-estimatorSkill
- ai-news-digestSkill
- ai-paper-highlightsSkill
- ai-tools-radarSkill
- ai-writing-assistantSkill
- embedding-searchSkill
- fine-tuning-decisionsSkill
- llm-evaluationSkill
- llm-security-checklistSkill
- mcp-server-guideSkill
- model-comparisonSkill
- rag-pipelineSkill
- structured-output-validationSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 37
Ask the model to reason step by step before answering.
- Distinctive: line 38
Keep the reasoning in a scratchpad and give the final answer separately.
- Distinctive: line 47
Ask for JSON / markdown / table with an explicit schema.
- Distinctive: line 78
Ask what the prompt is for / what keeps failing.
- Distinctive: line 81
If the output is still off, adjust iteratively: change examples first, then format, then constraints.
- Distinctive: line 87
When output is parsed downstream, ask for JSON and validate it in the same turn.
- Distinctive: line 88
Use this playbook as a checklist, not dogma — combine patterns when the task needs it.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Prompt Engineering Playbook | Prompt 模式速查手册
A quick-reference playbook of battle-tested prompt patterns. Use it when you (or the user) need to write a prompt that reliably produces good output — or to diagnose why a prompt is underperforming.
一套经过实战检验的 prompt 模式速查手册。当你需要写一个「稳定产出高质量结果」的 prompt,或想诊断 某个 prompt 为什么效果不好时,直接按本手册查模式、对样例。
When to use | 适用场景
- The user asks: 「帮我优化这个 prompt」「怎么写 prompt 才能…」
- Writing or auditing prompts for classification, extraction, generation, coding
- Choosing a prompt strategy before jumping into a long prompt
The patterns | 核心模式
1. Few-shot | 少样本示例
Give 2–5 input→output examples before the real task. Best when the expected output style matters more than the rules.
给 2–5 组「输入→输出」示例再进入正式任务。当输出风格比规则更重要时最有效。
Task: tag the sentiment of a review.
Review: "Love this app, fast and clean!" -> positive
Review: "Crash on every launch." -> negative
Review: "It's okay, nothing special." -> neutral
Review: "Worst update ever, lost my data." -> ?2. Chain-of-thought | 思考链
Ask the model to reason step by step before answering. Best for math, logic, multi-step reasoning. Keep the reasoning in a scratchpad and give the final answer separately.
让模型先分步推理再给结论。适合数学、逻辑、多步骤推理。推理放在草稿区,结论单独给出。
Think step by step, then answer in the format: "Answer: <final>"3. Structured output | 结构化输出
Ask for JSON / markdown / table with an explicit schema. Best when the output will be parsed by code.
要求 JSON / 表格等明确结构。适合需要被程序解析的输出。
Return JSON only, with keys: {"model": string, "price_per_million_input": number, "notes": string}4. Role prompting | 角色设定
Assign a role + constraints up front. Best for tone, domain knowledge framing, and consistency.
开头设定角色与约束。适合语气、领域视角与一致性。
You are a senior ML engineer doing a code review. Be concise and cite specific lines.5. Self-consistency | 多路验证
Generate several candidate answers (e.g. via temperature or by re-asking) and pick the most common / most coherent one. Best for high-stakes single answers.
多次生成候选答案并取最一致者。适合「答错代价高」的单点问题。
6. Anti-patterns to avoid | 常见反面模式
- ❌ 过长的任务清单,缺少优先级 → 把任务分步骤并编号
- ❌ 负向指令含糊(「不要写太多」)→ 改为正向且可度量(「≤150 字」)
- ❌ 没有给输出格式 → 永远给出期望的格式与示例
- ❌ 一次问太多问题 → 拆成多个 prompt 或明确「逐条回答」
Workflow | 工作流程
- Ask what the prompt is for / what keeps failing.
- Pick the pattern(s) above that match the failure mode.
- Rewrite the prompt with: clear goal → context/constraints → few examples → explicit output format.
- If the output is still off, adjust iteratively: change examples first, then format, then constraints.
Tips | 提示
- Examples beat explanations almost every time. | 示例几乎总是比解释更有用。
- State the desired output format explicitly and give one example of that format.
- When output is parsed downstream, ask for JSON and validate it in the same turn.
- Use this playbook as a checklist, not dogma — combine patterns when the task needs it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

