prompt-engineering-patterns

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

2|1|Updated Jun 9, 2026
One-click install
npx skills add https://github.com/zester4/zilmate --skill prompt-engineering-patterns-zester4
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prompt-engineering-patterns
Source: https://github.com/zester4/zilmate/tree/main/.agents/skills/prompt-engineering-patterns
Command: npx skills add https://github.com/zester4/zilmate --skill prompt-engineering-patterns-zester4

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, templates, and an automated optimization script to systematically improve prompt accuracy, consistency, and token efficiency. ## Core Features & Use Cases - Reasoning Patterns: Implement zero-shot and few-shot chain-of-thought, self-consistency voting, least-to-most decomposition, and tree-of-thought exploration for complex reasoning tasks. - Structured Outputs & Templates: Enforce Pydantic schemas for reliable JSON parsing, and build reusable prompt templates with variable interpolation, conditionals, and role-based system prompts. - Automated Optimization: Run A/B tests and iterative prompt refinement with the included Python optimizer that tracks accuracy, latency, and token metrics. - Use Case: You are building a customer support classifier that returns malformed JSON 20% of the time. Use this Skill to apply structured output patterns with Pydantic validation, add dynamically selected few-shot examples, and A/B test prompt variants until accuracy exceeds 95%. ## Quick Start Ask the AI to optimize your existing prompt for a classification task using few-shot examples and structured JSON output with Pydantic validation.

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 with JSON matching that schema. LangChain's with_structured_output method automates this binding, and you should add fallback handling for JSON decode or validation errors.

How do I improve LLM accuracy on reasoning tasks?

Use chain-of-thought prompting by adding 'Let's think step by step' or providing few-shot examples with explicit reasoning traces. For higher reliability, apply self-consistency by sampling multiple reasoning paths and taking the majority answer.

How do I select few-shot examples for prompts?

Use semantic similarity selection with embedding models to retrieve examples closest to each query, or diversity sampling via clustering to cover edge cases. Balance example count against your context window token budget.

When should I not use chain-of-thought prompting?

Skip chain-of-thought for simple factual lookups, direct retrieval, creative writing, and latency-sensitive real-time applications. CoT adds tokens and response time, so reserve it for math, logic, multi-step planning, and debugging tasks.

How do I A/B test two prompt versions?

Run both prompts against the same test suite, measuring accuracy, latency, and token usage per variant. Use a statistical significance test such as a t-test on the metric distributions before declaring a winner.

Why does my prompt produce inconsistent outputs?

Inconsistency usually comes from ambiguous instructions, missing output format constraints, or examples that do not match the target task. Add explicit format requirements, edge-case examples, and a verification step, then measure consistency across repeated runs.