prompt-engineering-patterns

Design, test, and optimize LLM prompts using few-shot, chain-of-thought, and structured output patterns.

2|Updated May 9, 2026
One-click install
npx skills add https://github.com/Manuel-Gartenkrot-Casal/AfterDrive_Intelligence --skill prompt-engineering-patterns-manuel-gartenkrot-casal
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: prompt-engineering-patterns
Source: https://github.com/Manuel-Gartenkrot-Casal/AfterDrive_Intelligence/tree/main/.agents/skills/prompt-engineering-patterns
Command: npx skills add https://github.com/Manuel-Gartenkrot-Casal/AfterDrive_Intelligence --skill prompt-engineering-patterns-manuel-gartenkrot-casal

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve? LLM prompts often produce inconsistent, unparseable, or low-quality outputs in production applications. This Skill provides proven prompt engineering patterns and an automated optimization script to systematically improve prompt accuracy, consistency, and token efficiency. ## Core Features & Use Cases - Few-Shot Learning: Select examples via semantic similarity, diversity sampling, or difficulty progression, with token-budget-aware selection. - Chain-of-Thought Reasoning: Apply zero-shot CoT, self-consistency voting, tree-of-thought, and verification steps for complex reasoning tasks. - Structured Outputs: Enforce Pydantic schemas and JSON mode for reliable, type-safe response parsing with error recovery fallbacks. - Prompt Optimization: Run A/B tests and iterative refinement with the included optimize-prompt.py script, tracking accuracy, latency, and token metrics. - Use Case: You are building a sentiment analysis feature and outputs are inconsistent. Use this Skill to apply a few-shot classification template, enforce a structured output schema, and A/B test prompt variations until accuracy exceeds your target. ## Quick Start Ask the AI to optimize your prompt for a classification task using few-shot examples and structured JSON output.

Frequently Asked Questions about prompt-engineering-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I improve LLM prompt accuracy with few-shot examples?▼

Select 1-10 examples using semantic similarity retrieval with embedding models, ensuring consistent input-output formatting across all examples. Balance example count against your context window budget, typically allocating around 38% of tokens to examples.

How to get structured JSON output from an LLM?▼

Define a Pydantic schema describing the expected fields and use structured output mode or JSON mode in your prompt. Add error handling with a fallback prompt that retries with a simpler instruction if JSON parsing or schema validation fails.

What is chain-of-thought prompting and when should I use it?▼

Chain-of-thought prompting elicits step-by-step reasoning by adding phrases like "Let's think step by step" or providing reasoning examples. Use it for math, logic, and multi-step tasks, but skip it for simple lookups or latency-sensitive applications.

How do I A/B test two prompt variations?▼

Run both prompts against the same test suite and measure accuracy, latency, and token usage. Use a statistical significance test such as a t-test with p < 0.05 to confirm the winning variant's improvement is not due to chance.

Why does my prompt produce inconsistent outputs across runs?▼

Inconsistency usually comes from ambiguous instructions, missing output format constraints, or high sampling temperature. Add explicit format requirements, include examples, and measure consistency by running identical inputs multiple times.

When should I not use few-shot prompting?▼

Avoid few-shot prompting when examples do not match the target task, when token limits are tight, or when the model already performs well zero-shot. Poorly chosen examples can cause the model to overfit to example patterns.