Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Prompt templates, few-shot examples, chain-of-thought, structured output, evals
.claude/skills/prompt-engineering/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-22 | ✗→✓ | ▲ Improved | — | — |
| case-06 | ✗→✓ | ▲ Improved | — | — |
| case-03 | ✗→✓ | ▲ Improved | — | — |
| case-16 | ✗→✓ | ▲ Improved | — | — |
| case-12 | ✗→✗ | = Same ✗ | — | — |
pythonSYSTEM_PROMPT = """You are a {role} specialized in {domain}. ## Task {task_description} ## Rules {numbered_rules} ## Output Format {format_spec} ## Examples {few_shot_examples} """
pythondef build_few_shot_prompt(task: str, examples: list[dict], query: str) -> str: prompt = f"Task: {task}\n\n" for i, ex in enumerate(examples, 1): prompt += f"Example {i}:\nInput: {ex['input']}\nOutput: {ex['output']}\n\n" prompt += f"Now process:\nInput: {query}\nOutput:" return prompt # Usage examples = [ {"input": "The food was great", "output": '{"sentiment": "positive", "confidence": 0.95}'}, {"input": "Terrible service", "output": '{"sentiment": "negative", "confidence": 0.90}'}, {"input": "It was okay", "output": '{"sentiment": "neutral", "confidence": 0.70}'}, ] prompt = build_few_shot_prompt("Classify sentiment as JSON", examples, "Really loved it!")
Analyze this code for security vulnerabilities.
Think step by step:
1. Identify all user inputs
2. Trace each input through the code
3. Check if any input reaches a sensitive operation without sanitization
4. For each vulnerability found, classify severity (critical/high/medium/low)
5. Suggest a fix for each vulnerability
Code:
{code}pythonimport json from collections import Counter async def self_consistent_answer(question: str, n_paths: int = 5) -> str: answers = [] for _ in range(n_paths): response = await llm.generate( f"Think step by step and answer: {question}\n\nFinal answer:", temperature=0.7, # Higher temp for diversity ) final = extract_final_answer(response) answers.append(final) # Majority vote most_common = Counter(answers).most_common(1)[0][0] return most_common
pythonfrom pydantic import BaseModel, Field from openai import OpenAI class CodeReview(BaseModel): issues: list[dict] = Field(description="List of issues found") severity: str = Field(description="Overall severity: low|medium|high|critical") summary: str = Field(description="One-line summary") suggestions: list[str] = Field(description="Improvement suggestions") client = OpenAI() response = client.beta.chat.completions.parse( model="gpt-4o", messages=[ {"role": "system", "content": "Review code and output structured analysis."}, {"role": "user", "content": f"Review this code:\n```\n{code}\n```"}, ], response_format=CodeReview, ) review = response.choices[0].message.parsed
<task>Analyze the following error log and extract structured information.</task>
<rules>
- Extract timestamp, severity, service name, and error message
- Classify root cause category
- Output in the specified XML format
</rules>
<input>
{error_log}
</input>
<output_format>
<analysis>
<timestamp>ISO 8601</timestamp>
<severity>ERROR|WARN|FATAL</severity>
<service>service name</service>
<message>error message</message>
<root_cause>category</root_cause>
<suggested_fix>actionable fix</suggested_fix>
</analysis>
</output_format>pythonclass PromptEvaluator: def __init__(self, test_cases: list[dict]): self.test_cases = test_cases # [{"input": ..., "expected": ..., "criteria": ...}] async def evaluate(self, prompt_template: str) -> dict: results = [] for case in self.test_cases: prompt = prompt_template.format(**case["input"]) output = await llm.generate(prompt) score = self._score(output, case["expected"], case.get("criteria", {})) results.append({"input": case["input"], "output": output, "score": score}) return { "avg_score": sum(r["score"] for r in results) / len(results), "pass_rate": sum(1 for r in results if r["score"] >= 0.8) / len(results), "failures": [r for r in results if r["score"] < 0.8], } def _score(self, output: str, expected: str, criteria: dict) -> float: scores = [] if "contains" in criteria: scores.append(1.0 if criteria["contains"] in output else 0.0) if "format" in criteria: scores.append(1.0 if self._check_format(output, criteria["format"]) else 0.0) if "max_length" in criteria: scores.append(1.0 if len(output) <= criteria["max_length"] else 0.0) return sum(scores) / len(scores) if scores else 0.5
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-12 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +18 percentage points is the difference between those two pass rates over the 22 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.