Prompt Engineering Skill
Overview
The prompt-engineering skill establishes a disciplined approach to LLM instruction design within the KILO-KIT ecosystem. Moving beyond ad-hoc prompting, this skill treats prompts as first-class code, emphasizing contract-based structures, declarative signatures, and rigorous validation loops to ensure reproducible, high-quality AI behavior.
When To Use
- When developing new LLM-powered features or agents.
- When existing prompts produce inconsistent, fragile, or hallucinated outputs.
- When implementing complex reasoning tasks that require strict output formatting.
- When you need to scale prompt maintenance across a team or large codebase.
- When setting up automated prompt optimization or regression testing pipelines.
Core Concepts
Contract-First Prompt Architecture
Prompts are defined using a 5-part structure to ensure clarity and modularity:
- Identity: Define the persona, expertise, and operational boundaries.
- Context Boundaries: Explicitly define what data is in-scope and what is off-limits.
- Operational Rules: Step-by-step logic and prioritized directives.
- Edge Cases: Explicit handling of ambiguous, empty, or adversarial inputs.
- Output Schemas: Declarative JSON, XML, or Pydantic schemas to enforce structured output.
Reasoning Model Steerability
Optimizing for advanced reasoning models (e.g., o1, o3, Gemini 2.0+):
- Reasoning Effort Control: Explicitly specify constraints to trade-off speed vs. reasoning depth.
- Chain-of-Symbol (CoS): Use compact symbol-based notation for complex logic to minimize token usage and improve coherence.
- XML/Markdown Boundary Formatting: Utilize strict XML tags (e.g., , , ) to segment reasoning from content.
DSPy Integration
Leverage programmatic prompt optimization:
- Signatures: Define declarative Input/Output contracts.
- Optimizers: Apply
BootstrapFewShot, MIPROv2, or COPRO to automatically refine prompts based on validation datasets.
Workflow
- Define: Create a declarative signature for the task.
- Draft: Implement using the Contract-First structure.
- Optimize: Run meta-prompting loops (using
pro models) to critique and refine.
- Validate: Test against a set of representative inputs and boundary cases.
- Iterate: Use DSPy optimizers to refine instruction logic.
- Deploy & Monitor: Version control the final prompt as code.
Key Patterns
- Semantic Diversity: Select Few-Shot examples based on embedding-space diversity rather than arbitrary selection.
- Negative Constraint Prioritization: Explicitly list what NOT to do, placing these at the beginning of the operational rules.
- Structured Output First: Enforce JSON/Schema output early in the instruction stream to prevent preamble bloat.
- Self-Correction Loops: Instruct the model to critique its own intermediate steps before generating the final output.
Quality Gates
- Contract Adherence: Does the output strictly follow the schema?
- Ambiguity Check: Can the prompt produce valid responses for empty or malformed input?
- Few-Shot Quality: Are examples diverse, representative, and error-free?
- Regression Testing: Does this version outperform the previous version on the golden test set?
- Token Efficiency: Have unnecessary filler instructions been removed?
References
1---2name: prompt-engineering3description: Use when designing, optimizing, testing, or deploying robust prompt systems for AI agents. This skill provides frameworks for structured prompt engineering, meta-prompting, and automated optimization workflows.4---56# Prompt Engineering Skill78## Overview9The `prompt-engineering` skill establishes a disciplined approach to LLM instruction design within the KILO-KIT ecosystem. Moving beyond ad-hoc prompting, this skill treats prompts as first-class code, emphasizing contract-based structures, declarative signatures, and rigorous validation loops to ensure reproducible, high-quality AI behavior.1011## When To Use12- When developing new LLM-powered features or agents.13- When existing prompts produce inconsistent, fragile, or hallucinated outputs.14- When implementing complex reasoning tasks that require strict output formatting.15- When you need to scale prompt maintenance across a team or large codebase.16- When setting up automated prompt optimization or regression testing pipelines.1718## Core Concepts1920### Contract-First Prompt Architecture21Prompts are defined using a 5-part structure to ensure clarity and modularity:221. **Identity**: Define the persona, expertise, and operational boundaries.232. **Context Boundaries**: Explicitly define what data is in-scope and what is off-limits.243. **Operational Rules**: Step-by-step logic and prioritized directives.254. **Edge Cases**: Explicit handling of ambiguous, empty, or adversarial inputs.265. **Output Schemas**: Declarative JSON, XML, or Pydantic schemas to enforce structured output.2728### Reasoning Model Steerability29Optimizing for advanced reasoning models (e.g., o1, o3, Gemini 2.0+):30- **Reasoning Effort Control**: Explicitly specify constraints to trade-off speed vs. reasoning depth.31- **Chain-of-Symbol (CoS)**: Use compact symbol-based notation for complex logic to minimize token usage and improve coherence.32- **XML/Markdown Boundary Formatting**: Utilize strict XML tags (e.g., <thought>, <logic>, <result>) to segment reasoning from content.3334### DSPy Integration35Leverage programmatic prompt optimization:36- **Signatures**: Define declarative Input/Output contracts.37- **Optimizers**: Apply `BootstrapFewShot`, `MIPROv2`, or `COPRO` to automatically refine prompts based on validation datasets.3839## Workflow401. **Define**: Create a declarative signature for the task.412. **Draft**: Implement using the Contract-First structure.423. **Optimize**: Run meta-prompting loops (using `pro` models) to critique and refine.434. **Validate**: Test against a set of representative inputs and boundary cases.445. **Iterate**: Use DSPy optimizers to refine instruction logic.456. **Deploy & Monitor**: Version control the final prompt as code.4647## Key Patterns48- **Semantic Diversity**: Select Few-Shot examples based on embedding-space diversity rather than arbitrary selection.49- **Negative Constraint Prioritization**: Explicitly list what NOT to do, placing these at the beginning of the operational rules.50- **Structured Output First**: Enforce JSON/Schema output early in the instruction stream to prevent preamble bloat.51- **Self-Correction Loops**: Instruct the model to critique its own intermediate steps before generating the final output.5253## Quality Gates54- **Contract Adherence**: Does the output strictly follow the schema?55- **Ambiguity Check**: Can the prompt produce valid responses for empty or malformed input?56- **Few-Shot Quality**: Are examples diverse, representative, and error-free?57- **Regression Testing**: Does this version outperform the previous version on the golden test set?58- **Token Efficiency**: Have unnecessary filler instructions been removed?5960## References61- [DSPy Documentation](https://dspy-docs.vercel.app/)62- [Anthropic Prompt Engineering Guide](https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering)63- [OpenAI Prompt Engineering Best Practices](https://platform.openai.com/docs/guides/prompt-engineering)64- KILO-KIT Architecture ADRs on Prompt Versioning