[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-55a15eb1-ffa6-41db-b6f4-083e6de5ce2d":3,"$f-b-oQZjiQPbNTAQL4iqUp_0L_FC3tFeD6LVgqcXERaE":42},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":33},"55a15eb1-ffa6-41db-b6f4-083e6de5ce2d","prompt-engineering-patterns","掌握高级提示工程技巧，以最大化LLM的性能、可靠性和可控性。","cat_coding_backend","mod_coding","sickn33,coding","---\nname: prompt-engineering-patterns\ndescription: \"Master advanced prompt engineering techniques to maximize LLM performance, reliability, and controllability.\"\nrisk: unknown\nsource: community\ndate_added: \"2026-02-27\"\n---\n\n# Prompt Engineering Patterns\n\nMaster advanced prompt engineering techniques to maximize LLM performance, reliability, and controllability.\n\n## Do not use this skill when\n\n- The task is unrelated to prompt engineering patterns\n- You need a different domain or tool outside this scope\n\n## Instructions\n\n- Clarify goals, constraints, and required inputs.\n- Apply relevant best practices and validate outcomes.\n- Provide actionable steps and verification.\n- If detailed examples are required, open `resources\u002Fimplementation-playbook.md`.\n\n## Use this skill when\n\n- Designing complex prompts for production LLM applications\n- Optimizing prompt performance and consistency\n- Implementing structured reasoning patterns (chain-of-thought, tree-of-thought)\n- Building few-shot learning systems with dynamic example selection\n- Creating reusable prompt templates with variable interpolation\n- Debugging and refining prompts that produce inconsistent outputs\n- Implementing system prompts for specialized AI assistants\n\n## Core Capabilities\n\n### 1. Few-Shot Learning\n- Example selection strategies (semantic similarity, diversity sampling)\n- Balancing example count with context window constraints\n- Constructing effective demonstrations with input-output pairs\n- Dynamic example retrieval from knowledge bases\n- Handling edge cases through strategic example selection\n\n### 2. Chain-of-Thought Prompting\n- Step-by-step reasoning elicitation\n- Zero-shot CoT with \"Let's think step by step\"\n- Few-shot CoT with reasoning traces\n- Self-consistency techniques (sampling multiple reasoning paths)\n- Verification and validation steps\n\n### 3. Prompt Optimization\n- Iterative refinement workflows\n- A\u002FB testing prompt variations\n- Measuring prompt performance metrics (accuracy, consistency, latency)\n- Reducing token usage while maintaining quality\n- Handling edge cases and failure modes\n\n### 4. Template Systems\n- Variable interpolation and formatting\n- Conditional prompt sections\n- Multi-turn conversation templates\n- Role-based prompt composition\n- Modular prompt components\n\n### 5. System Prompt Design\n- Setting model behavior and constraints\n- Defining output formats and structure\n- Establishing role and expertise\n- Safety guidelines and content policies\n- Context setting and background information\n\n## Quick Start\n\n```python\nfrom prompt_optimizer import PromptTemplate, FewShotSelector\n\n# Define a structured prompt template\ntemplate = PromptTemplate(\n    system=\"You are an expert SQL developer. Generate efficient, secure SQL queries.\",\n    instruction=\"Convert the following natural language query to SQL:\\n{query}\",\n    few_shot_examples=True,\n    output_format=\"SQL code block with explanatory comments\"\n)\n\n# Configure few-shot learning\nselector = FewShotSelector(\n    examples_db=\"sql_examples.jsonl\",\n    selection_strategy=\"semantic_similarity\",\n    max_examples=3\n)\n\n# Generate optimized prompt\nprompt = template.render(\n    query=\"Find all users who registered in the last 30 days\",\n    examples=selector.select(query=\"user registration date filter\")\n)\n```\n\n## Key Patterns\n\n### Progressive Disclosure\nStart with simple prompts, add complexity only when needed:\n\n1. **Level 1**: Direct instruction\n   - \"Summarize this article\"\n\n2. **Level 2**: Add constraints\n   - \"Summarize this article in 3 bullet points, focusing on key findings\"\n\n3. **Level 3**: Add reasoning\n   - \"Read this article, identify the main findings, then summarize in 3 bullet points\"\n\n4. **Level 4**: Add examples\n   - Include 2-3 example summaries with input-output pairs\n\n### Instruction Hierarchy\n```\n[System Context] → [Task Instruction] → [Examples] → [Input Data] → [Output Format]\n```\n\n### Error Recovery\nBuild prompts that gracefully handle failures:\n- Include fallback instructions\n- Request confidence scores\n- Ask for alternative interpretations when uncertain\n- Specify how to indicate missing information\n\n## Best Practices\n\n1. **Be Specific**: Vague prompts produce inconsistent results\n2. **Show, Don't Tell**: Examples are more effective than descriptions\n3. **Test Extensively**: Evaluate on diverse, representative inputs\n4. **Iterate Rapidly**: Small changes can have large impacts\n5. **Monitor Performance**: Track metrics in production\n6. **Version Control**: Treat prompts as code with proper versioning\n7. **Document Intent**: Explain why prompts are structured as they are\n\n## Common Pitfalls\n\n- **Over-engineering**: Starting with complex prompts before trying simple ones\n- **Example pollution**: Using examples that don't match the target task\n- **Context overflow**: Exceeding token limits with excessive examples\n- **Ambiguous instructions**: Leaving room for multiple interpretations\n- **Ignoring edge cases**: Not testing on unusual or boundary inputs\n\n## Integration Patterns\n\n### With RAG Systems\n```python\n# Combine retrieved context with prompt engineering\nprompt = f\"\"\"Given the following context:\n{retrieved_context}\n\n{few_shot_examples}\n\nQuestion: {user_question}\n\nProvide a detailed answer based solely on the context above. If the context doesn't contain enough information, explicitly state what's missing.\"\"\"\n```\n\n### With Validation\n```python\n# Add self-verification step\nprompt = f\"\"\"{main_task_prompt}\n\nAfter generating your response, verify it meets these criteria:\n1. Answers the question directly\n2. Uses only information from provided context\n3. Cites specific sources\n4. Acknowledges any uncertainty\n\nIf verification fails, revise your response.\"\"\"\n```\n\n## Performance Optimization\n\n### Token Efficiency\n- Remove redundant words and phrases\n- Use abbreviations consistently after first definition\n- Consolidate similar instructions\n- Move stable content to system prompts\n\n### Latency Reduction\n- Minimize prompt length without sacrificing quality\n- Use streaming for long-form outputs\n- Cache common prompt prefixes\n- Batch similar requests when possible\n\n## Resources\n\n- **references\u002Ffew-shot-learning.md**: Deep dive on example selection and construction\n- **references\u002Fchain-of-thought.md**: Advanced reasoning elicitation techniques\n- **references\u002Fprompt-optimization.md**: Systematic refinement workflows\n- **references\u002Fprompt-templates.md**: Reusable template patterns\n- **references\u002Fsystem-prompts.md**: System-level prompt design\n- **assets\u002Fprompt-template-library.md**: Battle-tested prompt templates\n- **assets\u002Ffew-shot-examples.json**: Curated example datasets\n- **scripts\u002Foptimize-prompt.py**: Automated prompt optimization tool\n\n## Success Metrics\n\nTrack these KPIs for your prompts:\n- **Accuracy**: Correctness of outputs\n- **Consistency**: Reproducibility across similar inputs\n- **Latency**: Response time (P50, P95, P99)\n- **Token Usage**: Average tokens per request\n- **Success Rate**: Percentage of valid outputs\n- **User Satisfaction**: Ratings and feedback\n\n## Next Steps\n\n1. Review the prompt template library for common patterns\n2. Experiment with few-shot learning for your specific use case\n3. Implement prompt versioning and A\u002FB testing\n4. Set up automated evaluation pipelines\n5. Document your prompt engineering decisions and learnings\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,141,440,"2026-05-16 13:35:34",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":25,"skillCount":32,"createdAt":26},"后端开发","backend","mdi-server","API、数据库、服务端架构",296,[34],{"id":35,"skillId":4,"version":36,"fileName":37,"fileSize":38,"filePath":39,"fileHash":40,"manifest":41,"createdAt":19},"86939a22-b9fb-4511-8a77-8ff0f563e38f","1.0.0","prompt-engineering-patterns.zip",27437,"uploads\u002Fskills\u002F55a15eb1-ffa6-41db-b6f4-083e6de5ce2d\u002Fprompt-engineering-patterns.zip","a34380ba39164a701e4ab4ea23c9f46a455ec76cbd9c64c0d7066d8076622dc8","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":7642},{\"path\":\"assets\u002Ffew-shot-examples.json\",\"isDirectory\":false,\"size\":4174},{\"path\":\"assets\u002Fprompt-template-library.md\",\"isDirectory\":false,\"size\":3273},{\"path\":\"references\u002Fchain-of-thought.md\",\"isDirectory\":false,\"size\":9386},{\"path\":\"references\u002Ffew-shot-learning.md\",\"isDirectory\":false,\"size\":11171},{\"path\":\"references\u002Fprompt-optimization.md\",\"isDirectory\":false,\"size\":12778},{\"path\":\"references\u002Fprompt-templates.md\",\"isDirectory\":false,\"size\":11395},{\"path\":\"references\u002Fsystem-prompts.md\",\"isDirectory\":false,\"size\":5438},{\"path\":\"scripts\u002Foptimize-prompt.py\",\"isDirectory\":false,\"size\":9159}]",{"code":43,"message":44,"data":45},200,"success",{"items":46,"stats":47,"page":50},[],{"averageRating":48,"totalRatings":48,"ratingCounts":49},0,[48,48,48,48,48],{"limit":51,"offset":48,"hasMore":52,"nextOffset":51,"ratedOnly":16},15,false]