Skip to content

Commit a1b3a52

Browse files
Brian MadisonBrian Madison
authored andcommitted
refactor: optimize data files for LLM runtime consumption
Dense format optimization across all agent data files. - Removed redundancy, fluff, and exposition - Converted prose to tables, lists, code blocks - Structured for quick scanning and validation - Preserved ALL technical rules and checkpoints - Updated for simplified agent model (hasSidecar boolean) Results: 763 lines removed while preserving functionality. Files optimized: agent-architecture, agent-compilation, agent-menu-patterns, agent-metadata, agent-validation, brainstorm-context, critical-actions, persona-properties, principles-crafting, understanding-agent-types
1 parent fd02020 commit a1b3a52

10 files changed

Lines changed: 643 additions & 1406 deletions

src/workflows/agent/data/agent-architecture.md

Lines changed: 135 additions & 228 deletions
Large diffs are not rendered by default.
Lines changed: 72 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
1-
# Agent Compilation: YAML Source → Final Agent
1+
# Agent Compilation: YAML → Compiled
22

3-
> **For the LLM running this workflow:** This document explains what the compiler adds. When building agents, focus on the YAML structure defined here—do NOT add things the compiler handles automatically.
4-
>
5-
> **Example reference:** Compare `{workflow_path}/data/reference/module-examples/architect.agent.yaml` (source, 32 lines) with `architect.md` (compiled, 69 lines) to see what the compiler adds.
3+
**TL;DR:** Write minimal YAML → compiler adds frontmatter, activation XML, handlers, rules, MH/CH/PM/DA menu items.
64

75
---
86

9-
## Quick Overview
10-
11-
You write: **YAML source file** (`agent-name.agent.yaml`)
12-
Compiler produces: **Markdown with XML** (`agent-name.md`) for LLM consumption
13-
14-
The compiler transforms your clean YAML into a fully functional agent by adding:
15-
- Frontmatter (name, description)
16-
- XML activation block with numbered steps
17-
- Menu handlers (workflow, exec, action)
18-
- Auto-injected menu items (MH, CH, PM, DA)
19-
- Rules section
20-
21-
---
22-
23-
## What YOU Provide (YAML Source)
24-
25-
Your YAML contains ONLY these sections:
7+
## YAML Structure (YOU WRITE)
268

