agentleFS
pyramidheadsharkpyramidheadshark/claude-scaffold/.claude/skills/prompt-engineering/SKILL.md

prompt-engineering

Skill4 starsChanged 8 months agoMITArchived repositoryView on GitHub

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: 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. Use explicit CoT for reasoning tasks. Add "Think step by step" or "First reason through the problem, then…

99 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use security-checklist, multi-agent-orchestration and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • atuljha23Skill

    security-checklist

    OWASP-style quick reference — authn/authz, injection, secrets, sessions, crypto, dependencies. Use during code review and before committing security-sensitive changes.

    Also in 3 projects that use this

  • javalenciacaiSkill

    multi-agent-orchestration

    Design and coordinate multi-agent systems where specialized agents work together to solve complex problems. Covers agent communication, task delegation, workflow orchestration, and result aggregation. Use when building coordinated agent teams, complex workflows, or systems requiring specialized expertise across domains.

    Also in 4 projects that use this

  • xfstudioSkill

    llm-evaluation

    Implement comprehensive evaluation strategies for LLM applications using automated metrics, human feedback, and benchmarking. Use when testing LLM performance, measuring AI application quality, or establishing evaluation frameworks.

    Also in 3 projects that use this

  • MicrosoftSkill

    cost-optimization

    Optimize existing Azure resources and analyze Reservations or Savings Plans. WHEN: \"optimize Azure costs\", \"reduce cloud spending\", \"rightsize resources\", \"find idle resources\", \"orphaned disk\", \"deleted VM still charged\", \"public IP still charging\", \"reservation utilization\", \"Savings Plan coverage\", \"commitment recommendation\", \"why is pay-as-you-go still charged\". DO NOT USE FOR: cost spikes, forecasts, pricing estimates, budgets, or governance.

    Also in 3 projects that use this

  • GoogleSkill

    coding-principles

    Enforces engineering, architecture, public API, and code quality standards distilled from human reviewer feedback across A2UI pull requests. Use when authoring new code, refactoring, addressing review feedback, or reviewing PR diffs. Don't use for release publishing or spec blueprint generation without code or PR changes.

    Also in 3 projects that use this

  • mrgoonieSkill

    problem-solving

    Creative problem-solving techniques for breaking through stuck points - includes collision-zone thinking, inversion, pattern recognition, and simplification

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 87 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep system prompts under 2000 tokens.

    line 25
  2. Distinctive:

    Place examples AFTER the main instruction, not before.

    line 29
  3. Distinctive:

    Use explicit CoT for reasoning tasks.

    line 49
  4. Distinctive:

    Do NOT use CoT for classification or extraction tasks — it wastes tokens without improving accuracy.

    line 63

“Common” is measured: kept by at least 6 in 10 of the 87 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
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 "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.

Few-Shot Examples

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
"""

Chain-of-Thought

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.

Structured Output

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)

Prompt Versioning

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")

Common Failure Modes

  • Instruction following failure: too many rules in one prompt → split into sub-tasks
  • Format drift: Claude adds explanation around JSON → add "Return ONLY..." + validate
  • Role confusion: Claude breaks character → strengthen the Role section
  • Reasoning shortcut: Claude skips steps → explicitly require intermediate steps

See Also

  • resources/structured-output.md — advanced output validation patterns
  • resources/evals-framework.md — eval framework for prompt regression testing

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.