Use when the user asks to optimize prompts, design prompt templates, evaluate LLM outputs with an eval set, measure RAG retrieval quality, validate agent/tool configurations, analyze token usage, or design structured-output contracts. Covers eval-driven prompt iteration, RAG
Installs just this skill. Get the whole plugin for auto-invocation.
โก How it fires
How this skill gets triggered: by you, by Claude, or both.
Fires itselfClaude auto-loads it when your prompt matches the work.
You can call itInvoke it directly when you want it.
Slash command/senior-prompt-engineer
๐๏ธ Context preview
The summary Claude sees to decide when to auto-load this skill.
Use when the user asks to optimize prompts, design prompt templates, evaluate LLM outputs with an eval set, measure RAG retrieval quality, validate agent/tool configurations, analyze token usage, or design structured-output contracts. Covers eval-driven prompt iteration, RAG
๐ Stats
Stars23,062
Forks3,139
LanguagePython
LicenseMIT
๐ฆ Ships with claude-skills
</> SKILL.md
senior-prompt-engineer.SKILL.md
---name: "senior-prompt-engineer"
description: Use when the user asks to optimize prompts, design prompt templates, evaluate LLM outputs with an eval set, measure RAG retrieval quality, validate agent/tool configurations, analyze token usage, or design structured-output contracts. Covers eval-driven prompt iteration, RAG metrics (relevance, faithfulness, coverage), agent workflow validation, and token/cost budgeting โ all model-agnostic, with three stdlib Python tools.
---# Senior Prompt Engineer
Eval-driven prompt engineering, RAG quality measurement, and agent workflow validation. Everything here is **model-agnostic by design**: techniques are framed by what they do, not by which model generation they were observed on, and the tools never hardcode model IDs or pricing โ you supply your provider's current rates when you want dollar figures.
## Operating Rules
1. **Never change a prompt without a baseline.** Capture metrics first (`--analyze --output baseline.json`), then compare every iteration against it.
2. **Eval set before optimization.** 10โ20 representative cases with expected outputs minimum. If the user has no eval set, build one with them before touching the prompt โ optimizing against vibes is the #1 failure mode.
3. **Prefer platform features over prompt hacks.** If the provider offers native structured outputs / JSON schema enforcement, tool-use APIs, or prompt caching, use those instead of "respond ONLY with JSON" incantations. Prompt-level format enforcement is the fallback, not the default.
4. **Current-generation models need less scaffolding.** Don't add chain-of-thought boilerplate, role framing, or few-shot examples reflexively โ frontier models often do worse with redundant scaffolding. Add each element only when the eval set shows it helps.
5. **Cost numbers are always user-supplied.** Look up the provider's current per-Mtok pricing and pass it via `--price-per-mtok` (never trust a cached price table โ including any you remember).
`--model` accepts any string; only the tokenizer family is inferred (names containing "claude" โ 3.5 chars/token, otherwise 4.0). Exit 0 on success, 1 on missing file.
Reports context relevance, precision@k, coverage, answer faithfulness, groundedness. Treat relevance < 0.80 as a retrieval problem (chunking/embedding/filtering), not a prompt problem โ fix retrieval before rewriting the generation prompt.
Without the two price flags, `--estimate-cost` reports token estimates only. The `model:` field in the config is informational โ any model name is accepted.
Pair this structural gate with your task-level eval: the revision must not lose any previously-passing eval case (no-regression rule).
### Few-Shot Example Design
1. Define the task contract first (input shape, output shape, edge-case policy).
2. Start with **zero examples** and measure โ current models often need none. Add examples only for failure clusters the eval reveals.
3. When adding: 3โ5 max, ordered simple โ edge โ negative (what NOT to extract), formatted identically to the real output contract.
4. Validate consistency: `python3 scripts/prompt_optimizer.py prompt_with_examples.txt --extract-examples --output examples.json` and inspect that every extracted pair parses against your schema.
5. Re-run the eval set; if a case passes only because it resembles an example, add a held-out variant to the eval set.
### Structured Output Design
1. Write the JSON Schema first (types, enums, required, maxLength).
3. Fallback (API without schema support): include the schema rendered as field-by-field rules + one valid example, and instruct "output only the JSON object".
4. Gate: pipe 10 eval outputs through a schema validator (`python3 -c "import json,sys; [json.loads(l) for l in sys.stdin]"` at minimum); 10/10 must parse, else return to step 2.
### RAG Tuning Loop
1. Build `questions.json` (id, question, reference answer) and capture current retrievals to `contexts.json`.
3. Fix the **lowest metric first**: relevance โ chunking/embeddings/metadata filters; faithfulness โ grounding instructions + "answer only from context" + citation requirement; coverage โ retrieval k / query expansion.
4. Gate: `python3 scripts/rag_evaluator.py --contexts new_contexts.json --questions questions.json --compare rag_baseline.json` โ every metric must be โฅ baseline; any regression blocks the change.
### Agent Config Review
1. `python3 scripts/agent_orchestrator.py agent.yaml --validate` โ must exit with VALIDATION PASSED; fix every error and warning (missing tool config, unbounded iterations, loop risk).
2. Check context discipline: each tool description โค 1โ2 sentences, tool count minimal for the job, stable system prompt placed first (cache-friendly), iteration cap + early-exit condition present.
3. Budget: `--estimate-cost --runs N` with your current prices; if cost/run exceeds budget, cut tools or context before downgrading the model.