‹ 首页

prompt-engineering

@giuseppe-trisciuoglio · 收录于 1 周前

Provides workflows to write, debug, and optimize prompts for LLMs, including few-shot example selection, chain-of-thought structuring, system prompt design, and template composition. Use when the user asks to write or improve a prompt, wants help with few-shot examples, chain-of-thought, system prompts, prompt templates, or asks how to get better results from an LLM.

适合你,如果你经常需要与大语言模型交互并希望获得更好结果

/ 下载安装
prompt-engineering.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add giuseppe-trisciuoglio/developer-kit/prompt-engineering
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- giuseppe-trisciuoglio/developer-kit/prompt-engineering
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify giuseppe-trisciuoglio/developer-kit/prompt-engineering
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
303GitHub stars
~1.9K最小装载
~13.5K含声明引用
~13.5K文本包总量
镜像托管

怎么用

技能原文 SKILL.md作者撰写 · MIT · 306f428

Prompt Engineering

Overview

Use this skill to design prompt systems that are clear, testable, and reusable. It covers prompt drafting, optimization, evaluation, and production-oriented patterns for few-shot prompting, reasoning workflows, templates, and system prompts.

Keep the main workflow in this file and load the targeted reference files only for the pattern you are applying.

When to Use

Use this skill when:

  • A user asks to write, rewrite, or improve a prompt
  • A prompt needs better structure, reliability, or output formatting
  • Few-shot examples or reasoning scaffolds are needed
  • A system prompt or reusable prompt template must be created
  • An existing prompt needs measurable optimization and testing

Read the relevant files in references/ when you need deeper guidance on a specific pattern.

Core Patterns
1. Few-Shot Learning
Example Selection Strategy
  • Use references/few-shot-patterns.md for comprehensive selection frameworks
  • Balance example count (3-5 optimal) with context window limitations
  • Include edge cases and boundary conditions in example sets
  • Prioritize diverse examples that cover problem space variations
  • Order examples from simple to complex for progressive learning
Few-Shot Example (Sentiment Classification)
Classify the sentiment as Positive, Negative, or Neutral.

Text: "I love this product! It exceeded my expectations."
Sentiment: Positive
Reasoning: Enthusiastic language, positive adjectives, satisfaction

Text: "The app keeps crashing when I upload large files."
Sentiment: Negative
Reasoning: Complaint about functionality, frustration indicator

Text: "It arrived on time, as described."
Sentiment: Neutral
Reasoning: Factual statement, no strong emotion either way

Text: "{user_input}"
Sentiment:
Reasoning:
2. Chain-of-Thought Reasoning
Implementation Patterns
  • Reference references/cot-patterns.md for detailed reasoning frameworks
  • Use "Let's think step by step" for zero-shot CoT initiation
  • Provide complete reasoning traces for few-shot CoT demonstrations
  • Implement self-consistency by sampling multiple reasoning paths
  • Include verification and validation steps in reasoning chains
CoT Template Structure
Let's approach this step-by-step:

Step 1: {break_down_the_problem}
Analysis: {detailed_reasoning}

Step 2: {identify_key_components}
Analysis: {component_analysis}

Step 3: {synthesize_solution}
Analysis: {solution_justification}

Final Answer: {conclusion_with_confidence}
3. Prompt Optimization
Optimization Process
  • Use references/optimization-frameworks.md for comprehensive optimization strategies
  • Measure baseline performance before optimization attempts
  • Implement single-variable changes for accurate attribution
  • Track metrics: accuracy, consistency, latency, token efficiency
  • Use statistical significance testing for A/B validation
  • Document optimization iterations and their impacts

Track these metrics: accuracy, consistency, token efficiency, robustness, safety. See references/optimization-frameworks.md for measurement utilities.

4. Template Systems
Template Design Principles
  • Reference references/template-systems.md for modular template frameworks
  • Use clear variable naming conventions (e.g., {user_input}, {context})
  • Implement conditional sections for different scenario handling
  • Design role-based templates for specific use cases
  • Create hierarchical template composition patterns
Template Structure Example
# System Context
You are a {role} with {expertise_level} expertise in {domain}.

# Task Context
{if background_information}
Background: {background_information}
{endif}

# Instructions
{task_instructions}

# Examples
{example_count}

# Output Format
{output_specification}

# Input
{user_query}
5. System Prompt Design
System Prompt Components
  • Use references/system-prompt-design.md for detailed design guidelines
  • Define clear role specification and expertise boundaries
  • Establish output format requirements and structural constraints
  • Include safety guidelines and content policy adherence
  • Set context for background information and domain knowledge
System Prompt Framework
You are an expert {role} specializing in {domain} with {experience_level} of experience.

## Core Capabilities
- List specific capabilities and expertise areas
- Define scope of knowledge and limitations

