Reusable Patterns
Context Engineering Templates
Reusable templates for Claude context packets, source packets, compaction handoffs, MCP resource inventories, and token-budget reviews.
"The token count should be considered an estimate."
Source: Token counting, Claude Platform Docs.
Template 1: Context packet
Use this when a human or orchestrator needs to hand Claude a bounded task with clear source boundaries.
<context_packet>
<task>
What Claude should accomplish in this run.
</task>
<success_criteria>
Concrete checks for a good answer or completed action.
</success_criteria>
<allowed_actions>
Tools, edits, commands, or decisions Claude may perform.
</allowed_actions>
<constraints>
Hard boundaries, security rules, freshness requirements, and non-goals.
</constraints>
<sources>
Source list with URLs, file paths, timestamps, and relevance notes.
</sources>
</context_packet> Template 2: Source packet
Use this when accuracy depends on verifiable evidence. The point is to separate source metadata from interpretation.
<source_packet generated_at="2026-07-06">
<source id="S1">
<title>Context windows</title>
<publisher>Claude Platform Docs</publisher>
<url>https://platform.claude.com/docs/en/build-with-claude/context-windows</url>
<accessed>2026-07-06</accessed>
<relevance>Defines context-window behavior and compaction guidance.</relevance>
<notes>Use for current Claude context-window claims.</notes>
</source>
</source_packet> Template 3: Compaction handoff
Use this when a session is about to be compacted or handed to another agent. Preserve exact facts, unresolved risks, and next actions.
<compaction_handoff>
<objective>Current goal and why it matters.</objective>
<decisions>Decisions already made, with reasons.</decisions>
<state>Files touched, commands run, source facts established.</state>
<open_questions>Unknowns that still affect the outcome.</open_questions>
<next_actions>Ordered, concrete next steps.</next_actions>
<do_not_repeat>Explorations already ruled out.</do_not_repeat>
</compaction_handoff> Template 4: MCP resource inventory
Use this before adding MCP resources to an agent. It makes resource priority, sensitivity, and freshness explicit.
resource: file:///repo/README.md
owner: engineering-docs
audience: assistant,user
priority: 0.8
lastModified: 2026-07-01T18:12:00Z
sensitivity: internal
load_strategy: summary-first
refresh_rule: check lastModified before use
failure_mode: if unavailable, ask for current docs rather than guessing FAQ
Can I paste these templates directly into Claude?
Yes, but adapt them. Remove unused fields, keep source metadata current, and avoid adding structure that the task does not need.
Do templates replace evals?
No. Templates make context clearer. Evals still determine whether the structure improves outcomes.
Sources Used
- Prompting best practices, Claude Platform Docs. Accessed 2026-07-06. Official guidance on clear instructions, examples, XML sections, long-context prompting, and tool-use prompting.
- Token counting, Claude Platform Docs. Accessed 2026-07-06. Official endpoint guidance for estimating input tokens, costs, rate limits, and model routing.
- Context engineering: memory, compaction, and tool clearing, Claude Cookbook. Accessed 2026-07-06. Cookbook comparison of server-side compaction, context editing, tool-result clearing, and memory.
- Resources, Model Context Protocol Specification. Accessed 2026-07-06. Protocol definition for resources, resource templates, subscriptions, contents, and annotations.
Cite this page
Suggested citation: Claude Context, "Context Engineering Templates," updated 2026-07-06, https://claudecontext-com.pages.dev/templates/.
This page is an independent educational resource and is not affiliated with Anthropic.