|
| 1 | +--- |
| 2 | +cypilot: true |
| 3 | +type: requirement |
| 4 | +name: Compilation Brief Template |
| 5 | +version: 2.0 |
| 6 | +purpose: Template for per-phase compilation briefs — filled by LLM during plan Phase 3.2 |
| 7 | +--- |
| 8 | + |
| 9 | +# Compilation Brief Template |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | +Compilation briefs are short instruction documents (~50–100 lines) generated during plan Phase 3.2. Each brief tells the executing agent what files to read, how to use them, and how to compile the corresponding phase file. |
| 14 | + |
| 15 | +The plan workflow agent fills this template once per phase using data from `plan.toml` and task context. No script is needed — the LLM generates briefs directly. |
| 16 | + |
| 17 | +**Task-agnostic**: This template works for any plan type — kit-based artifact generation, code refactoring, migration, infrastructure, documentation, or any other task that was decomposed into phases. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Template |
| 22 | + |
| 23 | +````markdown |
| 24 | +# Compilation Brief: Phase {number}/{total} — {title} |
| 25 | + |
| 26 | +--- CONTEXT BOUNDARY --- |
| 27 | +Disregard all previous context. This brief is self-contained. |
| 28 | +Read ONLY the files listed below. Follow the instructions exactly. |
| 29 | +--- |
| 30 | + |
| 31 | +## Phase Metadata |
| 32 | + |
| 33 | +```toml |
| 34 | +[phase] |
| 35 | +number = {number} |
| 36 | +total = {total} |
| 37 | +type = "{type}" |
| 38 | +title = "{title}" |
| 39 | +depends_on = {depends_on} |
| 40 | +input_files = {input_files} |
| 41 | +output_files = {output_files} |
| 42 | +outputs = {outputs} |
| 43 | +inputs = {inputs} |
| 44 | +``` |
| 45 | + |
| 46 | +## Load Instructions |
| 47 | + |
| 48 | +This section tells the executing agent **what to read and how to use it**. Each item specifies a file (or set of files) with: |
| 49 | +- **Path** and approximate size (`~N lines`) |
| 50 | +- **Action**: how to use the content — inline into a phase file section, or read at runtime |
| 51 | +- **Scope**: what parts to keep/skip (if only a subset is needed) |
| 52 | + |
| 53 | +List all sources the agent needs. Omit anything not relevant to this phase. |
| 54 | + |
| 55 | +{numbered list of load items — see examples below} |
| 56 | + |
| 57 | +**Do NOT load**: {list files that exist but are irrelevant to this phase} |
| 58 | + |
| 59 | +## Compile Phase File |
| 60 | + |
| 61 | +Write to: `{plan_dir}/{phase_file}` |
| 62 | + |
| 63 | +Phase file structure (all sections required): |
| 64 | + |
| 65 | +1. **TOML frontmatter** — use Phase Metadata above (wrap in ```toml code fence) |
| 66 | +2. **Preamble** — write verbatim: "This is a self-contained phase file. All rules, constraints, and kit content are included below. Project files listed in the Task section must be read at runtime. Follow the instructions exactly, run any EXECUTE commands as written, and report results against the acceptance criteria at the end." |
| 67 | +3. **What** — describe deliverable + scope boundary (2-5 sentences) |
| 68 | +4. **Prior Context** — summarize prior phases (≤ 20 lines), include pre-resolved user decisions |
| 69 | +5. **User Decisions** — already-decided items + phase-bound questions with checkboxes |
| 70 | +6. **Rules** — constraints the agent MUST follow (from load items marked "inline → Rules") |
| 71 | +7. **Input** — reference content (from load items marked "inline → Input") |
| 72 | +8. **Task** — 3-10 concrete steps with verifiable outcomes. Deterministic-first: use EXECUTE for CLI commands/scripts, LLM reasoning only for creative steps. Add "Read <file>" steps for runtime-read items. |
| 73 | +9. **Acceptance Criteria** — 3-10 binary pass/fail checks |
| 74 | +10. **Output Format** — completion report + next-phase prompt (see plan-template.md Section 9) |
| 75 | + |
| 76 | +## Context Budget |
| 77 | + |
| 78 | +- Phase file target: ≤ 600 lines |
| 79 | +- Inlined content estimate: ~{N} lines |
| 80 | +- Total execution context (phase file + runtime reads): ≤ 2000 lines |
| 81 | +- If Rules section exceeds 300 lines, narrow phase scope — NEVER drop rules |
| 82 | + |
| 83 | +## After Compilation |
| 84 | + |
| 85 | +Report: "Phase {number} compiled → {phase_file} (N lines)" |
| 86 | +Then apply context boundary and proceed to next brief. |
| 87 | +```` |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## Load Instructions: How to Fill |
| 92 | + |
| 93 | +The Load Instructions section is the core of the brief. It is a numbered list of items — each item is a file (or file group) that the executing agent needs. The LLM decides what items to include based on the task type and phase scope. |
| 94 | + |
| 95 | +### Item anatomy |
| 96 | + |
| 97 | +Each item follows this pattern: |
| 98 | + |
| 99 | +``` |
| 100 | +N. **Label**: Read `{path}` (lines {from}-{to}, ~{N} lines) |
| 101 | + - {action}: what to do with the content |
| 102 | + - {scope}: what to keep/skip (optional, if only parts are needed) |
| 103 | +``` |
| 104 | + |
| 105 | +**Line ranges** help the executing agent read only the relevant portion of a file. Specify `lines {from}-{to}` when: |
| 106 | +- Only a section of a large file is needed (e.g., H2 sections 3-5 of a 800-line doc) |
| 107 | +- A specific function, class, or config block is the target |
| 108 | +- The file is too large to read in full within the context budget |
| 109 | + |
| 110 | +Omit line ranges when the entire file should be read. Use `~` for approximate ranges when exact lines aren't known at brief time (the executing agent will locate the exact boundaries). |
| 111 | + |
| 112 | +### Actions |
| 113 | + |
| 114 | +There are two actions. Choose one per item: |
| 115 | + |
| 116 | +| Action | Meaning | Goes into phase section | |
| 117 | +|--------|---------|------------------------| |
| 118 | +| **Inline** | Copy content into the phase file at compile time | Rules, Input, or both | |
| 119 | +| **Runtime read** | Agent reads the file during execution, NOT compiled in | Task (as "Read <file>" step) | |
| 120 | + |
| 121 | +**When to inline**: Content that is stable and defines constraints or structure — rules, templates, checklists, examples, style guides, coding standards, API specs. |
| 122 | + |
| 123 | +**When to runtime-read**: Content that may change between phases or is too large to inline — project files, source code, prior phase outputs, database schemas, config files, external docs. |
| 124 | + |
| 125 | +### Examples by task type |
| 126 | + |
| 127 | +**Kit-based artifact generation** (e.g., generate ADR, PRD): |
| 128 | + |
| 129 | +``` |
| 130 | +1. **Rules**: Read `{kit}/artifacts/ADR/rules.md` (lines 30-450, ~420 lines) |
| 131 | + - Inline → Rules section |
| 132 | + - Keep: MUST/MUST NOT requirements, structural/semantic rules, constraints |
| 133 | + - Skip: lines 1-29 (Prerequisites, Load Dependencies), lines 451+ (Tasks, Next Steps) |
| 134 | +
|
| 135 | +2. **Template**: Read `{kit}/artifacts/ADR/template.md` (lines 10-48, ~38 lines) |
| 136 | + - Inline → Input section (H2 sections 1-4 only) |
| 137 | +
|
| 138 | +3. **Example**: Read `{kit}/artifacts/ADR/examples/example.md` (~91 lines) |
| 139 | + - Inline → Input section as "Reference Example" (full file) |
| 140 | +
|
| 141 | +4. **Project context**: `whatsnew.toml` (lines ~140-172), `workflows/plan.md` (lines 1-80) |
| 142 | + - Runtime read — add "Read <file>" steps to Task |
| 143 | +``` |
| 144 | + |
| 145 | +**Code refactoring** (e.g., extract module, rename API): |
| 146 | + |
| 147 | +``` |
| 148 | +1. **Coding standards**: Read `docs/CONTRIBUTING.md` (lines 45-98, ~53 lines) |
| 149 | + - Inline → Rules section ("Code Style" and "Testing" sections only) |
| 150 | +
|
| 151 | +2. **Design doc**: Read `architecture/DESIGN.md` (lines 120-210, ~90 lines) |
| 152 | + - Inline → Input section (component diagram and interface contracts) |
| 153 | +
|
| 154 | +3. **Source files to modify**: `src/api/handlers.py` (lines 1-250), `src/api/routes.py` (~80 lines) |
| 155 | + - Runtime read — add "Read <file>" steps to Task |
| 156 | +
|
| 157 | +4. **Test files**: `tests/test_handlers.py` (lines ~30-120, relevant test class) |
| 158 | + - Runtime read — verify tests pass after changes |
| 159 | +``` |
| 160 | + |
| 161 | +**Migration** (e.g., upgrade framework, migrate database): |
| 162 | + |
| 163 | +``` |
| 164 | +1. **Migration guide**: Read `docs/migration-v3-to-v4.md` (lines 1-200, ~200 lines) |
| 165 | + - Inline → Rules section (breaking changes, required steps — full file) |
| 166 | +
|
| 167 | +2. **Changelog**: Read `CHANGELOG.md` (lines 3-52, ~50 lines) |
| 168 | + - Inline → Input section (v4.0 section only) |
| 169 | +
|
| 170 | +3. **Config files**: `pyproject.toml` (~40 lines), `setup.cfg` (lines 1-25) |
| 171 | + - Runtime read — modify during execution |
| 172 | +
|
| 173 | +4. **Prior phase output**: `{plan_dir}/out/phase-01-audit.md` (~60 lines) |
| 174 | + - Runtime read — contains dependency audit from Phase 1 |
| 175 | +``` |
| 176 | + |
| 177 | +**Free-form task** (e.g., write documentation, create CI pipeline): |
| 178 | + |
| 179 | +``` |
| 180 | +1. **Style guide**: Read `docs/STYLE.md` (lines 1-80, ~80 lines) |
| 181 | + - Inline → Rules section (full file) |
| 182 | +
|
| 183 | +2. **Existing examples**: Read `docs/api-reference.md` (lines 1-60, ~60 lines) |
| 184 | + - Inline → Input section as reference for tone and format |
| 185 | +
|
| 186 | +3. **Source files**: `src/core/api.py` (lines ~15-90, public class), `src/core/models.py` (lines ~1-50) |
| 187 | + - Runtime read — extract docstrings and signatures |
| 188 | +``` |
| 189 | + |
| 190 | +--- |
| 191 | + |
| 192 | +## Fill Rules |
| 193 | + |
| 194 | +When generating briefs from this template: |
| 195 | + |
| 196 | +1. **Include only what this phase needs** — every item must have a clear reason. If a file exists but isn't relevant to the phase, put it in the "Do NOT load" list. |
| 197 | +2. **Line counts** — run `wc -l` or estimate from prior reads. Approximate values are fine (prefix with ~). |
| 198 | +3. **One brief per phase** — generate briefs sequentially, apply context boundary between each. |
| 199 | +4. **File naming** — `brief-{NN}-{slug}.md` where NN is zero-padded phase number and slug is from plan.toml. |
| 200 | +5. **Inline budget** — if inlined content exceeds ~500 lines, consider splitting into multiple load items with narrower scope, or moving some items to runtime reads. |
0 commit comments