agentleFS
nisarthnisarth/claude-skills-store/skills/devtools/prompt-engineering/SKILL.md

Prompt Engineering

Skill1 starsChanged 7 months agoMITView on GitHub

Design, optimize, and evaluate prompts for Claude. Covers system prompts, few-shot examples, chain-of-thought reasoning, structured output, and systematic evaluation of prompt quality. Trigger phrases: "design a prompt", "optimize prompt", "prompt engineering", "write a system prompt", "improve my prompt", "prompt template", "few-shot examples"

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈12

    Distinctive · estimate

    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:

    Write the initial prompt following these structural principles:

    line 56
  2. Distinctive:

    Examples: - if using few-shot, place here

    line 62
  3. Distinctive:

    Use XML tags to separate sections:

    line 65
  4. Distinctive:

    When using few-shot prompting:

    line 92
  5. Distinctive:

    Keep examples representative of real inputs

    line 98
  6. Distinctive:

    Test edge cases: - run unusual inputs and fix failures

    line 107
  7. Distinctive:

    Check consistency: - verify output format matches across runs

    line 108
  8. Distinctive:

    Create an evaluation framework:

    line 113
  9. Distinctive:

    Run each input through the prompt

    line 116
  10. Distinctive:

    Test cases for ongoing quality monitoring

    line 129
  11. Distinctive:

    Action: Create a role-based system prompt with specific review criteria (security, performance, readability), severity levels, and …

    line 143
  12. Distinctive:

    Front-load critical instructions: - put the most important rules first

    line 155

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Design high-quality prompts for Claude that produce reliable, accurate, and well-structured outputs across diverse use cases.

Prerequisites

  • Clear understanding of the task the prompt should accomplish
  • Example inputs and desired outputs
  • Knowledge of the target audience and context
  • Access to Claude API or Claude Code for testing

Workflow

Step 1: Define the Task

Establish clear requirements:

  1. Objective - what should the prompt accomplish in one sentence
  2. Input format - what data will the prompt receive
  3. Output format - exact structure of the desired response
  4. Constraints - length limits, tone, forbidden content, required elements
  5. Edge cases - unusual inputs the prompt must handle
  6. Evaluation criteria - how to measure prompt quality

Step 2: Choose the Prompt Pattern

Select the appropriate technique based on the task:

Direct instruction: Simple tasks with clear requirements. State what to do plainly.

System prompt + user prompt: Tasks requiring persistent persona or rules. System prompt sets behavior; user prompt provides the specific request.

Few-shot examples: Tasks where showing is easier than telling. Provide 2-5 input/output pairs before the actual input.

Chain-of-thought: Complex reasoning tasks. Instruct the model to think step-by-step before answering.

Structured output: Tasks requiring specific formats. Define the output schema explicitly using XML tags, JSON, or Markdown.

Role-based: Tasks benefiting from domain expertise. Assign a specific expert role with relevant knowledge.

Step 3: Draft the Prompt

Write the initial prompt following these structural principles:

  1. Context first - provide background before the task
  2. Task statement - clear, unambiguous instruction
  3. Constraints - rules and boundaries
  4. Output format - explicit format specification
  5. Examples - if using few-shot, place here
  6. Input data - the actual content to process

Use XML tags to separate sections:

<context>
Background information about the task domain.
</context>

<task>
What Claude should do with the input.
</task>

<constraints>
- Rule 1
- Rule 2
</constraints>

<output_format>
Description of the expected output structure.
</output_format>

<input>
{{user_input}}
</input>

Step 4: Add Few-Shot Examples

When using few-shot prompting:

  1. Include 2-5 diverse examples covering different scenarios
  2. Order examples from simple to complex
  3. Show the exact output format you expect
  4. Include at least one edge case example
  5. Keep examples representative of real inputs

Step 5: Optimize the Prompt

Iterate on the draft:

  1. Remove ambiguity - eliminate words with multiple interpretations
  2. Reduce length - cut redundant instructions without losing clarity
  3. Strengthen constraints - make rules more specific and enforceable
  4. Test edge cases - run unusual inputs and fix failures
  5. Check consistency - verify output format matches across runs
  6. Measure quality - score outputs against evaluation criteria

Step 6: Evaluate Systematically

Create an evaluation framework:

  1. Build a test set of 10-20 diverse inputs with expected outputs
  2. Run each input through the prompt
  3. Score each output on your evaluation criteria (accuracy, format, completeness)
  4. Calculate aggregate metrics
  5. Identify failure patterns and iterate

Output Format

The skill produces:

  • Complete prompt text ready for use
  • System prompt (if applicable) separated from user prompt
  • Few-shot examples (if applicable)
  • Evaluation criteria checklist
  • Test cases for ongoing quality monitoring

Examples

Example 1: Data Extraction Prompt

User: "Create a prompt that extracts contact info from emails"

Action: Design a structured extraction prompt with XML output tags, few-shot examples of various email formats, and handling for missing fields.

Example 2: Code Review Prompt

User: "Design a system prompt for automated code review"

Action: Create a role-based system prompt with specific review criteria (security, performance, readability), severity levels, and structured feedback format.

Example 3: Classification Prompt

User: "Build a prompt for categorizing support tickets"

Action: Design a chain-of-thought classification prompt with category definitions, few-shot examples per category, confidence scoring, and multi-label support.

Best Practices

  1. Be explicit about format - show the exact output structure, do not assume
  2. Use XML tags for structure - they improve parsing and reduce format drift
  3. Front-load critical instructions - put the most important rules first
  4. Avoid negations when possible - "use formal tone" over "don't be informal"
  5. Test with adversarial inputs - try inputs designed to break the prompt
  6. Keep system prompts stable - change user prompts for per-request variation
  7. Document prompt versions - track what changed and why
  8. Measure before optimizing - establish a baseline before making changes
  9. Use temperature thoughtfully - lower for consistency, higher for creativity
  10. Iterate in small steps - change one thing at a time to isolate improvements

Error Handling

ErrorCauseRecovery
Format driftOutput structure varies across runsAdd stricter format instructions and examples
HallucinationModel generates unsupported claimsAdd grounding constraints, require citations
Instruction skippingModel ignores some rulesMove ignored rules to more prominent position
Over-verbosityOutput far exceeds desired lengthAdd explicit length constraints with word counts
Edge case failureUnusual inputs produce bad outputAdd few-shot examples for edge cases
Inconsistent qualityQuality varies across inputsAdd chain-of-thought reasoning step

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.