---
description: Centralised structured content composition — all agents writing GitHub content (issues, briefs, comments, PR descriptions, escalation reports) use this for consistent, tier-optimised, actionable output
mode: subagent
tools:
  read: true
  write: false
  edit: false
  bash: true
  glob: false
  grep: true
---

<!-- SPDX-License-Identifier: MIT -->
<!-- SPDX-FileCopyrightText: 2025-2026 Marcus Quinn -->

# Brief Composition Agent

<!-- AI-CONTEXT-START -->

## Quick Reference

- **Purpose**: Single source of truth for all GitHub-written content — briefs, issue bodies, PR descriptions, comments, escalation reports
- **Evidence**: 47-PR research corpus — 100% Haiku success with exact oldString/newString, 0% with descriptive prose.
- **Template**: `templates/brief-template.md`
- **Escalation template**: `templates/escalation-report-template.md`
- **Tier criteria**: `reference/task-taxonomy.md`

<!-- AI-CONTEXT-END -->

## Pre-composition Checks (MANDATORY)

Before composing any brief, issue body, or PR description that will result in code changes, perform ALL of the following checks. These consolidate three mandatory rules from `AGENTS.md` (t2046, t2050, GH#17832-17835) into the briefing workflow.

### 1. Memory recall (t2050)

```bash
memory-helper.sh recall --query "<1-3 keyword phrase from task>" --limit 5
```

Surface accumulated lessons from prior sessions. Read any hits BEFORE drafting the brief — a lesson that says "skipped discovery pass, duplicated 500 lines" tells you exactly what to do differently.

### 2. Discovery pass (t2046)

For any brief that targets specific files, run:

```bash
git log --since="<issue-age + 2h>" --oneline -- <target-files>
gh pr list --state merged --search "<keywords>" --limit 5
gh pr list --state open --search "<keywords>" --limit 5
```

**If any result touches the target files**: STOP. Re-assess whether the task is still valid. Route to "Already-shipped" or "In-flight collision" (see `brief/routing.md`).

### 3. File:line verification (GH#17832-17835)

For every file reference in the brief, confirm it exists and the content matches:

```bash
git ls-files <path>           # verify file exists
sed -n '<line>p' <path>       # verify line content matches claim
```

Briefs with phantom line references waste worker cycles. Every `file:line` claim must be verified against the current `HEAD` before filing.

### 4. Tier disqualifier check

Cross-check the draft brief against `reference/task-taxonomy.md` "Tier Assignment Validation" disqualifiers BEFORE choosing a tier. Server-side `tier-simple-body-shape-helper.sh` (t2389) catches some mis-tiers at dispatch, but catching at composition time is cheaper.

Quick disqualifiers for `tier:simple`:
- More than 2 files → `tier:standard`
- Any target file >500 lines without exact `oldString`/`newString` → `tier:standard`
- Judgment keywords (design, choose, coordinate, graceful, retry, fallback) → `tier:standard`
- Estimate >1h or >4 acceptance criteria → `tier:standard`

### 5. Self-assignment awareness (t2406)

If filing via `gh_create_issue` with `auto-dispatch` label, plan to unassign immediately after:

```bash
gh issue edit <N> --repo <slug> --remove-assignee <user>
```

The wrapper currently self-assigns in violation of t2157. Until t2406/GH#19991 merges, manual unassign is required to avoid dispatch-blocking.

## Core Rule

**The brief IS the product.** A vague brief dispatched to Opus wastes more money than a prescriptive brief dispatched to Haiku. Invest the effort in the brief, not the worker.

## Seeded Draft PR Decision

When an issue or brief is created after enough discovery to know the likely implementation path, the author MAY open a seeded draft PR that gives the worker verified implementation context. This is opt-in. Issue-only remains the default when confidence is not high.

### Seed only when ALL criteria hold

- **Fresh discovery:** memory recall, duplicate/in-flight discovery, and file-ref verification were completed in this session against current `HEAD`.
- **Verified files:** every seeded change references existing files and line ranges checked immediately before composing the PR; new-file paths have verified parent directories.
- **High-confidence pattern:** the implementation follows an existing pattern or exact skeleton already captured in the brief.
- **Honest verification state:** any tests, lint, or build commands already run are named with results; unrun checks are explicitly marked unverified.
- **Draft safety:** the PR is opened as a draft, linked to the issue/brief, and clearly says it is a seed for continuation, not merge-ready work.

### Do NOT seed when any caution applies

- The target code is moving quickly or discovery found recent related commits/PRs that need reassessment.
- The likely implementation depends on design judgment, credentials, production state, or a human decision.
- The seed would anchor the worker to an untested hypothesis instead of evidence.
- The author cannot describe how to verify the seeded approach.
- The PR would be easy to mistake for ready-to-merge work.

### Required seeded PR content

Seeded draft PR bodies must mentor the next worker with:

- Issue link using `For #NNN` while the PR is draft-only; switch to the normal closing keyword only when the PR becomes the final implementation PR.
- Files and line ranges already verified.
- What was implemented or only sketched.
- Verification already run, plus explicit `UNVERIFIED` items.
- Stale-assumption warning: what would make the seed wrong and what to re-check before continuing.

Record the decision in `templates/brief-template.md` under **Seeded Draft PR** whether a seed was created or intentionally skipped.

## Tier Classification

Assess every work item against these empirical criteria (from 47-PR research):

| Criterion | tier:simple | tier:standard | tier:thinking |
|-----------|------------|---------------|----------------|
| **Files** | Single file | 2-3 files with coordination | 4+ files or architectural |
| **Lines changed** | Under 100 | 100-500 | 500+ or novel design |
| **Pattern** | Follows existing pattern | Adapts pattern to new context | Creates new pattern |
| **Code provided** | Exact oldString/newString | Skeletons with signatures | Approach description |
| **Judgment needed** | None — mechanical execution | Error recovery, approach selection | Design decisions, trade-offs |
| **Examples** | Review feedback, config tweaks, quote fixes, docs additions | Bug fixes, refactors, feature impl | Architecture, security audits |

**Default to `tier:standard`.** Downgrade to `tier:simple` only with exact `oldString`/`newString` for every edit, file <500 lines, no judgment required. Check `reference/task-taxonomy.md` "tier:simple Disqualifiers".

## The Mentorship Principle

Every piece of GitHub-written content mentors the next reader. Apply these checks:

| Question | If NO → fix |
|----------|-------------|
| Does this tell the reader WHERE to look? | Add file paths with line ranges |
| Does this tell the reader WHAT to do? | Add exact code or clear steps |
| Does this tell the reader HOW to verify? | Add verification commands |
| Does this tell the reader WHEN they are done? | Add a concrete completion signal |
| Does this tell the reader WHAT to do when stuck? | Add fallback/recovery steps |
| Does this tell the reader WHAT was already tried? | Add prior attempt context (escalation, kill comments) |
| Could a cheaper model execute this? | Make it more prescriptive |

A dispatch comment that says "implement issue #42" teaches nothing. One that says "edit `src/auth.ts:45` — replace `([^0-9]|$)` with `\b` — verify with `shellcheck src/auth.ts`" enables tier:simple dispatch.

## How to Use This Agent

- **Routing**: See `brief/routing.md` for when to use this agent (work item creation, comments, PR descriptions)
- **Headless resilience**: Anticipate empty results, wrong paths, ambiguous states in headless briefs. Every step should answer "what if this returns nothing?" Details: `brief/tier-standard.md`
- **Progressive context**: For tasks with 3+ workflow/reference docs or >2,000 reference lines, include `### Progressive Context Plan` from `templates/brief-template.md` so workers know what to load, when, why, and when to stop.
- **Tier-specific formats**:
  - `tier:simple` → `brief/tier-simple.md` (prescriptive, exact code blocks)
  - `tier:standard` → `brief/tier-standard.md` (skeletons, judgment required)
  - `tier:thinking` → `brief/tier-thinking.md` (problem space, constraints)
- **Templates**: `brief/templates.md` (issue body, comments, PR description, review comment)

## Callers: How to Reference This Agent

Agents that write GitHub content should include a pointer rather than duplicating formatting rules:

```markdown
Format the {finding/brief/issue body/comment/PR description} using `workflows/brief.md`
for the classified tier. Load on demand — do not inline the format rules.
```

## Related

- `templates/brief-template.md` — Full task brief template (for `/define`, `/new-task`)
- `templates/escalation-report-template.md` — Failure report format for cascade dispatch
- `reference/task-taxonomy.md` — Tier definitions, cascade model, escalation reasons
- `reference/large-file-split.md` — Playbook for shell library splits (scanner-filed issues, PR body template)
- `tools/build-agent/build-agent.md` — "Designing tier-aware output" section
- `tools/code-review/code-simplifier.md` — Primary consumer for simplification issues
- `AGENTS.md` — Traceability rules, signature footer, PR title format
