Writing Subagent Prompts
<key_insight>
Subagent prompts should be task-specific, not generic. They define a specialized role with clear focus areas, workflows, and constraints.
**Critical**: Subagent.md files use pure XML structure (no markdown headings). Like skills and slash commands, this improves parsing and token efficiency.
</key_insight>
<xml_structure_rule>
**Remove ALL markdown headings (##, ###) from subagent body.** Use semantic XML tags instead.
Keep markdown formatting WITHIN content (bold, italic, lists, code blocks, links).
See @skills/create-agent-skills/references/use-xml-tags.md for XML structure principles - they apply to subagents too.
</xml_structure_rule>
<core_principles>
<principle name="specificity">
Define exactly what the subagent does and how it approaches tasks.
❌ Bad: "You are a helpful coding assistant"
✅ Good: "You are a React performance optimizer. Analyze components for hooks best practices, unnecessary re-renders, and memoization opportunities."
</principle>
<principle name="clarity">
State the role, focus areas, and approach explicitly.
❌ Bad: "Help with tests"
✅ Good: "You are a test automation specialist. Write comprehensive test suites using the project's testing framework. Focus on edge cases and error conditions."
</principle>
<principle name="constraints">
Include what the subagent should NOT do. Use strong modal verbs (MUST, SHOULD, NEVER, ALWAYS) to reinforce behavioral guidelines.
Example:when to use it
Community prompt sourced from the open-source GitHub repo Elad73/agentic-base-layer (MIT). A "Writing Subagent Prompts" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.
tags
productivitycommunitydeveloper
source
Elad73/agentic-base-layer · MIT
more in Productivity
Productivity✓ tested
Summarize a doc into decisions & actions
chief of staff who extracts what to DO, not just what was said
Productivity✓ tested
Draft a reply to a hard email
calm, direct communicator who de-escalates without caving
Productivity✓ tested
Turn a brain-dump into a weekly plan
planning coach who protects your focus, not just your calendar