prompting-patterns

Automate prompt engineering with structured templates, few-shot examples, and injection prevention.

2|Updated Nov 13, 2025
One-click install
npx skills add https://github.com/ricardoroche/ricardos-claude-code --skill prompting-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prompting-patterns
Source: https://github.com/ricardoroche/ricardos-claude-code/tree/main/.claude/skills/prompting-patterns
Command: npx skills add https://github.com/ricardoroche/ricardos-claude-code --skill prompting-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pydantic.

What problem does it solve?

This Skill provides a structured approach to prompt engineering, addressing challenges like inconsistent LLM responses, prompt injection vulnerabilities, and context window limitations. It ensures your LLM applications are reliable, secure, and deliver high-quality outputs.

Core Features & Use Cases

  • Structured Prompt Templates: Guides on creating reusable prompt templates with system messages, variables, and few-shot examples using Pydantic.
  • Prompt Injection Prevention: Provides patterns for sanitizing user input and wrapping it with clear boundaries to mitigate injection risks.
  • Few-Shot & Chain-of-Thought: Explains how to use few-shot examples for complex tasks and chain-of-thought prompting for detailed reasoning.
  • Context Window Management: Offers strategies for truncating message history and managing context window limits for long conversations.
  • Prompt Version Control: Introduces patterns for versioning prompts and tracking their performance metrics.
  • Use Case: A developer is building an LLM-powered summarization tool. This skill helps them create a PromptTemplate with a clear system message, few-shot examples for better accuracy, and integrate PromptSanitizer to protect against malicious user inputs.

Quick Start

Create a structured prompt template for summarizing documents, including a system message and a few-shot example.

Frequently Asked Questions about prompting-patterns

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

FAQPage Schema
How do I prevent prompt injection attacks in LLM applications?

Prompt injection prevention involves sanitizing user input and wrapping it with clear boundaries to isolate untrusted data from system instructions. This Skill provides patterns for input handling and safe formatting via Python classes to mitigate injection risks across system prompts and user queries.

What's the best way to structure prompts for consistent LLM responses?

Structured prompt templates using Pydantic classes define system messages, variables, and few-shot examples to guide LLM behavior consistently. This approach ensures reliable outputs and enables version control for tracking prompt performance metrics over time.

How do I handle context window limitations in long LLM conversations?

Context window management involves truncating message history and prioritizing recent or critical information to stay within token limits. This Skill covers strategies for managing conversation length while preserving context quality for long-running LLM applications.

How does chain-of-thought prompting improve LLM reasoning?

Chain-of-thought prompting guides LLMs through step-by-step reasoning for complex tasks by structuring prompts to show intermediate thinking. Combined with few-shot examples, it produces more detailed and accurate outputs than direct instruction alone.

Can I use Python Pydantic for building reusable prompt templates?

Yes. Pydantic classes enable structured prompt template design with validated fields, system messages, and variable injection. This provides type safety, composability, and consistent message assembly for LLM API integration.

Why do few-shot examples matter in prompt engineering?

Few-shot examples demonstrate the desired input-output pattern and reasoning style directly within prompts. They improve LLM accuracy for complex tasks without retraining and work alongside chain-of-thought for comprehensive instruction and demonstration.