Agent Skillsrmyndharis/antigravity-skills › prompt-engineering-patterns

prompt-engineering-patterns

GitHub

掌握高级提示词工程技巧,提升LLM性能、可靠性与可控性。适用于生产环境提示词设计、优化、结构化推理实现及模板构建。

skills/prompt-engineering-patterns/SKILL.md rmyndharis/antigravity-skills

Trigger Scenarios

为生产级LLM应用设计复杂提示词 优化提示词以改善一致性与性能 实现思维链或树状思考等推理模式 构建带动态示例选择的学习系统 创建可复用的变量插值模板 调试输出不一致的提示词 设计专用AI助手的系统提示

Install

npx skills add rmyndharis/antigravity-skills --skill prompt-engineering-patterns -g -y
More Options

Use without installing

npx skills use rmyndharis/antigravity-skills@prompt-engineering-patterns

指定 Agent (Claude Code)

npx skills add rmyndharis/antigravity-skills --skill prompt-engineering-patterns -a claude-code -g -y

安装 repo 全部 skill

npx skills add rmyndharis/antigravity-skills --all -g -y

预览 repo 内 skill

npx skills add rmyndharis/antigravity-skills --list

SKILL.md

Frontmatter
{
    "name": "prompt-engineering-patterns",
    "description": "Master advanced prompt engineering techniques to maximize LLM performance, reliability, and controllability in production. Use when optimizing prompts, improving LLM outputs, or designing production prompt templates."
}

Prompt Engineering Patterns

Master advanced prompt engineering techniques to maximize LLM performance, reliability, and controllability.

Do not use this skill when

  • The task is unrelated to prompt engineering patterns
  • You need a different domain or tool outside this scope

Instructions

  • Clarify goals, constraints, and required inputs.
  • Apply relevant best practices and validate outcomes.
  • Provide actionable steps and verification.

Use this skill when

  • Designing complex prompts for production LLM applications
  • Optimizing prompt performance and consistency
  • Implementing structured reasoning patterns (chain-of-thought, tree-of-thought)
  • Building few-shot learning systems with dynamic example selection
  • Creating reusable prompt templates with variable interpolation
  • Debugging and refining prompts that produce inconsistent outputs
  • Implementing system prompts for specialized AI assistants

Core Capabilities

1. Few-Shot Learning

  • Example selection strategies (semantic similarity, diversity sampling)
  • Balancing example count with context window constraints
  • Constructing effective demonstrations with input-output pairs
  • Dynamic example retrieval from knowledge bases
  • Handling edge cases through strategic example selection

2. Chain-of-Thought Prompting

  • Step-by-step reasoning elicitation
  • Zero-shot CoT with "Let's think step by step"
  • Few-shot CoT with reasoning traces
  • Self-consistency techniques (sampling multiple reasoning paths)
  • Verification and validation steps

3. Prompt Optimization

  • Iterative refinement workflows
  • A/B testing prompt variations
  • Measuring prompt performance metrics (accuracy, consistency, latency)
  • Reducing token usage while maintaining quality
  • Handling edge cases and failure modes

4. Template Systems

  • Variable interpolation and formatting
  • Conditional prompt sections
  • Multi-turn conversation templates
  • Role-based prompt composition
  • Modular prompt components

5. System Prompt Design

  • Setting model behavior and constraints
  • Defining output formats and structure
  • Establishing role and expertise
  • Safety guidelines and content policies
  • Context setting and background information

Quick Start

from prompt_optimizer import PromptTemplate, FewShotSelector

# Define a structured prompt template
template = PromptTemplate(
    system="You are an expert SQL developer. Generate efficient, secure SQL queries.",
    instruction="Convert the following natural language query to SQL:\n{query}",
    few_shot_examples=True,
    output_format="SQL code block with explanatory comments"
)

# Configure few-shot learning
selector = FewShotSelector(
    examples_db="sql_examples.jsonl",
    selection_strategy="semantic_similarity",
    max_examples=3
)

# Generate optimized prompt
prompt = template.render(
    query="Find all users who registered in the last 30 days",
    examples=selector.select(query="user registration date filter")
)

Key Patterns

Progressive Disclosure

Start with simple prompts, add complexity only when needed:

  1. Level 1: Direct instruction

    • "Summarize this article"
  2. Level 2: Add constraints

    • "Summarize this article in 3 bullet points, focusing on key findings"
  3. Level 3: Add reasoning

    • "Read this article, identify the main findings, then summarize in 3 bullet points"
  4. Level 4: Add examples

    • Include 2-3 example summaries with input-output pairs

