Protocol Injection Flow
Version: 1.0.0 | Status: ACTIVE This document describes how protocols are loaded, combined, and injected into subagent prompts.Overview
Step 1: Skill Selection
The dispatch algorithm selects the appropriate skill:Step 2: Template Loading
Load the skill’s SKILL.md template:- Skill purpose and capabilities
- Methodology instructions
- Token placeholders (e.g.,
{{TASK_ID}})
Step 3: Base Protocol Loading
Always loaded for every subagent:| Rule | Requirement |
|---|---|
| OUT-001 | MUST write output to claudedocs/agent-outputs/ |
| OUT-002 | MUST append ONE line to MANIFEST.jsonl |
| OUT-003 | MUST return summary message only |
| OUT-004 | MUST NOT return content in response |
Step 4: Conditional Protocol Loading
Loaded based on task context:| Protocol | Trigger Condition |
|---|---|
| Task Lifecycle | Always (task system integration) |
| Research Linking | Task has research dependencies |
| Verification Gates | Task requires verification |
| Phase Awareness | Project has phase tracking |
| Dependency Context | Task has dependencies |
| Error Handling | Always (fallback behavior) |
| Session Integration | Session is active |
Step 5: Token Resolution
Replace all{{TOKEN}} placeholders with values:
| Category | Tokens | Source |
|---|---|---|
| Task | {{TASK_ID}}, {{TASK_TITLE}}, {{TASK_DESCRIPTION}} | Task data |
| Context | {{EPIC_ID}}, {{SESSION_ID}}, {{DATE}} | Session/environment |
| Output | {{OUTPUT_FILE}}, {{TOPIC_SLUG}} | Generated |
| Manifest | {{MANIFEST_SUMMARIES}}, {{PRIOR_RESEARCH}} | MANIFEST.jsonl |
Step 6: Prompt Assembly
Combine all components:Output Structure
The assembled prompt is returned as JSON:Error Handling
| Error | Cause | Resolution |
|---|---|---|
| Empty prompt | Token injection failed | Check required tokens set |
| Missing template | Skill not found | Verify skill exists in manifest |
| Validation error | Invalid token patterns | Check token format |