279
```yaml
2810
agent:
@@ -31,7 +13,7 @@ agent:
3113
name: "Persona Name"
3214
title: "Agent Title"
3315
icon: "🔧"
34-
module: "stand-alone" or "bmm" or "cis" or "bmgd"
16+
module: "stand-alone" | "bmm" | "cis" | "bmgd"
3517

3618
persona:
3719
role: "First-person role description"
@@ -40,17 +22,17 @@ agent:
4022
principles:
4123
- "Core belief or methodology"
4224

43-
critical_actions: # Optional - for any agent with activation behavior
25+
critical_actions: # Optional - ANY agent can have these
4426
- "Load COMPLETE file {project-root}/_bmad/_memory/journal-sidecar/memories.md"
4527
- "Load COMPLETE file {project-root}/_bmad/_memory/journal-sidecar/instructions.md"
4628
- "ONLY read/write files in {project-root}/_bmad/_memory/journal-sidecar/"
4729

48-
prompts: # Optional - for Simple/Expert agents
30+
prompts: # Optional - standalone agents
4931
- id: prompt-name
5032
content: |
5133
<instructions>Prompt content</instructions>
5234
53-
menu: # Your custom items only
35+
menu: # Custom items ONLY
5436
- trigger: XX or fuzzy match on command-name
5537
workflow: "path/to/workflow.yaml" # OR
5638
exec: "path/to/file.md" # OR
@@ -60,36 +42,18 @@ agent:
6042
6143
---
6244
63-
## What COMPILER Adds (DO NOT Include)
45+
## What Compiler Adds (DO NOT WRITE)
6446
65-
### 1. Frontmatter
66-
```markdown
67-
---
68-
name: "architect"
69-
description: "Architect"
70-
---
71-
```
72-
**DO NOT add** frontmatter to your YAML.
47+
| Component | Source |
48+
|-----------|--------|
49+
| Frontmatter (`---name/description---`) | Auto-generated |
50+
| XML activation block with numbered steps | Auto-generated |
51+
| critical_actions → activation steps | Injected as steps 4, 5, 6... |
52+
| Menu handlers (workflow/exec/action) | Auto-detected |
53+
| Rules section | Auto-generated |
54+
| MH, CH, PM, DA menu items | Always injected |
7355

74-
### 2. XML Activation Block
75-
```xml
76-
<activation critical="MANDATORY">
77-
<step n="1">Load persona from this current agent file</step>
78-
<step n="2">Load config to get {user_name}, {communication_language}</step>
79-
<step n="3">Remember: user's name is {user_name}</step>
80-
<!-- YOUR critical_actions inserted here as steps 4, 5, etc. -->
81-
<step n="N">ALWAYS communicate in {communication_language}</step>
82-
<step n="N+1">Show greeting + numbered menu</step>
83-
<step n="N+2">STOP and WAIT for user input</step>
84-
<step n="N+3">Input resolution rules</step>
85-
<menu-handlers>...</menu-handlers>
86-
<rules>...</rules>
87-
</activation>
88-
```
89-
**DO NOT create** activation sections—the compiler builds them.
90-
91-
### 3. Auto-Injected Menu Items
92-
Every agent gets these 4 items automatically. **DO NOT add them to your YAML:**
56+
### Auto-Injected Menu Items (NEVER add)
9357

9458
| Code | Trigger | Description |
9559
|------|---------|-------------|
@@ -98,55 +62,10 @@ Every agent gets these 4 items automatically. **DO NOT add them to your YAML:**
9862
| PM | party-mode | Start Party Mode |
9963
| DA | exit, leave, goodbye, dismiss agent | Dismiss Agent |
10064

101-
### 4. Menu Handlers
102-
```xml
103-
<handler type="workflow">
104-
When menu item has: workflow="path/to/workflow.yaml"
105-
→ Load workflow.xml and execute with workflow-config parameter
106-
</handler>
107-
<handler type="exec">
108-
When menu item has: exec="path/to/file.md"
109-
→ Load and execute the file at that path
110-
</handler>
111-
```
112-
**DO NOT add** handlers—the compiler detects and generates them.
113-
11465
---
11566

116-
## Before/After Example: Architect Agent
67+
## Compiled Output Structure
11768

118-
### Source: `architect.agent.yaml` (32 lines - YOU WRITE)
119-
```yaml
120-
agent:
121-
metadata:
122-
id: "_bmad/bmm/agents/architect.md"
123-
name: Winston
124-
title: Architect
125-
icon: 🏗️
126-
module: bmm
127-
128-
persona:
129-
role: System Architect + Technical Design Leader
130-
identity: Senior architect with expertise in distributed systems...
131-
communication_style: "Speaks in calm, pragmatic tones..."
132-
principles: |
133-
- User journeys drive technical decisions...
134-
135-
menu:
136-
- trigger: WS or fuzzy match on workflow-status
137-
workflow: "{project-root}/_bmad/bmm/workflows/workflow-status/workflow.yaml"
138-
description: "[WS] Get workflow status..."
139-
140-
- trigger: CA or fuzzy match on create-architecture
141-
exec: "{project-root}/_bmad/bmm/workflows/3-solutioning/create-architecture/workflow.md"
142-
description: "[CA] Create an Architecture Document"
143-
144-
- trigger: IR or fuzzy match on implementation-readiness
145-
exec: "{project-root}/_bmad/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md"
146-
description: "[IR] Implementation Readiness Review"
147-
```
148-
149-
### Compiled: `architect.md` (69 lines - COMPILER PRODUCES)
15069
```markdown
15170
---
15271
name: "architect"
@@ -159,25 +78,26 @@ You must fully embody this agent's persona...
15978
<agent id="architect.agent.yaml" name="Winston" title="Architect" icon="🏗️">
16079
<activation critical="MANDATORY">
16180
<step n="1">Load persona from this current agent file (already in context)</step>
162-
<step n="2">🚨 IMMEDIATE ACTION REQUIRED - BEFORE ANY OUTPUT...</step>
81+
<step n="2">Load config to get {user_name}, {communication_language}</step>
16382
<step n="3">Remember: user's name is {user_name}</step>
164-
<step n="4">Show greeting using {user_name} from config...</step>
165-
<step n="5">STOP and WAIT for user input...</step>
166-
<step n="6">On user input: Number → execute menu item[n]...</step>
167-
<step n="7">When executing a menu item: Check menu-handlers section...</step>
83+
<!-- YOUR critical_actions inserted here as steps 4, 5, 6... -->
84+
<step n="N">ALWAYS communicate in {communication_language}</step>
85+
<step n="N+1">Show greeting + numbered menu</step>
86+
<step n="N+2">STOP and WAIT for user input</step>
16887

