prompt-engineering

Engineer LLM prompts using zero-shot, few-shot, chain-of-thought, and structured output techniques.

1|Updated Feb 24, 2026
One-click install
npx skills add https://github.com/masermediagroup-stack/maser-media --skill prompt-engineering-masermediagroup-stack
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: prompt-engineering
Source: https://github.com/masermediagroup-stack/maser-media/tree/main/.cursor/skills/community/ai-design-components/skills/prompt-engineering
Command: npx skills add https://github.com/masermediagroup-stack/maser-media --skill prompt-engineering-masermediagroup-stack

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires openai, anthropic, langchain, langchain-openai, pydantic, tiktoken, tenacity, and includes scripts (resource) and references (resource) components.

What problem does it solve? LLM outputs are often unreliable, inconsistent, or fail to produce structured data, forcing developers into trial-and-error prompt iteration. This Skill provides systematic, research-backed prompting patterns that improve accuracy, reduce hallucination, and lower token costs across OpenAI, Anthropic, Google, and open-source models. ## Core Features & Use Cases - Proven Prompting Patterns: Apply zero-shot, few-shot, chain-of-thought, structured output (JSON mode/tool calling), system prompts, and prompt chaining with a decision framework for choosing the right technique. - Multi-Provider Portability: Adapt prompts across OpenAI GPT, Anthropic Claude, Google Gemini, and Meta Llama with provider-specific guidance and Python/TypeScript examples. - Production Tooling: Use scripts for prompt validation, injection detection, token counting, cost estimation, and A/B testing of prompt variants. - Use Case: When building a RAG question-answering system whose JSON parsing keeps failing, apply the structured output patterns with Pydantic/Zod validation and the RAG reference guide to get reliable, cited answers. ## Quick Start Ask the AI to design a chain-of-thought prompt with structured JSON output for your specific task, following the technique decision framework in this Skill.

Frequently Asked Questions about prompt-engineering

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

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

Use native JSON mode on OpenAI (response_format json_object) or tool use on Anthropic Claude with an input_schema defining your structure. Validate responses with Pydantic in Python or Zod in TypeScript instead of parsing raw text.

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

Use chain-of-thought for complex reasoning tasks like math, logic puzzles, and multi-hop question answering, where showing intermediate steps improves accuracy by 20-50%. It is unnecessary for simple factual recall or basic classification.

How many few-shot examples should I include in a prompt?▼

Use 2-5 diverse, high-quality examples; performance typically plateaus after 5-7 examples. Include edge cases, keep formatting consistent, and randomize example order to avoid position bias.

LangChain vs Vercel AI SDK for prompt workflows?▼

LangChain suits complex Python workflows like RAG pipelines, agents, and multi-step chains with LCEL composition. Vercel AI SDK is better for TypeScript/React apps needing streaming, type-safe structured outputs, and multi-provider support.

How do I reduce LLM API costs for repeated prompts?▼

Use Anthropic prompt caching with cache_control on large repeated context blocks for up to 90% cost reduction on cached tokens. Also count tokens before execution, set temperature appropriately, and cache prompt prefixes across chained calls.

How do I prevent prompt injection attacks?▼

Sanitize user input by detecting patterns like 'ignore previous instructions', wrap user content in delimiters or XML tags, and instruct the model in the system prompt to ignore instructions embedded in user text. The included prompt-validator script automates these checks.