Template Format
Templates are markdown files with YAML frontmatter that define reusable prompt sections for wu:brief. The template system enables customization of agent prompts without modifying core LumenFlow code.
Template Location
Section titled “Template Location”Templates live in .lumenflow/templates/spawn-prompt/:
Template Structure
Section titled “Template Structure”Every template has two parts: YAML frontmatter and markdown content.
Minimal Template
Section titled “Minimal Template”Complete Template
Section titled “Complete Template”Frontmatter Fields
Section titled “Frontmatter Fields”| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Unique identifier matching manifest entry |
name | string | Yes | Human-readable name for debugging |
required | boolean | Yes | If true, assembly fails when template is missing |
order | number | Yes | Assembly position (lower numbers appear first) |
tokens | string[] | No | Token names used in this template |
condition | string | No | Expression that must be true for template inclusion |
The id Field
Section titled “The id Field”The id must match an entry in manifest.yaml. It’s used to:
- Look up the template during assembly
- Apply client-specific overrides (matching by
id) - Reference templates in error messages
The order Field
Section titled “The order Field”Templates are sorted by order before assembly. Use these ranges:
| Range | Purpose | Examples |
|---|---|---|
| 10-50 | Type-specific directives | tdd-directive, docs-directive |
| 50-100 | Skills and methodology | skills-selection |
| 100-200 | Agent guidance | effort-scaling, parallel-calls |
| 200-300 | Operational guidance | bug-discovery, quick-fix |
| 300-400 | Recovery and worktree | worktree-recovery |
| 400-500 | Lane-specific guidance | lane-guidance-operations |
| 900+ | Constraints (always last) | constraints |
The required Field
Section titled “The required Field”When required: true:
- Template must exist for assembly to succeed
- Missing template throws an error with the expected path
- Use for critical sections like constraints
When required: false:
- Template is optional
- Missing template is silently skipped
- Use for type-specific or conditional content
The tokens Field
Section titled “The tokens Field”Lists token names that appear in the template content:
This field is informational (documents which tokens the template uses) but token replacement happens automatically for all known tokens regardless of this field.
The condition Field
Section titled “The condition Field”A JavaScript-like expression evaluated against the WU context. Template is included only when the condition evaluates to true.
See Condition Syntax for details.
Token Replacement
Section titled “Token Replacement”Tokens are placeholders in template content that get replaced with actual values during assembly.
Token Syntax
Section titled “Token Syntax”Use curly braces with uppercase names:
Available Tokens
Section titled “Available Tokens”| Token | Description | Example Value |
|---|---|---|
{WU_ID} | Work Unit identifier | WU-1253 |
{LANE} | Full lane name | Framework: Core |
{TYPE} | WU type | feature, bug, documentation |
{TITLE} | WU title | Add template loader |
{DESCRIPTION} | WU description | Implement the template system... |
{WORKTREE_PATH} | Path to worktree (if claimed) | worktrees/framework-core-wu-1253 |
Token Example
Section titled “Token Example”Template:
Output (after replacement):
Condition Syntax
Section titled “Condition Syntax”Conditions control whether a template is included in the assembled prompt.
Supported Operators
Section titled “Supported Operators”| Operator | Syntax | Description |
|---|---|---|
| Equality | field === 'value' | Exact match |
| Inequality | field !== 'value' | Not equal |
| Truthy | field | Field exists and truthy |
| AND | expr1 && expr2 | Both must be true |
| OR | expr1 || expr2 | Either can be true |
Context Variables
Section titled “Context Variables”Conditions use lowercase aliases of token values:
| Variable | Maps To | Example Values |
|---|---|---|
type | {TYPE} | feature, bug, documentation |
lane | {LANE} | Framework: Core |
wuId | {WU_ID} | WU-1253 |
title | {TITLE} | Add template loader |
description | {DESCRIPTION} | Full description text |
worktreePath | {WORKTREE_PATH} | Path or undefined |
laneParent | Extracted | Framework, Content, Operations |
policy.testing | Resolved policy | tdd, test-after, none |
policy.architecture | Resolved policy | hexagonal, layered, none |
Condition Examples
Section titled “Condition Examples”Type-based inclusion:
Lane-based inclusion:
Truthy checks:
Policy-based inclusion:
Combined conditions:
Assembly Process
Section titled “Assembly Process”When wu:brief runs, templates are assembled in this order:
- Load manifest from
.lumenflow/templates/manifest.yaml - Load templates from
spawn-prompt/directory - Apply client overrides (e.g.,
templates.claude/spawn-prompt/) - Sort by order field (ascending)
- Evaluate conditions for each template against the WU context
- Replace tokens in included templates
- Concatenate with double newlines between sections
Override Resolution
Section titled “Override Resolution”Client-specific templates take priority:
When running wu:brief --id WU-XXX --client <client>:
- Load base
skills-selection.md - Override with
templates.claude/spawn-prompt/skills-selection.md - Cursor template is ignored
Error Handling
Section titled “Error Handling”Missing Required Template
Section titled “Missing Required Template”Fix: Create the template at the expected path or mark it required: false in the manifest.
Invalid Frontmatter
Section titled “Invalid Frontmatter”Fix: Add the missing frontmatter field.
Manifest Validation
Section titled “Manifest Validation”Fix: Add the missing field to the manifest entry.
Best Practices
Section titled “Best Practices”Template Design
Section titled “Template Design”- One concern per template - Keep templates focused
- Use conditions - Avoid including irrelevant content
- Document tokens - List tokens in frontmatter even though optional
- Leave order gaps - Use increments of 10 for flexibility
Naming Conventions
Section titled “Naming Conventions”- File names: Lowercase with hyphens (
tdd-directive.md) - Template IDs: Match file name without extension (
tdd-directive) - Subdirectories: Use for related groups (
lane-guidance/)
Ordering Guidelines
Section titled “Ordering Guidelines”Next Steps
Section titled “Next Steps”- Manifest Schema - Configure template assembly
- Customizing Spawn Prompts - Create custom templates
- CLI Reference -
wu:briefandwu:delegatecommand options