.claude/skills/prompt-engineering/SKILL.md
# Prompt Engineering ## When to Load This Skill Load when working with: system prompts, few-shot examples, chain-of-thought, prompt templates, `system_prompt`, `few_shot`, prompt evaluation, "промпт", CoT, output formatting, structured output. ## System Prompt Structure A production system prompt has four sections: ``` ## Role Who Claude is in this context. ## Context What the system is, what data Claude has access to, key constraints. ## Task What Claude must do. Be specific — avoid "hel
npx skillsauth add pyramidheadshark/ml-claude-infra .claude/skills/prompt-engineeringInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Load when working with: system prompts, few-shot examples, chain-of-thought, prompt templates, system_prompt, few_shot, prompt evaluation, "промпт", CoT, output formatting, structured output.
A production system prompt has four sections:
## Role
Who Claude is in this context.
## Context
What the system is, what data Claude has access to, key constraints.
## Task
What Claude must do. Be specific — avoid "help the user".
## Output Format
Exact format of the response. Include examples.
Keep system prompts under 2000 tokens. Longer prompts reduce Claude's effective context for user content.
Place examples AFTER the main instruction, not before. Three examples outperform one. Use diverse examples that cover edge cases.
SYSTEM_PROMPT = """
You are a document classifier. Classify the document into one of: invoice, contract, receipt, other.
Examples:
Document: "Payment due by 30 days for services rendered..."
Label: invoice
Document: "This agreement is made between Party A and Party B..."
Label: contract
Document: "Thank you for your purchase. Total: $42.00"
Label: receipt
"""
Use explicit CoT for reasoning tasks. Add "Think step by step" or "First reason through the problem, then give your answer."
SYSTEM_PROMPT = """
You are a data analyst. When answering questions about data:
1. First, identify what the question is asking
2. List the relevant data points
3. Reason through the calculation
4. State your final answer
Do not skip directly to the answer.
"""
Do NOT use CoT for classification or extraction tasks — it wastes tokens without improving accuracy.
For JSON output, provide the exact schema in the system prompt:
SYSTEM_PROMPT = """
Extract the following fields from the document. Return ONLY valid JSON, no other text:
{
"date": "YYYY-MM-DD or null",
"amount": float or null,
"vendor": "string or null",
"category": "invoice|receipt|contract|other"
}
"""
Validate the output with Pydantic:
from pydantic import BaseModel
class DocumentExtraction(BaseModel):
date: str | None
amount: float | None
vendor: str | None
category: str
def extract(text: str) -> DocumentExtraction:
response = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=256,
system=EXTRACTION_PROMPT,
messages=[{"role": "user", "content": text}],
)
return DocumentExtraction.model_validate_json(response.content[0].text)
Store prompts in files, not inline strings:
prompts/
├── v1/
│ ├── system.md
│ └── examples.md
└── v2/
├── system.md
└── examples.md
Load at startup, cache in memory:
from pathlib import Path
from functools import lru_cache
@lru_cache(maxsize=None)
def load_prompt(name: str, version: str = "v1") -> str:
path = Path("prompts") / version / f"{name}.md"
return path.read_text(encoding="utf-8")
resources/structured-output.md — advanced output validation patternsresources/evals-framework.md — eval framework for prompt regression testingtesting
# Design Doc Creator ## When to Load This Skill Load when: design documents, requirements, new project start. Short fixture skill for testing (optional/meta skill).
development
# Windows Developer Guide ## When to Load Automatically loaded on Windows (`platform_trigger: "win32"`). Applies to: `.py`, `.ps1`, `.bat`, `.cmd` files and any Windows-specific workflow. ## Python on Windows ### Encoding (CRITICAL) Windows defaults to `cp1251` / `cp1252` for file I/O. Always specify UTF-8 explicitly: ```python with open("file.txt", "r", encoding="utf-8") as f: content = f.read() Path("file.txt").read_text(encoding="utf-8") Path("file.txt").write_text(content, encodin
development
# Test-First Patterns ## When to Load This Skill Load when writing tests, creating `.feature` files, setting up conftest, discussing test strategy, or reviewing coverage. ## Philosophy Tests are written BEFORE code. Always. No exceptions. The order is: Design Doc → BDD Scenarios → Unit Tests → Implementation. BDD scenarios come from the design document's use cases section — they are a direct translation of business requirements into executable specifications. This makes tests the living do
testing
# Skill: Supply Chain Auditor ## When to Load Auto-load when: adding dependencies, reviewing packages, updating versions, or discussing `requirements.txt`, `pyproject.toml`, `package.json`. Triggers on `dependency`, `install`, `package`, `CVE`, `audit`, `vulnerable` (≥2 keywords). ## Core Rules Every new dependency addition must pass this checklist before merging: 1. **Pinned** — exact version in production (`==1.2.3` for pip, `"1.2.3"` for npm, not `^` or `~`). 2. **Maintained** — last com