Use when designing prompts, evals, or LLM-powered features — prompt architecture, model selection, guardrails, and eval harnesses for prompt-as-product surfaces. Triggers on "prompt engineering", "LLM feature", "eval harness", "prompt design", "提示词工程", "LLM 特性", "prompt 设计".
Design prompts and evals as a first-class engineering deliverable. context-engineering
assembles context for a coding agent; this skill designs the prompt-as-product surface — the
prompts, model choices, guardrails, and eval harnesses behind LLM-powered features. A prompt
without an eval is an opinion; an eval without a prompt is a benchmark. Ship neither blind.
When to use
Designing an LLM-powered feature (chat, summarization, extraction, classification, generation)
Building or refining a prompt for production use
Creating an eval harness to measure prompt/model quality
Selecting a model for a specific task against cost/latency/quality trade-offs
Not for: assembling context for a coding agent (use context-engineering); general research
on a topic (use research); API contract design for non-LLM endpoints (use api-design).
Steps
1. Define the task and success criteria
State the task in one sentence, then define measurable success criteria — without these, prompt
iteration is vibes-driven. Pull from the product spec:
Input space: what inputs will the prompt receive? (vary by length, language, edge case, adversarial)
Output contract: structured output (JSON schema), free text, or classification?
Quality bar: accuracy %, format adherence %, hallucination rate, latency target, cost per call
Failure modes to prevent: what must the model NEVER do? (leak PII, invent facts, refuse valid input)
Verify: success criteria are written as measurable thresholds, not "good responses."
2. Design the prompt architecture
Structure the prompt as components, not a wall of text — each component has a job:
System / role: who the model is, what it must and must not do (guardrails live here)
Task instruction: the operation, stated precisely with the output format
Context / retrieved data: only the facts the model needs (not the whole knowledge base —
context bloat degrades accuracy and raises cost)
Few-shot examples: 2–5 input→output pairs covering the happy path and an edge case; place
before the actual input, after the instruction
Output format: explicit schema or template; use structured output (JSON mode / function
calling) when the downstream system parses the result
Separate stable parts (system, format) from variable parts (user input, retrieved context) so
prompt caching applies to the stable prefix. Verify: each prompt component is labeled and serves
one purpose; no component is duplicated.
3. Select the model
Match the model to the task's quality, latency, and cost profile — don't default to the most
capable model for every call:
Complex reasoning / generation: most capable model, accept higher latency and cost
Classification / extraction / routing: smaller, faster, cheaper model — these tasks are
over-served by frontier models
High-volume, low-stakes: the cheapest model that meets the quality bar; route edge cases to
a stronger model (cascaded / routed architecture)
Evaluate multiple models against the eval harness (step 4) before committing — model choice is
empirical, not reputational
Verify: model choice is documented with the eval comparison and the cost/latency/quality
trade-off that justified it.
4. Build the eval harness
An eval harness is the test suite for prompts. It runs the prompt against a labeled dataset and
scores the output against the success criteria:
Dataset: 50–200 examples minimum, covering happy path, edge cases, and known failure modes.
Use real production inputs where possible; synthesize adversarial cases for gaps.
Metrics: automated where possible (exact match, JSON schema validity, BLEU/ROUGE for
generation, classifier-based safety); human review for quality dimensions automation can't score.
Regression suite: the eval harness runs on every prompt or model change — a prompt tweak
that improves one case but regresses three others is a bug, not an improvement.
Verify: the eval harness runs from one command, produces a scorecard, and is committed alongside
the prompt.
5. Add guardrails
Production prompts need defenses the prompt itself cannot provide:
Input validation: reject malformed, oversized, or disallowed inputs before they reach the model
Output validation: parse and schema-check model output; reject and retry (or fallback) on
malformed output
Content filters: safety classifiers for harmful content (input and output)
PII redaction: strip sensitive data from prompts before logging; never log raw user input
that may contain PII to a shared prompt-logging system
Rate limits and cost caps: bound per-user and aggregate spend; a prompt bug that loops can
burn a budget in minutes
Verify: every guardrail has a defined failure behavior (reject, retry, fallback) — silent
pass-through is not a guardrail.
6. Iterate against evals
Iterate the prompt against the eval harness — change one variable at a time (instruction,
examples, model, temperature), re-run evals, keep the change only if the scorecard improves
without regression. Document prompt versions and their eval scores alongside the prompt, the way
code commits pair with test results.
Output:docs/design/PROMPT.md — the prompt design document: task definition, success
criteria, prompt architecture (component breakdown), model selection rationale, eval harness
description and dataset, guardrails, and version history with eval scores.
Verify
Task stated in one sentence; success criteria are measurable thresholds
Prompt structured into labeled components (system, instruction, context, examples, format)
Stable and variable parts separated for prompt caching
Model selected via eval comparison, not reputation; trade-off documented
Eval harness: 50+ examples, automated metrics, runs from one command, committed
Guardrails on input, output, content, PII, and cost — each with a failure behavior
Prompt changes paired with eval re-runs; no regression accepted
docs/design/PROMPT.md produced with architecture + eval + guardrails + version history
Red flags: a single wall-of-text prompt with no structure; choosing the most expensive model
for a classification task; shipping a prompt with no eval; logging raw prompts with user PII; no
output schema validation (trusting the model to always return valid JSON); prompt iteration by
vibes without a scorecard; no cost cap on a production prompt.
1---2name: prompt-engineering3description: Use when designing prompts, evals, or LLM-powered features — prompt architecture, model selection, guardrails, and eval harnesses for prompt-as-product surfaces. Triggers on "prompt engineering", "LLM feature", "eval harness", "prompt design", "提示词工程", "LLM 特性", "prompt 设计".4---56# Prompt Engineering78Design prompts and evals as a first-class engineering deliverable. `context-engineering`9assembles context for a coding agent; this skill designs the prompt-as-product surface — the10prompts, model choices, guardrails, and eval harnesses behind LLM-powered features. A prompt11without an eval is an opinion; an eval without a prompt is a benchmark. Ship neither blind.1213## When to use1415- Designing an LLM-powered feature (chat, summarization, extraction, classification, generation)16- Building or refining a prompt for production use17- Creating an eval harness to measure prompt/model quality18- Selecting a model for a specific task against cost/latency/quality trade-offs19- Triggers on "prompt engineering", "LLM feature", "eval harness", "prompt design", "提示词工程", "LLM 特性"2021**Not for:** assembling context for a coding agent (use `context-engineering`); general research22on a topic (use `research`); API contract design for non-LLM endpoints (use `api-design`).2324## Steps2526### 1. Define the task and success criteria2728State the task in one sentence, then define measurable success criteria — without these, prompt29iteration is vibes-driven. Pull from the product spec:3031- Input space: what inputs will the prompt receive? (vary by length, language, edge case, adversarial)32- Output contract: structured output (JSON schema), free text, or classification?33- Quality bar: accuracy %, format adherence %, hallucination rate, latency target, cost per call34- Failure modes to prevent: what must the model NEVER do? (leak PII, invent facts, refuse valid input)3536_Verify: success criteria are written as measurable thresholds, not "good responses."_3738### 2. Design the prompt architecture3940Structure the prompt as components, not a wall of text — each component has a job:4142- **System / role:** who the model is, what it must and must not do (guardrails live here)43- **Task instruction:** the operation, stated precisely with the output format44- **Context / retrieved data:** only the facts the model needs (not the whole knowledge base —45 context bloat degrades accuracy and raises cost)46- **Few-shot examples:** 2–5 input→output pairs covering the happy path and an edge case; place47 before the actual input, after the instruction48- **Output format:** explicit schema or template; use structured output (JSON mode / function49 calling) when the downstream system parses the result5051Separate stable parts (system, format) from variable parts (user input, retrieved context) so52prompt caching applies to the stable prefix. _Verify: each prompt component is labeled and serves53one purpose; no component is duplicated._5455### 3. Select the model5657Match the model to the task's quality, latency, and cost profile — don't default to the most58capable model for every call:5960- **Complex reasoning / generation:** most capable model, accept higher latency and cost61- **Classification / extraction / routing:** smaller, faster, cheaper model — these tasks are62 over-served by frontier models63- **High-volume, low-stakes:** the cheapest model that meets the quality bar; route edge cases to64 a stronger model (cascaded / routed architecture)65- Evaluate multiple models against the eval harness (step 4) before committing — model choice is66 empirical, not reputational6768_Verify: model choice is documented with the eval comparison and the cost/latency/quality69trade-off that justified it._7071### 4. Build the eval harness7273An eval harness is the test suite for prompts. It runs the prompt against a labeled dataset and74scores the output against the success criteria:7576- **Dataset:** 50–200 examples minimum, covering happy path, edge cases, and known failure modes.77 Use real production inputs where possible; synthesize adversarial cases for gaps.78- **Metrics:** automated where possible (exact match, JSON schema validity, BLEU/ROUGE for79 generation, classifier-based safety); human review for quality dimensions automation can't score.80- **Regression suite:** the eval harness runs on every prompt or model change — a prompt tweak81 that improves one case but regresses three others is a bug, not an improvement.8283_Verify: the eval harness runs from one command, produces a scorecard, and is committed alongside84the prompt._8586### 5. Add guardrails8788Production prompts need defenses the prompt itself cannot provide:8990- **Input validation:** reject malformed, oversized, or disallowed inputs before they reach the model91- **Output validation:** parse and schema-check model output; reject and retry (or fallback) on92 malformed output93- **Content filters:** safety classifiers for harmful content (input and output)94- **PII redaction:** strip sensitive data from prompts before logging; never log raw user input95 that may contain PII to a shared prompt-logging system96- **Rate limits and cost caps:** bound per-user and aggregate spend; a prompt bug that loops can97 burn a budget in minutes9899_Verify: every guardrail has a defined failure behavior (reject, retry, fallback) — silent100pass-through is not a guardrail._101102### 6. Iterate against evals103104Iterate the prompt against the eval harness — change one variable at a time (instruction,105examples, model, temperature), re-run evals, keep the change only if the scorecard improves106without regression. Document prompt versions and their eval scores alongside the prompt, the way107code commits pair with test results.108109**Output:** `docs/design/PROMPT.md` — the prompt design document: task definition, success110criteria, prompt architecture (component breakdown), model selection rationale, eval harness111description and dataset, guardrails, and version history with eval scores.112113## Verify114115- [ ] Task stated in one sentence; success criteria are measurable thresholds116- [ ] Prompt structured into labeled components (system, instruction, context, examples, format)117- [ ] Stable and variable parts separated for prompt caching118- [ ] Model selected via eval comparison, not reputation; trade-off documented119- [ ] Eval harness: 50+ examples, automated metrics, runs from one command, committed120- [ ] Guardrails on input, output, content, PII, and cost — each with a failure behavior121- [ ] Prompt changes paired with eval re-runs; no regression accepted122- [ ] `docs/design/PROMPT.md` produced with architecture + eval + guardrails + version history123124**Red flags:** a single wall-of-text prompt with no structure; choosing the most expensive model125for a classification task; shipping a prompt with no eval; logging raw prompts with user PII; no126output schema validation (trusting the model to always return valid JSON); prompt iteration by127vibes without a scorecard; no cost cap on a production prompt.128129## References130131- [${CLAUDE_PLUGIN_ROOT}/references/engineering-principles.md](${CLAUDE_PLUGIN_ROOT}/references/engineering-principles.md) — shared discipline (surface assumptions, verify don't assume, goal-driven execution)132- [references/prompt-architecture.md](references/prompt-architecture.md) — prompt component breakdown, few-shot patterns, structured-output techniques, model selection matrix, eval-harness setup, guardrail catalog
Run npx skillmds@latest add int2t05/prompt-engineering in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Use when designing prompts, evals, or LLM-powered features — prompt architecture, model selection, guardrails, and eval harnesses for prompt-as-product surfaces. Triggers on "prompt engineering", "LLM feature", "eval harness", "prompt design", "提示词工程", "LLM 特性", "prompt 设计". It is listed under AI & ML on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
int2t05 (@int2t05) published this skill. Their other Agent Skills are listed on their SkillMD profile.