16988
<menu-handlers>
17089
<handlers>
171-
<handler type="workflow">...</handler>
172-
<handler type="exec">...</handler>
90+
<handler type="workflow">Load workflow.xml and execute with workflow-config parameter</handler>
91+
<handler type="exec">Load and execute the file at that path</handler>
92+
<handler type="action">Execute prompt with matching id from prompts section</handler>
17393
</handlers>
17494
</menu-handlers>
17595

17696
<rules>
17797
<r>ALWAYS communicate in {communication_language}</r>
17898
<r>Stay in character until exit selected</r>
179-
<r>Display Menu items as the item dictates...</r>
180-
<r>Load files ONLY when executing menu items...</r>
99+
<r>Display Menu items as the item dictates</r>
100+
<r>Load files ONLY when executing menu items</r>
181101
</rules>
182102
</activation>
183103

@@ -188,104 +108,78 @@ You must fully embody this agent's persona...
188108
<principles>- User journeys drive technical decisions...</principles>
189109
</persona>
190110

111+
<prompts>
112+
<prompt id="prompt-name">
113+
<instructions>Prompt content</instructions>
114+
</prompt>
115+
</prompts>
116+
191117
<menu>
192118
<item cmd="MH or fuzzy match on menu or help">[MH] Redisplay Menu Help</item>
193119
<item cmd="CH or fuzzy match on chat">[CH] Chat with the Agent about anything</item>
194-
<item cmd="WS...">[WS] Get workflow status...</item> ← YOUR CUSTOM ITEMS
195-
<item cmd="CA...">[CA] Create an Architecture Document</item>
196-
<item cmd="IR...">[IR] Implementation Readiness Review</item>
197-
<item cmd="PM...">[PM] Start Party Mode</item>
198-
<item cmd="DA...">[DA] Dismiss Agent</item>
120+
<!-- YOUR CUSTOM ITEMS HERE -->
121+
<item cmd="PM or fuzzy match on party-mode">[PM] Start Party Mode</item>
122+
<item cmd="DA or fuzzy match on exit leave goodbye dismiss agent">[DA] Dismiss Agent</item>
199123
</menu>
200124
</agent>
201125
```
202-
**Key additions by compiler:** Frontmatter, activation block, handlers, rules, MH/CH/PM/DA menu items.
203-
204-
---
205-
206-
## DO NOT DO Checklist
207-
208-
When building agent YAML, **DO NOT:**
209-
210-
- [ ] Add frontmatter (`---name/description---`) to YAML
211-
- [ ] Create activation blocks or XML sections
212-
- [ ] Add MH (menu/help) menu item
213-
- [ ] Add CH (chat) menu item
214-
- [ ] Add PM (party-mode) menu item
215-
- [ ] Add DA (dismiss/exit) menu item
216-
- [ ] Add menu handlers (workflow/exec logic)
217-
- [ ] Add rules section
218-
- [ ] Duplicate any auto-injected content
219-
220-
**DO:**
221-
- [ ] Define metadata (id, name, title, icon, module)
222-
- [ ] Define persona (role, identity, communication_style, principles)
223-
- [ ] Define critical_actions (if agent has activation behavior)
224-
- [ ] Define prompts with IDs (Simple/Expert agents only)
225-
- [ ] Define menu with your custom items only
226-
- [ ] Use proper trigger format: `XX or fuzzy match on command-name`
227-
- [ ] Use proper description format: `[XX] Description text`
228126

229127
---
230128

231-
## Agent critical_actions
129+
## critical_actions Injection
232130

233-
For any agent with activation behavior, your `critical_actions` become activation steps.
234-
235-
### Agents with sidecar (hasSidecar: true):
131+
Your `critical_actions` become numbered activation steps.
236132

133+
### With sidecar (hasSidecar: true):
237134
```yaml
238135
critical_actions:
239136
- "Load COMPLETE file {project-root}/_bmad/_memory/journal-sidecar/memories.md"
240137
- "Load COMPLETE file {project-root}/_bmad/_memory/journal-sidecar/instructions.md"
241138
- "ONLY read/write files in {project-root}/_bmad/_memory/journal-sidecar/"
242139
```
140+
→ Injected as steps 4, 5, 6
243141
244-
The compiler injects these as steps 4, 5, 6 in the activation block:
245-
246-
```xml
247-
<step n="4">Load COMPLETE file {project-root}/_bmad/_memory/journal-sidecar/memories.md</step>
248-
<step n="5">Load COMPLETE file {project-root}/_bmad/_memory/journal-sidecar/instructions.md</step>
249-
<step n="6">ONLY read/write files in {project-root}/_bmad/_memory/journal-sidecar/</step>
250-
<step n="7">ALWAYS communicate in {communication_language}</step>
251-
```
252-
253-
### Agents without sidecar (hasSidecar: false):
254-
142+
### Without sidecar (hasSidecar: false):
255143
```yaml
256144
critical_actions:
257145
- "Give user an inspirational quote before showing menu"
258-
- "Review {project-root}/finances/ for most recent data file"
259146
```
147+
→ Injected as step 4
260148
261-
The compiler injects these as steps 4, 5 in the activation block:
262-
263-
```xml
264-
<step n="4">Give user an inspirational quote before showing menu</step>
265-
<step n="5">Review {project-root}/finances/ for most recent data file</step>
266-
<step n="6">ALWAYS communicate in {communication_language}</step>
267-
```
149+
### No critical_actions:
150+
Activation jumps directly from step 3 to "ALWAYS communicate in {communication_language}"
268151
269152
---
270153
271-
## Division of Responsibilities
154+
## DO NOT / DO Checklist
272155
273-
| Aspect | YOU Provide (YAML) | COMPILER Adds |
274-
|--------|-------------------|---------------|
275-
| Agent identity | metadata + persona | Wrapped in XML |
276-
| Memory/actions | critical_actions | Inserted as activation steps |
277-
| Prompts | prompts with IDs | Referenced by menu actions |
278-
| Menu items | Your custom commands only | + MH, CH, PM, DA (auto) |
279-
| Activation || Full XML block with handlers |
280-
| Rules || Standardized rules section |
281-
| Frontmatter || name/description header |
156+
**DO NOT:**
157+
- [ ] Add frontmatter
158+
- [ ] Create activation/XML blocks
159+
- [ ] Add MH/CH/PM/DA menu items
160+
- [ ] Add menu handlers
161+
- [ ] Add rules section
162+
- [ ] Duplicate auto-injected content
163+
164+
**DO:**
165+
- [ ] Define metadata (id, name, title, icon, module)
166+
- [ ] Define persona (role, identity, communication_style, principles)
167+
- [ ] Define critical_actions (if activation behavior needed)
168+
- [ ] Define prompts with IDs (standalone agents)
169+
- [ ] Define menu with custom items only
170+
- [ ] Use format: `XX or fuzzy match on command-name`
171+
- [ ] Use description format: `[XX] Description text`
282172

283173
---
284174

285-
## Quick Reference for LLM
175+
## Division of Responsibilities
286176

287-
- **Focus on:** Clean YAML structure, persona definition, custom menu items
288-
- **Ignore:** What happens after compilation—that's the compiler's job
289-
- **Remember:** Every agent gets MH, CH, PM, DA automatically—don't add them
290-
- **critical_actions:** Use for activation behavior (loading files, greetings, data fetches)
291-
- **Module agents:** Use `workflow:` or `exec:` references, not inline actions
177+
| Aspect | YOU (YAML) | COMPILER |
178+
|--------|------------|----------|
179+
| Agent identity | metadata + persona | Wrapped in XML |
180+
| Activation steps | critical_actions | Inserted as steps 4+ |
181+
| Prompts | prompts with IDs | Referenced by actions |
182+
| Menu items | Custom only | + MH, CH, PM, DA |
183+
| Activation block | — | Full XML with handlers |
184+
| Rules | — | Standardized section |
185+
| Frontmatter | — | name/description |

0 commit comments

Comments
 (0)