Instruction Hierarchy

[System Context] → [Task Instruction] → [Examples] → [Input Data] → [Output Format]

Error Recovery

Build prompts that gracefully handle failures:

  • Include fallback instructions
  • Request confidence scores
  • Ask for alternative interpretations when uncertain
  • Specify how to indicate missing information

Best Practices

  1. Be Specific: Vague prompts produce inconsistent results
  2. Show, Don't Tell: Examples are more effective than descriptions
  3. Test Extensively: Evaluate on diverse, representative inputs
  4. Iterate Rapidly: Small changes can have large impacts
  5. Monitor Performance: Track metrics in production
  6. Version Control: Treat prompts as code with proper versioning
  7. Document Intent: Explain why prompts are structured as they are

Common Pitfalls

  • Over-engineering: Starting with complex prompts before trying simple ones
  • Example pollution: Using examples that don't match the target task
  • Context overflow: Exceeding token limits with excessive examples
  • Ambiguous instructions: Leaving room for multiple interpretations
  • Ignoring edge cases: Not testing on unusual or boundary inputs

Integration Patterns

With RAG Systems

# Combine retrieved context with prompt engineering
prompt = f"""Given the following context:
{retrieved_context}

{few_shot_examples}

Question: {user_question}

Provide a detailed answer based solely on the context above. If the context doesn't contain enough information, explicitly state what's missing."""

With Validation

# Add self-verification step
prompt = f"""{main_task_prompt}

After generating your response, verify it meets these criteria:
1. Answers the question directly
2. Uses only information from provided context
3. Cites specific sources
4. Acknowledges any uncertainty

If verification fails, revise your response."""

Performance Optimization

Token Efficiency

  • Remove redundant words and phrases
  • Use abbreviations consistently after first definition
  • Consolidate similar instructions
  • Move stable content to system prompts

Latency Reduction

  • Minimize prompt length without sacrificing quality
  • Use streaming for long-form outputs
  • Cache common prompt prefixes
  • Batch similar requests when possible

Resources

  • references/few-shot-learning.md: Deep dive on example selection and construction
  • references/chain-of-thought.md: Advanced reasoning elicitation techniques
  • references/prompt-optimization.md: Systematic refinement workflows
  • references/prompt-templates.md: Reusable template patterns
  • references/system-prompts.md: System-level prompt design
  • assets/prompt-template-library.md: Battle-tested prompt templates
  • assets/few-shot-examples.json: Curated example datasets
  • scripts/optimize-prompt.py: Automated prompt optimization tool

Success Metrics

Track these KPIs for your prompts:

  • Accuracy: Correctness of outputs
  • Consistency: Reproducibility across similar inputs
  • Latency: Response time (P50, P95, P99)
  • Token Usage: Average tokens per request
  • Success Rate: Percentage of valid outputs
  • User Satisfaction: Ratings and feedback

Next Steps

  1. Review the prompt template library for common patterns
  2. Experiment with few-shot learning for your specific use case
  3. Implement prompt versioning and A/B testing
  4. Set up automated evaluation pipelines
  5. Document your prompt engineering decisions and learnings

Version History

  • e63f7dd Current 2026-07-05 09:36

Same Skill Collection

