Repository navigation
Description
Symptom
The coordinator file squad.agent.md is now 83KB / 1,137 lines (the canonical .squad-templates/squad.agent.md on dev tip 89a1b96a). For every Copilot session against a Squad coordinator, that entire blob is loaded as the agent prompt before the first tool call. This is wasteful and only growing — the v0.10 stabilisation set added another +10.6KB / +114 lines.
Measured (today, on dev)
Top sections by byte count:
| Section | Bytes |
|---|---|
| Routing | 9,173 |
| Team Mode | 5,474 |
| Source of Truth Hierarchy | 4,416 |
| Response Mode Selection | 3,920 |
| How to Spawn an Agent | 3,196 |
| Init Mode — Phase 2: Create the Team | 3,171 |
| Init Mode — Phase 1: Propose the Team | 2,208 |
| Role Emoji in Task Descriptions | 2,059 |
| MCP Integration | 2,042 |
| Memory Governance Tools | 1,972 |
These ten sections alone account for 37.6KB / 45% of the file. Most of them describe machinery the coordinator only needs in specific situations (during init, during a spawn, when picking a response mode, etc.) — not on every prompt.
Proposal
Apply the same canonical-doc + load-on-demand-skill pattern we used for cross-squad (discovery in main file, full protocol in cross-squad-communication/SKILL.md):
-
Keep in
squad.agent.md(under ~40KB target):- State backend handshake + HARD RULE (fix(prompt): coordinator must probe for squad_state/memory tools before mutating state (closes #1305) #1306)
- Routing trigger table only (the action cells can be one-liners pointing at satellite skills)
- Always-on roster identity (Scribe, Ralph, Rai, Fact Checker)
- Hard rules (eager-execution exception, ask_user enforcement, spawn-a-squad)
- Source-of-truth one-paragraph summary with
→ load coordinator-source-of-truth skill for full hierarchy
-
Extract to satellite skills (lazy-loaded via the
skilltool when the routing table fires):New skill Source section ~Bytes saved coordinator-routing(full algorithm + examples)Routing 7,000 coordinator-team-modeTeam Mode 5,000 coordinator-source-of-truthSource of Truth Hierarchy 4,000 coordinator-response-modeResponse Mode Selection 3,500 coordinator-spawnHow to Spawn an Agent + Role Emoji 4,500 coordinator-init-modeInit Mode Phase 1 + Phase 2 + Casting 5,000 (existing cross-squad-communication)unchanged — -
Routing-table action cells become:
Load coordinator-{xxx} skill, then follow the {xxx} protocol. Same shape as the spawn-a-squad row (fix(coordinator): route "spawn a squad" / "another squad" prompts through the cross-squad skill #1307) and the squad-commands row (feat(skills): make /squad a real slash command (user-invocable: true + rename squad-commands → squad) #1303).
Target
squad.agent.md: 83KB → ~40KB (51% reduction)- New
coordinator-*skills installed alongside the existing ones viaMANIFEST_SKILL_NAMES - Behaviour unchanged — same triggers fire the same actions; just the action knowledge is loaded on demand
Why now
- v0.10 stabilisation is done and shipped (
@bradygaster/squad-cli@0.10.0-insider.1); good baseline to measure against. - We just did the exact same pattern with
cross-squad-communication(feat(sdk): bundle cross-squad-communication skill (#5 cross-squad protocols) #1295) and it worked well — the routing-table row +Hard trigger — keyword-to-skill matchparagraph (fix(coordinator): route "spawn a squad" / "another squad" prompts through the cross-squad skill #1307) is the load mechanism we'd reuse. - Every new feature added in v0.11+ will otherwise pile more bytes onto a file that's already at the ceiling.
Risks
- Regression risk on coordinator behaviour if a satellite skill isn't loaded when it should be. Mitigated by: (a) reusing the proven
Hard trigger — keyword-to-skill matchrule from fix(coordinator): route "spawn a squad" / "another squad" prompts through the cross-squad skill #1307, (b) regression tests intest/template-sync.test.tslike the ones we already added forcross-squad, (c) staged rollout (extract one section at a time, ship as separate PRs). - Cold-start cost: each satellite skill load is an extra ~50ms file read. Acceptable given the prompt-size savings.
- Coordinator may overlook satellite skills if the routing row + hard-trigger paragraph isn't airtight. Same failure mode we fixed in fix(coordinator): route "spawn a squad" / "another squad" prompts through the cross-squad skill #1307; same defences apply.
Out of scope
- Tier-aware loading by session-frequency (e.g., "load coordinator-routing only on first prompt of a session, cache for the rest") — that's a runtime optimisation; this issue is purely about prompt size.
- Slimming the rich agent charters (Rai 4.5KB, Fact Checker 3KB) — those are per-agent prompts loaded only when the agent is spawned, not on every coordinator session.
Validation plan
Before merging the slimming PR:
- Run the full
test/suite — must pass. - Smoke-test the same end-to-end "build a small Node CLI" scenario we used for v0.10.0-insider.1 — coordinator must dispatch + complete in similar time.
- Smoke-test the routing for each extracted section (spawn-a-squad, init-mode, response-mode-selection, etc.) — each must fire its satellite skill before acting.
Filed by the v0.10 stabilisation effort. Tracking: tamirdresher/squad-stack feat/coordinator-md-slimming (to be created).
Activity
test+changeset: follow 'Determine team size' assertion to coordinator…
test: extractInitMode follows satellite skill + version regex tolerat…
test: extractInitMode follows satellite skill + version regex tolerat…
feat(prompt): slim squad.agent.md by extracting 3 sections to satelli…
test+changeset: follow 'Determine team size' assertion to coordinator…
test: extractInitMode follows satellite skill + version regex tolerat…
feat(prompt): slim squad.agent.md by extracting 3 sections to satelli…
chore: promote dev -> main (v0.12.0) (#1698)