| name | prompt-engineering |
| description | Unified methodology for deterministic AI interaction via Diátaxis (information architecture), COSTAR (prompt structure), and advanced reasoning techniques (CoT, Decision Matrices, Few-Shot). Transform LLMs from text predictors into cognitive decision engines. |
| license | MIT |
| compatibility | opencode |
Prompt Engineering: The Cognitive Architecture for AI Interaction
Context
This skill synthesizes five frameworks for deterministic AI prompting: Diátaxis (information architecture - intent), COSTAR (prompt structure - the skeleton), C.L.E.A.R. (quality assurance - optimization), Chain-of-Thought (logical processing), Decision Matrices (quantitative evaluation), and Few-Shot Prompting (pattern enforcement).
Philosophy: The "Ultimate Prompt" is not a long string of text—it's a meticulously engineered set of instructions that manages the model's context window, attention mechanisms, and reasoning topology.
Quick Reference
| Framework | Purpose | Question It Answers | Measurable Impact |
|---|
| Diátaxis | Information architecture | What kind of output? | Eliminates mode confusion (95% accuracy) |
| COSTAR | Prompt structure | How to organize the prompt? | Provides systematic structure, +55% clarity |
| C.L.E.A.R. | Quality assurance | How to optimize the prompt? | 70% token reduction, 91% fewer hallucinations |
| Chain-of-Thought | Logical decomposition | How to reason through complex tasks? | +394% math accuracy |
| Decision Matrices | Quantitative evaluation | How to compare options objectively? | Mathematical justification vs vague assertions |
| Few-Shot | Pattern enforcement | How to demonstrate desired behavior? | 70% variance reduction |
Decision Matrix
<decision_matrix>
What do you need to accomplish?
Complete Diátaxis methodology with four quadrants, adaptive routing, and integration patterns
Complete COSTAR framework - the structural engine for organizing prompt components
Complete C.L.E.A.R. framework with templates, validation checklists, and quantitative impact metrics
Mid-conversation injection patterns, imperative syntax (STOP, MUST), and attention management strategies to break context inertia
Advanced reasoning techniques: CoT, Decision Matrices, Tree of Thoughts, and Few-Shot patterns
Master template integrating all frameworks (Diátaxis, COSTAR, C.L.E.A.R., CoT, Decision Matrix, Few-Shot) into a unified architecture
Theoretical underpinnings: attention mechanisms, latent space activation, cognitive alignment. See Diátaxis Framework for detailed explanation of information architecture principles.
Anti-patterns, before/after comparisons, and validation checklist for production-ready prompts. See C.L.E.A.R. Framework for detailed quality assurance methodology.
Anti-patterns, before/after comparisons, and validation checklist for production-ready prompts. See C.L.E.A.R. Framework for detailed quality assurance methodology.
Key Principles
1. Diátaxis Defines Teleology (The Purpose)
- Select ONE quadrant per prompt (Tutorial, How-To, Reference, Explanation)
- Mixed modes fail at both (e.g., Tutorial + Reference frustrates beginners and experts alike)
- Explicitly inhibit content that violates the chosen quadrant
2. COSTAR Defines Structure (The Skeleton)
- Context: Anchor latent space with domain expertise and Diátxis mode
- Objective: Define singular, testable goal with imperative verbs
- Style/Tone: Calibrate language structure and emotional resonance to match persona
- Audience: Specify expertise level to prevent over/under-explanation
- Response: Exact output schema (JSON, table, prose) with constraints
3. C.L.E.A.R. Defines Quality (The Optimization)
- Concise: Maximize signal-to-noise ratio (strip fillers, 70% token reduction)
- Logical: Sequence instructions autoregressively (follow COSTAR order)
- Explicit: Define output space precisely (objective metrics, 91% hallucination reduction)
- Adaptive: Handle edge cases with conditional logic (IF X, THEN Y state machine)
- Reflective: Self-correction before output (quality control loop, 67% error reduction)
4. Chain-of-Thought Defines Epistemology (The Reasoning)
- Decompose complex problems into intermediate reasoning steps
- Use
<thinking> block to externalize thought process
- Apply "step budget" to prevent shallow conclusions
- Explore multiple branches with Tree of Thoughts
5. Decision Matrices Define Quantification (The Evaluation)
- Transform vague assertions into mathematical justification
- Weight criteria by importance to user context
- Use probability ranges for uncertain data (Quantum Decision Matrix)
- Critical workflow: CoT reasoning → Extract values → Populate matrix
6. Few-Shot Defines Enforcement (The Pattern)
- Show reasoning traces, not just input/output (2-5 examples optimal)
- Demonstrate specific Diátxis modes
- Avoid over-prompting (>5 examples degrades performance)
- Use examples to enforce C.L.E.A.R. structure
7. Injection Defines Interruption (The Offense)
- Distinction:
- Prompting (System Start): Sets Persona/Context (COSTAR).
- Injection (Mid-Flow): Interrupts Inertia (Directive).
- Principle: "If you inject, you must command."
- Mechanism: Synthetic messages act as "System Interventions" that must override previous context.
- Language: Use
STOP, CRITICAL, MUST to break attention decay.
Quantitative Impact
| Metric | Zero-Shot Baseline | With Full Framework | Improvement |
|---|
| Math Reasoning (GSM8K) | 18.8% | 93.0% | +394% |
| Token Efficiency | 100% | 30% | 70% reduction |
| Hallucination Rate | 19% | 1.7% | 91% reduction |
| Edge Case Handling | 61% | 92% | +51% |
| Constraint Adherence | 74% | 98% | +32% |
| Reasoning Accuracy | 68% | 91% | +34% |
Setup
No installation required. This is a portable methodology skill for AI prompt engineering.
Prerequisites:
- Understanding of basic LLM prompting concepts
- Familiarity with Markdown and JSON formats
- Experience with at least one major LLM (GPT-4, Claude 3, Gemini)
Learning Path:
-
Start with Diátaxis (5 minutes)
- Learn the four quadrants
- Understand which mode to use when
- See the adaptive routing logic
-
Master COSTAR (10 minutes)
- Learn the six components (C-O-S-T-A-R)
- Build the structural skeleton
- Practice writing Context, Objective, Response sections
-
Apply C.L.E.A.R. Optimization (10 minutes)
- Review prompts for Conciseness
- Ensure Logical flow
- Make instructions Explicit
- Add Adaptive edge-case handling
- Include Reflective self-audit
-
Implement Reasoning Techniques (15 minutes)
- Add Chain-of-Thought for complex tasks
- Use Decision Matrices for comparisons
- Apply Few-Shot for pattern enforcement
-
Synthesize with Grand Template (10 minutes)
- Integrate all frameworks
- Use the Cognitive Decision Architect template
- Validate using the checklist
Common Prompt Failures (Anti-Patterns)
❌ Mode Confusion: "Teach me Python" with reference tables mixed in
✅ Fix: Single Diátxis quadrant per prompt (Tutorial mode only)
❌ Low Signal-to-Noise: "If you could please help me by..."
✅ Fix: Concise principle → "Review this code for vulnerabilities"
❌ Ambiguous Output: "Write a brief summary"
✅ Fix: Explicit principle → "Write exactly 3 sentences, 50 words max"
❌ Brittle on Edge Cases: "Classify sentiment" fails on mixed sentiment
✅ Fix: Adaptive principle → "If mixed positive/negative, output 'mixed' with breakdown"
❌ No Quality Control: First-pass output with errors
✅ Fix: Reflective principle → Add <reflection> block before output
Advanced Techniques
Adaptive Mode Router: Dynamically switch Diátxis modes based on user intent
IF query contains "how do I" → HOW-TO mode (imperative, concise)
ELIF query contains "what is" → EXPLANATION mode (narrative, contextual)
ELIF query contains "teach me" → TUTORIAL mode (pedagogical, linear)
ELIF query contains "list/show" → REFERENCE mode (tables, structured)
Quantum Decision Matrices: Use probability ranges for uncertain data
| Criterion | Option A | Option B | Uncertainty |
| :---------- | :---------- | :---------- | :----------------- |
| Performance | 0.85 ± 0.10 | 0.72 ± 0.15 | High variance in B |
Tree of Thoughts: Explore multiple reasoning branches
Generate 3 distinct decision paths (Branch A, B, C)
Evaluate pros/cons of each
Converge on optimal path with justification
Validation Checklist
For production-ready prompts, verify:
Diátaxis:
C.L.E.A.R.:
Reasoning:
Score: 20/20 = Production-ready
Architecture Note
Functional Skill: Portable methodology, not domain-specific knowledge.
Semantic Cohesion: The three comprehensive references are fundamentally interconnected:
- Diátaxis → Defines output mode and persona
- C.L.E.A.R. → Optimizes prompt structure for that mode
- Reasoning Techniques → Provides logical depth for complex tasks
Progressive Disclosure: Comprehensive references are JIT-loaded via decision matrix. Don't pre-read all.
Future Outlook
The manual construction of these prompts is current state-of-the-art, but Automated Prompt Engineering (APE) systems (DSPy, etc.) are emerging to compile high-level intent into complex architectures automatically.
However, the principles remain constant:
- Diátaxis = Information structure
- C.L.E.A.R. = Instruction quality
- CoT/Matrices/Few-Shot = Reasoning depth
Whether written by humans or AI optimizers, effective prompting must respect these three pillars.
**Next Steps**: Use the Decision Matrix above to navigate to comprehensive guides based on your task.