prompt-engineering-patterns

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

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill prompt-engineering-patterns-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prompt-engineering-patterns
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/prompt-engineering-patterns
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill prompt-engineering-patterns-sanketadlak

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. This Skill provides proven patterns and tooling to design, test, and iteratively optimize prompts for reliability and performance. ## Core Features & Use Cases - Prompting Patterns: Implement few-shot learning with dynamic example selection, chain-of-thought reasoning with self-consistency, and structured JSON outputs enforced with Pydantic schemas. - Prompt Optimization: Run A/B tests and iterative refinement with the included optimization script, tracking accuracy, latency, token usage, and success rate metrics. - Template Systems: Build reusable prompt templates with variable interpolation, conditional sections, and role-based system prompts. - Use Case: You are building a sentiment analysis feature and outputs are inconsistent. Use this Skill to apply structured output with a Pydantic schema, add few-shot examples from the assets library, and A/B test prompt variations until accuracy exceeds your target. ## Quick Start Ask the AI to convert your existing prompt into a structured-output prompt with a Pydantic schema and then optimize it against a small test suite.

Frequently Asked Questions about prompt-engineering-patterns

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

FAQPage Schema
How do I get structured JSON output from an LLM?

Define a Pydantic schema describing the expected fields, then instruct the model to respond in JSON matching that schema and parse the response into the model. With LangChain you can use with_structured_output to enforce the schema automatically.

How do I improve LLM accuracy with few-shot prompting?

Select 2-5 examples closely matching your task using semantic similarity retrieval with embeddings, keep formatting consistent across examples, and stay within your token budget. Include edge-case examples to handle boundary inputs.

When should I use chain-of-thought prompting?

Use chain-of-thought for math, logical reasoning, multi-step planning, and debugging tasks where step-by-step reasoning improves accuracy. Skip it for simple factual lookups, creative writing, or latency-sensitive applications.

How do I A/B test two prompt variations?

Run both prompts against the same test suite and compare accuracy, latency, and token metrics. The included optimize-prompt.py script automates this with parallel test execution and statistical comparison of results.

Why does my LLM output fail JSON parsing?

Parsing fails when the model adds extra prose around the JSON or omits required fields. Fix it by adding explicit format instructions, showing a schema example in the prompt, and adding a fallback path that retries with a simpler prompt on validation errors.