home / skills / madappgang / claude-code / xml-standards

This skill enforces XML tag standards for Claude Code agents, ensuring proper hierarchy, semantics, and reusable templates across role, instructions, and

npx playbooks add skill madappgang/claude-code --skill xml-standards

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
5.4 KB
---
name: xml-standards
description: XML tag structure patterns for Claude Code agents and commands. Use when designing or implementing agents to ensure proper XML structure following Anthropic best practices.
---
plugin: agentdev
updated: 2026-01-20

# XML Tag Standards

## Core Tags (Required for ALL Agents/Commands)

### `<role>`
Defines agent identity and purpose.

```xml
<role>
  <identity>Expert [Domain] Specialist</identity>
  <expertise>
    - Core skill 1
    - Core skill 2
    - Core skill 3
  </expertise>
  <mission>
    Clear statement of what this agent accomplishes
  </mission>
</role>
```

### `<instructions>`
Defines behavior constraints and workflow.

```xml
<instructions>
  <critical_constraints>
    <constraint_name>
      Description of critical rule that must be followed
    </constraint_name>
    <todowrite_requirement>
      You MUST use TodoWrite to track workflow progress.
    </todowrite_requirement>
  </critical_constraints>

  <core_principles>
    <principle name="Name" priority="critical|high|medium">
      Description of principle
    </principle>
  </core_principles>

  <workflow>
    <phase number="1" name="Phase Name">
      <step>Step description</step>
      <step>Step description</step>
    </phase>
  </workflow>
</instructions>
```

### `<knowledge>`
Domain-specific best practices and templates.

```xml
<knowledge>
  <section_name>
    Best practices, patterns, or reference material
  </section_name>
  <templates>
    <template name="Template Name">
      Template content
    </template>
  </templates>
</knowledge>
```

### `<examples>`
Concrete usage scenarios (2-4 required).

```xml
<examples>
  <example name="Descriptive Name">
    <user_request>What user asks for</user_request>
    <correct_approach>
      1. Step one
      2. Step two
      3. Step three
    </correct_approach>
  </example>
</examples>
```

### `<formatting>`
Communication style and output format.

```xml
<formatting>
  <communication_style>
    - Style guideline 1
    - Style guideline 2
  </communication_style>
  <completion_message_template>
    Template for completion messages
  </completion_message_template>
</formatting>
```

---

## Specialized Tags by Agent Type

### Orchestrators (Commands)

```xml
<orchestration>
  <allowed_tools>Task, Bash, Read, TodoWrite, AskUserQuestion</allowed_tools>
  <forbidden_tools>Write, Edit</forbidden_tools>

  <delegation_rules>
    <rule scope="design">ALL design → architect agent</rule>
    <rule scope="implementation">ALL implementation → developer agent</rule>
    <rule scope="review">ALL reviews → reviewer agent</rule>
  </delegation_rules>

  <phases>
    <phase number="1" name="Phase Name">
      <objective>What this phase achieves</objective>
      <steps>
        <step>Step description</step>
      </steps>
      <quality_gate>Exit criteria for this phase</quality_gate>
    </phase>
  </phases>
</orchestration>

<error_recovery>
  <strategy>
    Recovery steps for common failures
  </strategy>
</error_recovery>
```

### Planners (Architects)

```xml
<planning_methodology>
  <approach>How planning is performed</approach>
  <deliverables>What planning produces</deliverables>
</planning_methodology>

<gap_analysis>
  <checklist>Items to verify during planning</checklist>
</gap_analysis>

<output_structure>
  <format>Structure of planning output</format>
</output_structure>
```

### Implementers (Developers)

```xml
<implementation_standards>
  <file_writing_standards>
    <standard name="Standard Name">Description</standard>
  </file_writing_standards>

  <quality_checks mandatory="true">
    <check name="check_name" order="1">
      <tool>Tool name</tool>
      <command>Command to run</command>
      <requirement>What must pass</requirement>
      <on_failure>Recovery action</on_failure>
    </check>
  </quality_checks>

  <validation_checks>
    <check order="1" name="Check Name">
      Validation criteria
    </check>
  </validation_checks>
</implementation_standards>
```

