Prompt Engineering Guide
Create effective prompts for AI coding assistants across multiple platforms (Claude, GPT-4, GitHub Copilot, Cursor, Windsurf).
Overview
Master prompt engineering fundamentals, advanced techniques, platform-specific optimizations, and proven templates. Learn to craft prompts that elicit accurate, relevant, and high-quality code and responses.
When to Use This Skill
- Creating/updating system prompts for AI agents
- Improving prompts producing inconsistent results
- Designing instruction files (.instructions.md, SKILL.md)
- Optimizing agent behavior for specific tasks
- Debugging problematic prompts
- Migrating prompts between platforms
Before You Write: 9-Dimension Analysis
Before writing any prompt, silently extract these 9 dimensions from the request:
| # | Dimension | Question |
|---|---|---|
| 1 | Task | What exactly should the model do? (verb + object) |
| 2 | Input | What data/context will the model receive? |
| 3 | Output | What should the result look like? (format, length, structure) |
| 4 | Constraints | What is forbidden or must be avoided? |
| 5 | Context | What background does the model need? |
| 6 | Audience | Who will consume the output? |
| 7 | Memory | Is there session history that must be preserved? |
| 8 | Success criteria | How do we know the prompt worked? |
| 9 | Examples | Are there samples of desired input/output? |
Missing dimensions → add reasonable defaults or ask the user before writing.
Framework Selector
Choose the architecture before writing. See prompt frameworks for full reference.
| Task type | Framework |
|---|---|
| Simple generation / single instruction | RTF (Role · Task · Format) |
| Content with audience and tone | CO-STAR |
| Complex multi-step task | RISEN |
| Full agent system prompt | CRISPE |
| Agent with tools / search | ReAct |
Core Principles
1. Clarity and Specificity
Be explicit and unambiguous:
Poor:
Do something with this text
Good:
Extract all dates, names, and organizations from this text.
Return as JSON with fields: dates[], names[], organizations[]
Rules:
- Use concrete examples
- Define exact success criteria
- Avoid ambiguity
- Specify output format precisely
2. Recommend Structure
<role>AI role and primary task</role>
<context>Necessary background information</context>
<instructions>
Step-by-step guidelines
1. First step
2. Second step
</instructions>
<output_format>Precise format description</output_format>
<examples>
<example id="1">
<input>Sample input</input>
<output>Expected output</output>
</example>
</examples>
<constraints>Task boundaries and what NOT to do</constraints>
3. Effective Delimiters
Markdown (simple prompts):
# Main Instructions
## Section 1
- Point A
- Point B
XML (complex structures):
<instructions>
<task>Main task</task>
<constraints>
<constraint>Limitation 1</constraint>
</constraints>
</instructions>
See prompt engineering fundamentals for comprehensive theory.
Core Techniques
Chain of Thought (CoT)
Encourage step-by-step reasoning:
Solve step by step:
1. Analyze input data
2. Identify patterns
3. Formulate hypothesis
4. Test with examples
5. Provide final answer with justification
Use for: Complex problems, multi-step analysis, debugging, architecture decisions
Few-Shot Learning
Provide 2-5 examples:
<examples>
<example id="1">
Input: "Buy iPhone 13"
Output: {"intent": "purchase", "product": "iPhone 13"}
</example>
<example id="2">
Input: "This phone is terrible!"
Output: {"intent": "complaint", "product": "unknown"}
</example>
</examples>
Now process: "Looking for good smartphone under $500"
Use for: Specific output formats, pattern learning, classification
Self-Consistency
For critical tasks:
Solve using three different methods.
Compare results and choose the most justified answer.
Explain your selection.
Use for: High-stakes decisions, complex calculations, architecture validation
See advanced techniques for more methods.
Platform-Specific Notes
- Claude: Excels with XML structure, supports prefilling, extended thinking
- GPT-4.1: Optimized for agentic workflows, long context (1M tokens), tool use
- Copilot/Cursor: Workspace-aware, instruction files, inline suggestions
- Local models: Simpler structures, more examples, shorter context
See platform-specific techniques for detailed optimizations.
Quick Reference
Prompt Creation Workflow
- Define goal clearly
- Choose structure (markdown/XML)
- Add examples (1-5)
- Specify output format
- Add constraints
- Test and iterate
Common Mistakes
- Ambiguous instructions
- Missing output format specification
- Too few/many examples
- Ignoring platform differences
- No constraints specified
Prompt Length Guidelines
- Simple tasks: 100-500 tokens
- Complex tasks: 500-2000 tokens
- System prompts: 1000-5000 tokens
- Max recommended: 8000 tokens
Examples Repository
See comprehensive examples for:
- System prompts for agents
- Code generation prompts
- Code review prompts
- Testing prompts
- Documentation prompts
- Refactoring prompts
See prompt templates for ready-to-use templates.
Further Reading
- Prompt Frameworks - Named frameworks (RTF, CO-STAR, RISEN, CRISPE, ReAct), Memory Block, PAC2026 positional structure
- Prompt Engineering Fundamentals - Theory and principles
- Advanced Prompting Techniques - Expert methods
- Platform-Specific Techniques - Claude, GPT-4, Copilot optimizations
- Practical Guidelines - Real-world best practices
- Comprehensive Examples - Copy-paste ready prompts
- Prompt Templates - Reusable templates
Source: ziltorian/ContextOrchestration — distributed by TomeVault.