Prompt engineering guide
Skill The-AI-Directory-Company/agents-and-skills/skills/prompt-engineering-guide
70+ AI agent templates and 55+ skill definitions for Claude Code, Cursor, Windsurf, and other AI coding tools. Community-maintained, MIT licensed. Follows the Agent Skills specification.
npx -y skills add The-AI-Directory-Company/agents-and-skills --skill prompt-engineering-guideAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Design, test, and optimize LLM prompts systematically — with evaluation frameworks, chain-of-thought patterns, output formatting, and iteration methodology for reliable AI outputs.
SKILL.md
6.4 KB, as published. Nobody here has run it
Prompt Engineering Guide
Before you start
Gather the following from the user. If anything is missing, ask before proceeding:
- What task should the prompt accomplish? (Classification, generation, extraction, transformation, summarization)
- What model will run the prompt? (GPT-4, Claude, Gemini, open-source — capabilities differ)
- What does the input look like? (Free text, structured data, documents, code)
- What does the ideal output look like? (JSON, markdown, plain text — provide 2-3 real examples)
- What are the failure modes? (Hallucinations, wrong format, refusals, missing edge cases)
- How will you evaluate quality? (Human review, automated checks, ground truth comparison)
Prompt design template
1. Task Definition
Write a clear system prompt that defines the task, role, and constraints:
You are a [role] that [core task].
Your job is to [specific action] given [input description].
Rules:
- [Constraint 1: e.g., respond only in valid JSON]
- [Constraint 2: e.g., never fabricate information not in the source]
- [Constraint 3: e.g., if uncertain, say "I don't know"]
Output format:
[Exact schema or structure the model must follow]
Every sentence should constrain behavior or clarify expectations. Avoid vague instructions like "be helpful."
2. Few-Shot Examples
Include 2-5 input-output examples in the prompt. Examples teach format and edge cases more reliably than instructions alone.
Input: "The product crashed twice today and support hasn't responded."
Output: {"sentiment": "negative", "topics": ["reliability", "support"], "urgency": "high"}
Input: "Love the new dashboard — the filters are exactly what I needed."
Output: {"sentiment": "positive", "topics": ["dashboard", "filters"], "urgency": "low"}
Cover the typical case, a boundary case, and the hardest case. If the model gets the hard example right, it handles easy cases.
3. Chain-of-Thought Patterns
For reasoning tasks, instruct the model to show its work before answering:
- Step-by-step: "Think through this step by step before giving your final answer." Best for math and multi-step analysis.
- Explain-then-answer: "First explain your reasoning, then provide the answer on a new line starting with 'Answer:'." Best when you need to audit logic.
- Self-critique: "After drafting your response, review it for errors before outputting the final version." Best for generation tasks.
When chain-of-thought adds tokens without improving accuracy (simple classification), skip it.
4. Output Formatting
Specify the exact output structure. Ambiguity in format is the top cause of parsing failures.
Respond with a JSON object matching this schema exactly:
{
"summary": "string (1-2 sentences)",
"confidence": "number (0.0-1.0)",
"categories": ["string array, from: billing, technical, feature-request, other"],
"requires_escalation": "boolean"
}
Do not include any text outside the JSON object.
For structured outputs, provide the schema and a completed example. For free-text, specify length, tone, and inclusions/exclusions.
5. Evaluation Framework
Define how you will measure prompt quality before deploying. Build a test set of 20-50 examples with expected outputs.
| Metric | Method | Pass Threshold |
|---------------------|-------------------------|----------------|
| Format compliance | JSON schema validation | 100% |
| Classification acc. | Match against labels | >90% |
| Hallucination rate | Human review sample | <5% |
| Latency (p95) | API response time | <3s |
| Cost per request | Token count * price | <$0.02 |
Run the full test set after every prompt change. A prompt that improves accuracy but breaks format compliance is a regression, not an improvement.
6. Iteration Methodology
Follow this loop for every prompt revision:
- Run the current prompt against the full test set. Record scores.
- Identify failure patterns. Group errors by type: format, accuracy, hallucination, edge cases.
- Change one thing. One modification per iteration — instructions, examples, or structure.
- Re-run the test set. Compare scores to the previous version.
- Keep or revert. If any metric degrades, revert and try a different approach.
Log every iteration: what changed, the hypothesis, and results. Prompt engineering without records is guessing.
Quality checklist
Before delivering a prompt, verify:
- System prompt states task, role, and constraints concretely — no vague instructions
- Output format specified with a schema or example, not just described
- 2-5 few-shot examples cover typical, boundary, and difficult cases
- Chain-of-thought included only when it measurably improves accuracy
- Test set of 20+ examples exists with expected outputs
- Evaluation metrics and thresholds defined before testing begins
- Prompt tested on the target model — not assumed to transfer from another
- Token usage and cost within budget for expected volume
Common mistakes to avoid
- Writing instructions instead of showing examples. When instructions and examples conflict, the model follows examples. One example teaches format better than a paragraph of description.
- Optimizing on vibes. "This feels better" is not evaluation. Build a test set and compare versions quantitatively.
- Changing multiple things at once. One change per iteration — otherwise you cannot attribute improvement or regression.
- Ignoring model differences. A prompt tuned for GPT-4 may underperform on Claude or Gemini. Test on the target model.
- Skipping edge cases in examples. Happy-path-only examples cause hallucination on unusual inputs. Include the hardest realistic cases.
- Over-engineering simple tasks. Start minimal and add complexity only when the test set demands it.
Gives 0 of the 12 instructions most prompt engineering skills give
Counted across 563 of the 626 authors here whose files we hold, read 2026-08-06
- ask at most three clarifying questionsin 22 of 563, across 15 files
- respond in the user input languagein 14 of 563, across 9 files
- preserve the original intentin 13 of 563, across 11 files
- Establish baseline metrics and collect representative examplesin 12 of 563, across 2 files
- Identify failure modes and prioritize high-impact fixesin 12 of 563, across 2 files
- Apply prompt and workflow improvements with measurable goalsin 12 of 563, across 2 files
- Roll back quickly if quality or safety metrics regressin 12 of 563, across 2 files
- validate changes with tests and roll out in controlled stagesin 12 of 563, across 2 files
- generate quantitative baseline performance reportsin 12 of 563, across 2 files
- create representative test scenariosin 12 of 563, across 2 files
- treat prompts as codein 12 of 563, across 5 files
- test prompts on diverse inputsin 12 of 563, across 8 files
Said here and by no other author read
- gather task requirements from the user
- write a clear system prompt defining constraints
- cover typical boundary and difficult cases
- instruct the model to show work for reasoning tasks
- build a test set of 20-50 examples
- test on the target model
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.