## Behavioral Guidelines
- Specify interaction style and communication approach
- Define error handling and uncertainty protocols
- Establish quality standards and verification requirements

## Output Requirements
- Specify format expectations and structural requirements
- Define content inclusion and exclusion criteria
- Establish consistency and validation requirements

## Safety and Ethics
- Include content policy adherence
- Specify bias mitigation requirements
- Define harm prevention protocols
Implementation Workflows
Workflow 1: Create New Prompt from Requirements
  1. Analyze Requirements
  2. Identify task complexity and reasoning requirements
  3. Determine target model capabilities and limitations
  4. Define success criteria and evaluation metrics
  5. Assess need for few-shot learning or CoT reasoning
  1. Select Pattern Strategy
  2. Use few-shot learning for classification or transformation tasks
  3. Apply CoT for complex reasoning or multi-step problems
  4. Implement template systems for reusable prompt architecture
  5. Design system prompts for consistent behavior requirements
  1. Draft Initial Prompt
  2. Structure prompt with clear sections and logical flow
  3. Include relevant examples or reasoning demonstrations
  4. Specify output format and quality requirements
  5. Incorporate safety guidelines and constraints
  1. Validate and Test
  2. Test with at least 3 inputs: one happy path, one edge case, one adversarial
  3. Measure accuracy and token usage against defined success criteria
  4. Change one variable at a time, re-test, keep only what improves metrics
  5. Document optimization decisions and their rationale
Workflow 2: Optimize Existing Prompt
  1. Performance Analysis
  2. Measure current prompt performance metrics
  3. Identify failure modes and error patterns
  4. Analyze token efficiency and response latency
  5. Assess consistency across multiple runs
  1. Optimization Strategy
  2. Apply systematic A/B testing with single-variable changes
  3. Use few-shot learning to improve task adherence
  4. Implement CoT reasoning for complex task components
  5. Refine template structure for better clarity
  1. Implementation and Testing
  2. Re-run the same test cases from step 1 against the optimized prompt
  3. If accuracy < baseline, revert the change and try a different hypothesis
  4. If accuracy >= baseline but < 90%, return to step 2 with a new strategy
  5. Document the winning change and its measured impact
Workflow 3: Scale Prompt Systems
  1. Modular Architecture Design
  2. Decompose complex prompts into reusable components
  3. Create template inheritance hierarchies
  4. Implement dynamic example selection systems
  5. Build automated quality assurance frameworks
  1. Production Integration
  2. Implement prompt versioning and rollback capabilities
  3. Create performance monitoring and alerting systems
  4. Build automated testing frameworks for prompt validation
  5. Establish update and deployment workflows
Quality Gates
  • Accuracy >90% on 10+ diverse test cases before shipping
  • <5% variance across 3+ repeated runs
  • All edge cases and adversarial inputs handled gracefully
  • Output format matches spec on every test case
Best Practices
  • Optimize one variable at a time so results stay attributable
  • Keep prompts explicit about task, context, constraints, and output format
  • Prefer a small number of strong examples over many repetitive ones
  • Test prompts against happy-path, edge-case, and adversarial inputs
  • Move long pattern details to references/ instead of bloating SKILL.md
Constraints and Warnings
  • Do not assume longer prompts are better; extra detail often adds ambiguity
  • Avoid exposing hidden reasoning requirements when a concise rationale is enough
  • Validate prompts on representative inputs before claiming improvement
  • Keep model-specific assumptions explicit because behavior varies across models
Integration with Other Skills

This skill integrates seamlessly with:

  • langchain4j-ai-services-patterns: Interface-based prompt design
  • langchain4j-rag-implementation-patterns: Context-enhanced prompting
  • langchain4j-testing-strategies: Prompt validation frameworks
  • unit-test-parameterized: Systematic prompt testing approaches
Resources and References
  • references/few-shot-patterns.md: Comprehensive few-shot learning frameworks
  • references/cot-patterns.md: Chain-of-thought reasoning patterns and examples
  • references/optimization-frameworks.md: Systematic prompt optimization methodologies
  • references/template-systems.md: Modular template design and implementation
  • references/system-prompt-design.md: System prompt architecture and best practices
Common Pitfalls and Solutions

| Pitfall | Fix | |---|---| | Wrong output format | Add a concrete output example at the end of the prompt | | Inconsistent answers | Add 2-3 few-shot examples showing expected reasoning | | Hallucination | Add "If unsure, say 'I don't know'" + constrain the answer domain | | Too verbose | Add explicit word/sentence limit + "Be concise" instruction | | Missed edge cases | Add an edge-case few-shot example |

Constraints
  • Test across target models — capabilities and token limits vary
  • Keep few-shot examples to 3-5 to manage context usage
  • Validate with domain-specific test cases before production
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。