### Reviewers

```xml
<review_criteria>
  <focus_areas>
    <area name="Area Name" priority="critical|high|medium" weight="20%">
      **Check:**
      - Item to verify
      - Item to verify

      **Common Issues:**
      - Issue description

      **Critical if**: Condition for critical severity
      **High if**: Condition for high severity
    </area>
  </focus_areas>

  <feedback_format>
    Template for review feedback
  </feedback_format>
</review_criteria>

<approval_criteria>
  <status name="PASS">Criteria for passing</status>
  <status name="CONDITIONAL">Criteria for conditional approval</status>
  <status name="FAIL">Criteria for failure</status>
</approval_criteria>
```

### Testers

```xml
<testing_strategy>
  <approach>Testing methodology</approach>
  <test_types>
    <type name="Type Name">Description</type>
  </test_types>
</testing_strategy>

<coverage_requirements>
  <requirement>Coverage criteria</requirement>
</coverage_requirements>
```

---

## Nesting Rules

1. **Proper Hierarchy** - Tags must be properly nested
2. **Closing Tags** - All opening tags must have closing tags
3. **Semantic Attributes** - Use `name`, `priority`, `order` attributes
4. **Consistent Naming** - Use lowercase-with-hyphens for tag names

## Code Blocks in XML

```xml
<template name="Example">
```language
// code here - note: opening ``` directly under tag
```
</template>
```

## Character Escaping

Only in XML attribute values and text nodes (NOT in code blocks):
- `&lt;` for `<`
- `&gt;` for `>`
- `&amp;` for `&`

Overview

This skill provides XML tag structure patterns and conventions for designing Claude Code agents and commands. It codifies required core tags, specialized tag sets per agent role, nesting rules, code-block handling, and character-escaping guidance. Use it to ensure agent XML is well-formed, semantically consistent, and aligned with Anthropic best practices.

How this skill works

The skill inspects agent XML for required core sections (<role>, <instructions>, <knowledge>, <examples>, <formatting>) and validates specialized tag groups for orchestrators, planners, implementers, reviewers, and testers. It checks tag nesting, presence of closing tags, attribute usage (name, priority, order), allowed/forbidden tools in orchestration, and recommended patterns for code blocks and escaping. It reports missing sections, attribute inconsistencies, and common semantic errors, and suggests corrective edits.

When to use it

  • When authoring or reviewing XML manifests for Claude Code agents or commands.
  • During CI checks to enforce agent structure and required sections.
  • When creating orchestration workflows that must follow delegation and tool rules.
  • When defining implementation standards, validation checks, or review criteria.
  • When onboarding new agent authors to a consistent XML schema and examples.

Best practices

  • Always include the core tags: role, instructions, knowledge, examples, formatting.
  • Use lowercase-with-hyphens for custom tag names and semantic attributes (name, priority, order).
  • Keep workflows and phases explicit with numbered phases and clear quality gates.
  • Place code blocks inside template tags without escaping; only escape in attributes or text nodes.
  • Declare allowed and forbidden tools for orchestration agents to enforce delegation rules.
  • Provide 2–4 concrete examples per agent to demonstrate correct approaches.

Example use cases

  • Validating an orchestrator command XML to ensure allowed_tools and delegation_rules are present.
  • Checking an implementer agent manifest for required quality_checks and validation_checks structure.
  • Reviewing a planner agent to confirm gap_analysis checklist and output_structure are defined.
  • Enforcing nesting and closing-tag rules in CI for all agent XML files.
  • Converting informal agent notes into a compliant XML template with role, instructions, and examples.

FAQ

Are code blocks escaped inside templates?

No. Code blocks inside template tags should remain raw; escaping rules apply only to attribute values and plain text nodes.

Which tags are mandatory for every agent?

Every agent must include the core tags: <role>, <instructions>, <knowledge>, <examples>, and <formatting>.