skills/accessibility-compliance-accessibility-audit/SKILL.md
skills/agent-orchestration-improve-agent/SKILL.md
skills/agent-orchestration-multi-agent-optimize/SKILL.md
skills/ai-engineer/SKILL.md
skills/airflow-dag-patterns/SKILL.md
skills/angular-migration/SKILL.md
skills/anti-reversing-techniques/SKILL.md
skills/api-design-principles/SKILL.md
skills/api-documenter/SKILL.md
skills/api-testing-observability-api-mock/SKILL.md
skills/application-performance-performance-optimization/SKILL.md
skills/architect-review/SKILL.md
skills/architecture-decision-records/SKILL.md
skills/architecture-patterns/SKILL.md
skills/arm-cortex-expert/SKILL.md
skills/article-illustrations/SKILL.md
skills/async-python-patterns/SKILL.md
skills/attack-tree-construction/SKILL.md
skills/auth-implementation-patterns/SKILL.md
skills/backend-architect/SKILL.md
skills/backend-development-feature-development/SKILL.md
skills/backend-security-coder/SKILL.md
skills/backtesting-frameworks/SKILL.md
skills/bash-defensive-patterns/SKILL.md
skills/bash-pro/SKILL.md
skills/bats-testing-patterns/SKILL.md
skills/bazel-build-optimization/SKILL.md
skills/billing-automation/SKILL.md
skills/binary-analysis-patterns/SKILL.md
skills/blockchain-developer/SKILL.md
skills/business-analyst/SKILL.md
skills/c-pro/SKILL.md
skills/c4-architecture-c4-architecture/SKILL.md
skills/c4-code/SKILL.md
skills/c4-component/SKILL.md
skills/c4-container/SKILL.md
skills/c4-context/SKILL.md
skills/changelog-automation/SKILL.md
skills/cicd-automation-workflow-automate/SKILL.md
skills/cloud-architect/SKILL.md
skills/code-documentation-code-explain/SKILL.md
skills/code-documentation-doc-generate/SKILL.md
skills/code-refactoring-context-restore/SKILL.md
skills/code-refactoring-refactor-clean/SKILL.md
skills/code-refactoring-tech-debt/SKILL.md
skills/code-review-ai-ai-review/SKILL.md
skills/code-review-excellence/SKILL.md
skills/code-reviewer/SKILL.md
skills/codebase-cleanup-deps-audit/SKILL.md
skills/codebase-cleanup-refactor-clean/SKILL.md
skills/codebase-cleanup-tech-debt/SKILL.md
skills/competitive-landscape/SKILL.md
skills/comprehensive-review-full-review/SKILL.md
skills/comprehensive-review-pr-enhance/SKILL.md
skills/conductor-implement/SKILL.md
skills/conductor-manage/SKILL.md
skills/conductor-new-track/SKILL.md
skills/conductor-revert/SKILL.md
skills/conductor-setup/SKILL.md
skills/conductor-status/SKILL.md
skills/conductor-validator/SKILL.md
skills/content-marketer/SKILL.md
skills/context-driven-development/SKILL.md
skills/context-management-context-restore/SKILL.md
skills/context-management-context-save/SKILL.md
skills/context-manager/SKILL.md
skills/cost-optimization/SKILL.md
skills/cpp-pro/SKILL.md
skills/cqrs-implementation/SKILL.md
skills/csharp-pro/SKILL.md
skills/customer-support/SKILL.md
skills/data-engineer/SKILL.md
skills/data-engineering-data-driven-feature/SKILL.md
skills/data-engineering-data-pipeline/SKILL.md
skills/data-quality-frameworks/SKILL.md
skills/data-scientist/SKILL.md
skills/data-storytelling/SKILL.md
skills/database-admin/SKILL.md
skills/database-architect/SKILL.md
skills/database-cloud-optimization-cost-optimize/SKILL.md
skills/database-migration/SKILL.md
skills/database-migrations-migration-observability/SKILL.md
skills/database-migrations-sql-migrations/SKILL.md
skills/database-optimizer/SKILL.md
skills/dbt-transformation-patterns/SKILL.md
skills/debugger/SKILL.md
skills/debugging-strategies/SKILL.md
skills/debugging-toolkit-smart-debug/SKILL.md
skills/defi-protocol-templates/SKILL.md
skills/dependency-management-deps-audit/SKILL.md
skills/dependency-upgrade/SKILL.md
skills/deployment-engineer/SKILL.md
skills/deployment-pipeline-design/SKILL.md
skills/deployment-validation-config-validate/SKILL.md
skills/devops-troubleshooter/SKILL.md
skills/distributed-debugging-debug-trace/SKILL.md
skills/distributed-tracing/SKILL.md
skills/django-pro/SKILL.md
skills/docs-architect/SKILL.md
skills/documentation-generation-doc-generate/SKILL.md
skills/dotnet-architect/SKILL.md
skills/dotnet-backend-patterns/SKILL.md
skills/dx-optimizer/SKILL.md
skills/e2e-testing-patterns/SKILL.md
skills/elixir-pro/SKILL.md
skills/embedding-strategies/SKILL.md
skills/employment-contract-templates/SKILL.md
skills/error-debugging-error-analysis/SKILL.md
skills/error-debugging-error-trace/SKILL.md
skills/error-debugging-multi-agent-review/SKILL.md
skills/error-detective/SKILL.md
skills/error-diagnostics-error-analysis/SKILL.md
skills/error-diagnostics-error-trace/SKILL.md
skills/error-diagnostics-smart-debug/SKILL.md
skills/error-handling-patterns/SKILL.md
skills/event-sourcing-architect/SKILL.md
skills/event-store-design/SKILL.md
skills/fastapi-pro/SKILL.md
skills/fastapi-templates/SKILL.md
skills/firmware-analyst/SKILL.md
skills/flutter-expert/SKILL.md
skills/framework-migration-code-migrate/SKILL.md
skills/framework-migration-deps-upgrade/SKILL.md
skills/framework-migration-legacy-modernize/SKILL.md
skills/frontend-developer/SKILL.md
skills/frontend-mobile-development-component-scaffold/SKILL.md
skills/frontend-mobile-security-xss-scan/SKILL.md
skills/frontend-security-coder/SKILL.md
skills/full-stack-orchestration-full-stack-feature/SKILL.md
skills/gdpr-data-handling/SKILL.md
skills/git-advanced-workflows/SKILL.md
skills/git-pr-workflows-git-workflow/SKILL.md
skills/git-pr-workflows-onboard/SKILL.md
skills/git-pr-workflows-pr-enhance/SKILL.md
skills/github-actions-templates/SKILL.md
skills/gitlab-ci-patterns/SKILL.md
skills/gitops-workflow/SKILL.md
skills/go-concurrency-patterns/SKILL.md
skills/godot-gdscript-patterns/SKILL.md
skills/golang-pro/SKILL.md
skills/grafana-dashboards/SKILL.md
skills/graphql-architect/SKILL.md
skills/haskell-pro/SKILL.md
skills/helm-chart-scaffolding/SKILL.md
skills/hr-pro/SKILL.md
skills/hybrid-cloud-architect/SKILL.md
skills/hybrid-cloud-networking/SKILL.md
skills/hybrid-search-implementation/SKILL.md
skills/incident-responder/SKILL.md
skills/incident-response-incident-response/SKILL.md
skills/incident-response-smart-fix/SKILL.md
skills/incident-runbook-templates/SKILL.md
skills/ios-developer/SKILL.md
skills/istio-traffic-management/SKILL.md
skills/java-pro/SKILL.md
skills/javascript-pro/SKILL.md
skills/javascript-testing-patterns/SKILL.md
skills/javascript-typescript-typescript-scaffold/SKILL.md
skills/julia-pro/SKILL.md
skills/k8s-manifest-generator/SKILL.md
skills/k8s-security-policies/SKILL.md
skills/kpi-dashboard-design/SKILL.md
skills/kubernetes-architect/SKILL.md
skills/langchain-architecture/SKILL.md
skills/legacy-modernizer/SKILL.md
skills/legal-advisor/SKILL.md
skills/linkerd-patterns/SKILL.md
skills/llm-application-dev-ai-assistant/SKILL.md
skills/llm-application-dev-langchain-agent/SKILL.md
skills/llm-application-dev-prompt-optimize/SKILL.md
skills/llm-evaluation/SKILL.md
skills/machine-learning-ops-ml-pipeline/SKILL.md
skills/malware-analyst/SKILL.md
skills/market-sizing-analysis/SKILL.md
skills/memory-forensics/SKILL.md
skills/memory-safety-patterns/SKILL.md
skills/mermaid-expert/SKILL.md
skills/microservices-patterns/SKILL.md
skills/minecraft-bukkit-pro/SKILL.md
skills/ml-engineer/SKILL.md
skills/ml-pipeline-workflow/SKILL.md
skills/mlops-engineer/SKILL.md
skills/mobile-developer/SKILL.md
skills/mobile-security-coder/SKILL.md
skills/modern-javascript-patterns/SKILL.md
skills/monorepo-architect/SKILL.md
skills/monorepo-management/SKILL.md
skills/mtls-configuration/SKILL.md
skills/multi-cloud-architecture/SKILL.md
skills/multi-platform-apps-multi-platform/SKILL.md
skills/network-engineer/SKILL.md
skills/nextjs-app-router-patterns/SKILL.md
skills/nft-standards/SKILL.md
skills/nodejs-backend-patterns/SKILL.md
skills/nx-workspace-patterns/SKILL.md
skills/observability-engineer/SKILL.md
skills/observability-monitoring-monitor-setup/SKILL.md
skills/observability-monitoring-slo-implement/SKILL.md
skills/on-call-handoff-patterns/SKILL.md
skills/openapi-spec-generation/SKILL.md
skills/payment-integration/SKILL.md
skills/paypal-integration/SKILL.md
skills/pci-compliance/SKILL.md
skills/performance-engineer/SKILL.md
skills/performance-testing-review-ai-review/SKILL.md
skills/performance-testing-review-multi-agent-review/SKILL.md
skills/php-pro/SKILL.md
skills/posix-shell-pro/SKILL.md
skills/postgresql/SKILL.md
skills/postmortem-writing/SKILL.md
skills/projection-patterns/SKILL.md
skills/prometheus-configuration/SKILL.md
skills/prompt-engineer/SKILL.md
skills/protocol-reverse-engineering/SKILL.md
skills/python-packaging/SKILL.md
skills/python-performance-optimization/SKILL.md
skills/python-pro/SKILL.md
skills/python-testing-patterns/SKILL.md
skills/quant-analyst/SKILL.md
skills/rag-implementation/SKILL.md
skills/react-modernization/SKILL.md
skills/react-native-architecture/SKILL.md
skills/react-state-management/SKILL.md
skills/reference-builder/SKILL.md
skills/reverse-engineer/SKILL.md
skills/risk-manager/SKILL.md
skills/risk-metrics-calculation/SKILL.md
skills/ruby-pro/SKILL.md
skills/rust-async-patterns/SKILL.md
skills/rust-pro/SKILL.md
skills/saga-orchestration/SKILL.md
skills/sales-automator/SKILL.md
skills/sast-configuration/SKILL.md
skills/scala-pro/SKILL.md
skills/screen-reader-testing/SKILL.md
skills/search-specialist/SKILL.md
skills/secrets-management/SKILL.md
skills/security-auditor/SKILL.md
skills/security-compliance-compliance-check/SKILL.md
skills/security-requirement-extraction/SKILL.md
skills/security-scanning-security-dependencies/SKILL.md
skills/security-scanning-security-hardening/SKILL.md
skills/security-scanning-security-sast/SKILL.md
skills/seo-authority-builder/SKILL.md
skills/seo-cannibalization-detector/SKILL.md
skills/seo-content-auditor/SKILL.md
skills/seo-content-planner/SKILL.md
skills/seo-content-refresher/SKILL.md
skills/seo-content-writer/SKILL.md
skills/seo-keyword-strategist/SKILL.md
skills/seo-meta-optimizer/SKILL.md
skills/seo-snippet-hunter/SKILL.md
skills/seo-structure-architect/SKILL.md
skills/service-mesh-expert/SKILL.md
skills/service-mesh-observability/SKILL.md
skills/shellcheck-configuration/SKILL.md
skills/similarity-search-patterns/SKILL.md
skills/slo-implementation/SKILL.md
skills/solidity-security/SKILL.md
skills/spark-optimization/SKILL.md
skills/sql-optimization-patterns/SKILL.md
skills/sql-pro/SKILL.md
skills/startup-analyst/SKILL.md
skills/startup-business-analyst-business-case/SKILL.md
skills/startup-business-analyst-financial-projections/SKILL.md
skills/startup-business-analyst-market-opportunity/SKILL.md
skills/startup-financial-modeling/SKILL.md
skills/startup-metrics-framework/SKILL.md
skills/stride-analysis-patterns/SKILL.md
skills/stripe-integration/SKILL.md
skills/systems-programming-rust-project/SKILL.md
skills/tailwind-design-system/SKILL.md
skills/tdd-orchestrator/SKILL.md
skills/tdd-workflows-tdd-green/SKILL.md
skills/tdd-workflows-tdd-red/SKILL.md
skills/team-collaboration-issue/SKILL.md
skills/team-collaboration-standup-notes/SKILL.md
skills/team-composition-analysis/SKILL.md
skills/temporal-python-pro/SKILL.md
skills/temporal-python-testing/SKILL.md
skills/terraform-module-library/SKILL.md
skills/terraform-specialist/SKILL.md
skills/test-automator/SKILL.md
skills/threat-mitigation-mapping/SKILL.md
skills/threat-modeling-expert/SKILL.md
skills/track-management/SKILL.md
skills/turborepo-caching/SKILL.md
skills/tutorial-engineer/SKILL.md
skills/typescript-advanced-types/SKILL.md
skills/typescript-pro/SKILL.md
skills/ui-ux-designer/SKILL.md
skills/ui-visual-validator/SKILL.md
skills/unit-testing-test-generate/SKILL.md
skills/unity-developer/SKILL.md
skills/unity-ecs-patterns/SKILL.md
skills/uv-package-manager/SKILL.md
skills/vector-database-engineer/SKILL.md
skills/vector-index-tuning/SKILL.md
skills/wcag-audit-patterns/SKILL.md
skills/web3-testing/SKILL.md
skills/workflow-orchestration-patterns/SKILL.md
skills/workflow-patterns/SKILL.md
skills/tdd-workflows-tdd-cycle/SKILL.md
skills/tdd-workflows-tdd-refactor/SKILL.md

Metadata

Files
0
Version
e63f7dd
Hash
68c26f15
Indexed
2026-07-05 09:36

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-09 00:40
浙ICP备14020137号-1 $Carte des visiteurs$