Back to Skills

xml-context-engineering

verified

USE WHEN: writing system prompts, structuring complex instructions, engineering context for Claude agents, optimizing attention efficiency in long prompts. DO NOT USE WHEN: writing regular code, simple messages, or content where Markdown suffices. For optimal context architecture, trigger deep thinking with "think harder" or "ultrathink" to analyze attention economics thoroughly.

View on GitHub

Marketplace

claude-hacks

mahidalhan/claude-hacks

Plugin

xml-context-engineering

Repository

mahidalhan/claude-hacks
20stars

skills/xml-context-engineering/skills/xml-context-engineering/SKILL.md

Last Verified

January 22, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/mahidalhan/claude-hacks/blob/main/skills/xml-context-engineering/skills/xml-context-engineering/SKILL.md -a claude-code --skill xml-context-engineering

Installation paths:

Claude
.claude/skills/xml-context-engineering/
Powered by add-skill CLI

Instructions

Transform unstructured prompt content into XML-tagged context that maximizes LLM comprehension. The user provides raw instructions, data, or prompt content needing structure.

## Context Thinking

Before tagging anything, analyze the attention economics:
- **Boundaries**: Where does one semantic unit end and another begin? Tags mark cognitive boundaries, not arbitrary divisions.
- **Hierarchy**: Does nesting reflect logical containment, or are you creating false depth? Flatten unless parent-child relationship is real.
- **Retrieval**: Will the model need to reference this section? Name tags for retrieval (`<error_handling>`) not description (`<the_part_about_errors>`).
- **Density**: Is this content high-signal enough to warrant its own tag? Low-value content dilutes attention—exclude rather than tag.

**CRITICAL**: XML tags are attention anchors, not decorations. If a tag doesn't help the model locate, isolate, or reference content, it's noise. Every tag must earn its tokens. Tag soup—nested structures that add complexity without clarity—is worse than no tagging at all.

## Context Engineering Guidelines

Focus on:
- **Semantic naming**: Use domain-native tag names (`<constraints>`, `<examples>`, `<tool_guidance>`) that create instant comprehension. Avoid generic names like `<section1>` or `<info>`.
- **Flat-first structure**: Default to siblings, not children. Use `<instructions>` and `<context>` as siblings, not `<prompt><instructions><context>`. Nest only when content genuinely belongs inside another.
- **Canonical sections**: Standard patterns include `<system_context>`, `<user_background>`, `<instructions>`, `<constraints>`, `<examples>`, `<output_format>`. Deviate only with clear purpose.
- **Attribute discipline**: Use attributes for metadata that aids filtering (`<example type="edge_case">`), not for content that should be text. Attributes are invisible to casual scanning.
- **Progressive disclosure**: Place high-frequency reference content early. Put `<ins

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
3426 chars