
Prompt Engineer
Tune system prompts, context layout, and RAG so long-running coding agents follow instructions without burning tokens on noise.
Overview
Prompt-engineer is a journey-wide agent skill that structures system prompts, history, and RAG around signal-to-noise—usable whenever a solo builder needs to design or debug agent context before committing to behavior or
Install
npx skills add https://github.com/jeffallan/claude-skills --skill prompt-engineerWhat is this skill?
- Frames the context window as an attention budget and optimizes signal-to-noise ratio (SNR) for reasoning quality
- Maps four persistent context components: system prompt, few-shot examples, conversation history, and retrieved RAG conte
- Recommends XML-style delimiters (<instructions>, data blocks) so models separate rules from payloads
- Covers debugging ignored instructions, mid-conversation hallucination, and token/latency tradeoffs in long sessions
- Guides structuring conversation history and evaluating how retrieval quality affects downstream reasoning
- Documents 4 core context components: system prompt, few-shot examples, conversation history, and retrieved RAG context
Adoption & trust: 3k installs on skills.sh; 9.7k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your agent has a huge context window but still drifts, ignores rules, or gets slow and costly because instructions, examples, chat, and RAG are piled together without a clear attention budget.
Who is it for?
Builders authoring multi-step agents, custom skills, or RAG-backed assistants who need repeatable context architecture and debug playbooks for instruction drift.
Skip if: Teams that only need a one-line system prompt for a single-shot task, or builders with no agent context design problem and no long-running sessions to optimize.
When should I use this skill?
Designing system prompts for complex agents, debugging instruction drift or hallucination, optimizing token usage, or structuring conversation history and RAG for higher SNR.
What do I get? / Deliverables
After applying the reference, you get delimiter-separated prompt layers, an explicit SNR mindset, and retrievable context placement that improves instruction adherence and token efficiency in long coding sessions.
- Structured prompt layout with separated instructions, examples, history policy, and RAG placement
- Debug checklist for SNR, retrieval quality, and mid-session drift
Recommended Skills
Journey fit
Useful at every journey phase - explore requirements and options before committing to a direction.
Where it fits
Shape a minimal system prompt and few-shot block before demoing an agent on a landing-page chat widget.
Partition SKILL.md rules, tool outputs, and user data with XML delimiters in a new repo skill.
Diagnose why code-review agent hallucinates file contents after ten turns of noisy chat history.
Trim RAG chunks and refresh static instructions to cut latency on a support bot in production.
Keep marketing and docs snippets out of the coding agent system band so product copy does not steal attention budget.
How it compares
Use as procedural reference for context budgeting—not a hosted prompt playground or an MCP retrieval server.
Common Questions / FAQ
Who is prompt-engineer for?
Solo and indie builders shipping AI-assisted products who design system prompts, skill packs, or RAG-backed coding agents and care about cost, latency, and instruction fidelity.
When should I use prompt-engineer?
During Build when scaffolding agent-tooling and skills; during Ship when reviewing why an agent ignores tests or security rules mid-run; during Operate when iterating on production prompt packs; and during Validate when prototyping agent UX before full build.
Is prompt-engineer safe to install?
It is documentation-style guidance without built-in shell or network actions from the skill itself; review the Security Audits panel on this Prism page before installing any repo skill.
SKILL.md
READMESKILL.md - Prompt Engineer
# Context Management <!-- Content adapted from PR #168 (context-engineer skill) by Genius-apple (https://github.com/Genius-apple). --> <!-- Original submission: https://github.com/Jeffallan/claude-skills/pull/168 --> --- ## When to Use This Reference - Designing system prompts for complex agents with large context windows - Debugging agents that ignore instructions or hallucinate mid-conversation - Optimizing token usage for cost or latency in long-running sessions - Structuring conversation history and RAG retrieval for maximum signal - Evaluating retrieval quality impact on reasoning --- ## The Context Budget The context window is a scarce resource — an **attention budget**. Every token consumes attention capacity. Irrelevant tokens actively degrade performance. **Key metric:** Signal-to-Noise Ratio (SNR). Higher SNR = better reasoning quality. ### Context Components | Component | Purpose | Persistence | |-----------|---------|-------------| | **System Prompt** | Identity, permanent rules, output format | Static across session | | **Few-Shot Examples** | Demonstrations of desired behavior | Static or semi-static | | **Conversation History** | Short-term memory (user interactions) | Grows per turn | | **Retrieved Context (RAG)** | Long-term memory or external knowledge | Dynamic per query | ### Structuring Context with XML Tags Use explicit delimiters to separate context types. This helps the model distinguish instructions from data: ```xml <instructions> You are an expert code reviewer... </instructions> <documents> <doc id="1" source="auth.py">...</doc> <doc id="2" source="models.py">...</doc> </documents> <history> ...recent conversation turns... </history> <query> ...current user message... </query> ``` ### Recommended Ordering 1. System Instructions (highest primacy bias) 2. Reference Material (RAG documents) 3. Few-Shot Examples 4. Conversation History 5. User Query (highest recency bias) --- ## Context Degradation Patterns ### Lost-in-the-Middle **Symptom:** Agent ignores instructions or facts placed in the middle of long context. **Cause:** LLMs exhibit primacy bias (strong attention to the start) and recency bias (strong attention to the end). Content in the middle receives less attention. **Mitigation:** Move critical instructions to the beginning (system prompt) or repeat them near the end, just before the user query: ```python # Vulnerable to lost-in-the-middle prompt = system_prompt + long_history + user_query # Mitigated: critical instructions repeated near the end prompt = system_prompt + long_history + instruction_reminder + user_query ``` ### Context Poisoning **Symptom:** Irrelevant or conflicting information from previous turns confuses the agent, producing contradictory or stale outputs. **Mitigation:** - Explicitly invalidate outdated information: *"Ignore the previous constraint about X; focus only on Y."* - When context shifts significantly, insert a clear boundary marker - Summarize and replace older turns rather than accumulating verbatim history ### Distraction / Dilution **Symptom:** Too much irrelevant detail reduces reasoning quality, even when the answer exists in context. **Mitigation:** - Filter RAG results to only highly relevant documents - Summarize verbose tool outputs before injecting into context - Remove redundant or low-information turns from history --- ## The Four-Bucket Approach A tiered strategy for managing context across long sessions: | Bucket | Content | Treatment | |--------|---------|-----------| | **1. Critical Instructions** | System prompt, core constraints | Always present, verbatim | | **2. Immediate Context** | Last 3-5 conversation turns | Verbatim, always included | | **3. Relevant History** | Semantically matched past context | Retrieved via search (RAG) | | **4. Archived History** | Everything else | Summarized or discarded | This prevents unbounded context growth while preserving the most important information. As conversa