Skip to content

perf(workflows): load shipped mode playbooks as inline skills - #1739

Merged
bradygaster merged 1 commit into
devfrom
bradygaster-optimize-shipped-gh-aw-workflows
Aug 18, 2026
Merged

perf(workflows): load shipped mode playbooks as inline skills#1739
bradygaster merged 1 commit into
devfrom
bradygaster-optimize-shipped-gh-aw-workflows

Conversation

@bradygaster

Copy link
Copy Markdown
Owner

Summary

workflows/squad.md declares MODE ISOLATION — exactly one of ~20 mode playbooks executes per invocation — but it was loading all of them, plus the full planning ontology and policy, into every run's ambient prompt.

This converts the 21 mode playbooks and the two planning reference files into gh-aw inline ## skill: blocks, dispatched from a mode→skill table in Execute Mode.

Ambient prompt: 72.6 KB → 16.3 KB (−77.5%). Headroom against gh-aw's 100 KB ceiling goes from 27.6 KB to ~84 KB.

Scope is deliberately limited to the workflows we ship (top-level workflows/). Nothing in .github/workflows/ — the ones Squad uses in this repo — was touched.

Distribution is unchanged

Files stay at their current paths and the imports: list still resolves, so this keeps working:

gh aw add bradygaster/squad/workflows/squad.md@latest

workflows/shared/squad.md was deliberately not renamed — it's documented as a standalone import path, so prefixing it would break existing consumers.

⚠️ Breaking change

Policy selection in an issue body changes:

- <!-- squad-policy: lean -->
+ Squad-Policy: lean

This fixes a real bug rather than introducing churn: squad.md forbade HTML comments as machine state while the docs made the commented form the primary config mechanism — and gh-aw strips HTML comments before the agent ever sees the issue body, so it never worked. Docs updated in .github/agents.md.

Also in here

  • Renamesshared/planning-{ontology,policy}.mdshared/squad-planning-*.md for consistency. Done as git mv (98% / 80% similarity), with all 8 referencing sites updated.
  • allowed-files +17 entries in squad-implement-worker.md: C/C++ headers (*.h, *.hpp — previously *.c/*.cpp were allowed but headers weren't, so C/C++ work was half-blocked), .NET project/build files (*.csproj, *.fsproj, *.sln, *.slnx, *.props, *.targets), plus php, kt, kts, swift, sql, vue, svelte, cjs, gradle. Still an explicit allowlist — no wildcard. nuget.config intentionally excluded as a supply-chain surface.

Test changes worth reviewing

Three of these are findings, not just maintenance:

  1. The gh-aw suite could not run on Windows at all. The helper's /^---\n/ frontmatter regex doesn't match CRLF, and .gitattributes doesn't pin *.md to LF. The file failed to load, so ~86 assertions were passing vacuously on non-Linux machines. Fixed with a readText() CRLF-normalizing helper.
  2. extractModeTable was half-blind. A 3-column regex against a 2-column table matched only 12 of 24 rows. Fixed; coverage doubled, and it immediately caught a mode (Plan Accept (fast-path)) whose parenthetical broke heading matching.
  3. New inline skill extraction suite. This one matters: a skill block closed implicitly at the next ## heading discards trailing content. My first pass at wrapping the ontology silently dropped ~29 KB — the ontology, the policy, and the entire router body — and still compiled clean with all tests green. Now guarded by a zero-discarded-bytes assertion plus byte conservation, required-ambient-sections, and an ambient size budget.

Verification

  • 84 tests pass in the gh-aw suites.
  • Full suite diffed against a stashed baseline: zero new failures. The only delta is gh-aw-quality.test.ts going fail→pass (finding feat: worktree awareness, Scribe auto-commit, and decision consolidation #1 above). The 16 remaining failures are pre-existing Windows issues (path separators, hard-coded /bin/sh) and reproduce identically on the unmodified tree. template-sync flagged once but is flaky under parallel load — passes in isolation (252 tests) and did not recur on a second full run.
  • npm run build passes.
  • Consumer-repo install + gh aw compile --strict → exit 0, against a real mirror at bradygaster/aspiregregator-squad-test. Lock resolves the renamed imports correctly.
  • The 16.3 KB figure is not my own estimate — it comes from running gh-aw's own extract_inline_skills.cjs over the assembled prompt.

No changeset: this touches no packages/*/src/.

Not yet done

A live end-to-end run in the test repo, to confirm skills actually load lazily at runtime rather than merely compiling. That needs secrets configured in the test repo and is queued as follow-up. Everything verified so far proves the workflow compiles and extracts correctly — not that a real run dispatches a single skill.

I'd also suggest promoting the consumer-install harness into scripts/ or CI. The content-discard bug above was caught by hand; that shouldn't be the mechanism.

The shipped workflow declared MODE ISOLATION -- exactly one of ~20 mode
playbooks runs per invocation -- but loaded all of them, plus the full
planning ontology and policy, into every run's ambient prompt.

Convert the 21 mode playbooks and the two planning reference files into
gh-aw inline `## skill:` blocks, dispatched from a mode->skill table in
Execute Mode. Files stay at their current paths and the imports: list is
unchanged, so `gh aw add bradygaster/squad/workflows/squad.md@latest`
keeps resolving.

Ambient prompt: 72.6 KB -> 16.3 KB (-77.5%), verified by running gh-aw's
own extractor over the assembled prompt.

Also:

* Fix a policy bug: squad.md forbade HTML comments as machine state while
  the docs made `<!-- squad-policy: lean -->` the primary config
  mechanism. gh-aw strips HTML comments before the agent sees the issue
  body, so it never worked. Now a plain `Squad-Policy:` directive line.
  BREAKING for anyone using the old comment syntax.

* Prefix the shared planning files with `squad-` for consistency.

* Extend allowed-files in squad-implement-worker.md by 17 entries,
  including C/C++ headers (previously *.c/*.cpp were allowed but headers
  were not) and .NET project/build files.

* Make the gh-aw test suite runnable on Windows. It could not load at all
  (CRLF vs the `/^---\n/` frontmatter regex), so these assertions were
  passing vacuously on non-Linux machines.

* Fix extractModeTable: a 3-column regex against a 2-column table matched
  only 12 of 24 rows, so mode-dispatch coverage was silently half-blind.

* Add an extraction-semantics suite. A skill block closed implicitly at
  the next H2 DISCARDS trailing content, which silently dropped the
  ontology, the policy and the entire router body while still compiling
  clean. Guarded by a zero-discarded-bytes assertion.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ddaabd96-8df5-4998-8695-23b0dc1d896f
Copilot AI lite review requested due to automatic review settings August 17, 2026 23:39
@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit d62ca5f

PR Scope: 🔧 Infrastructure

⚠️ 2 item(s) to address before review

Status Check Details
Single commit 1 commit — clean history
Not in draft Ready for review
Branch up to date Up to date with dev
Copilot review No Copilot review yet — it may still be processing
Changeset present No source files changed — changeset not required
Scope clean No .squad/ or docs/proposals/ files
No merge conflicts No merge conflicts
Copilot threads resolved 1 unresolved Copilot thread(s) — fix and resolve before merging
CI passing All checks passing

Files Changed (7 files, +391 −88)

File +/−
.github/agents.md +8 −4
test-fixtures/planning/aspiregregator/README.md +1 −1
test/gh-aw-quality.test.ts +245 −33
workflows/shared/squad-planning-ontology.md +6 −0
workflows/shared/squad-planning-policy.md +17 −5
workflows/squad-implement-worker.md +17 −0
workflows/squad.md +97 −45

Total: +391 −88


This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.

@github-actions

Copy link
Copy Markdown
Contributor

🟡 Impact Analysis — PR #1739

Risk tier: 🟡 MEDIUM

📊 Summary

Metric Count
Files changed 7
Files added 0
Files modified 7
Files deleted 0
Modules touched 3

🎯 Risk Factors

  • 7 files changed (6-20 → MEDIUM)
  • 3 modules touched (2-4 → MEDIUM)

📦 Modules Affected

ci-workflows (1 file)
  • .github/agents.md
root (5 files)
  • test-fixtures/planning/aspiregregator/README.md
  • workflows/shared/squad-planning-ontology.md
  • workflows/shared/squad-planning-policy.md
  • workflows/squad-implement-worker.md
  • workflows/squad.md
tests (1 file)
  • test/gh-aw-quality.test.ts

This report is generated automatically for every PR. See #733 for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces the always-loaded gh-aw ambient prompt by converting shipped mode playbooks (and planning reference material) into inline ## skill: blocks, then dispatching them via a mode→skill table in Execute Mode. It also updates planning policy selection syntax and strengthens tests around prompt assembly/extraction behavior and cross-platform line endings.

Changes:

  • Converted shipped mode playbooks in workflows/squad.md into inline skills and added an explicit mode→skill dispatch table in Execute Mode.
  • Updated planning policy selection from HTML comments to visible Squad-Policy: / Squad-Setting: directive lines and refreshed related docs.
  • Expanded allowed-files for the implement worker and added/updated tests to enforce inline-skill extraction invariants and CRLF normalization.
Show a summary per file
File Description
workflows/squad.md Adds mode→skill dispatch table and wraps each mode playbook as an inline skill; updates policy resolution guidance.
workflows/squad-implement-worker.md Expands the safe-outputs allowed-files allowlist with additional extensions.
workflows/shared/squad-planning-policy.md Renames planning policy reference file and wraps it as an inline skill block (schema/reference content).
workflows/shared/squad-planning-ontology.md Renames planning ontology reference file and wraps it as an inline skill block.
test/gh-aw-quality.test.ts Normalizes CRLF in markdown reads; fixes mode-table parsing; adds inline-skill extraction regression tests and guards POSIX-shell-dependent suites.
test-fixtures/planning/aspiregregator/README.md Updates fixture docs to reference the renamed planning ontology file.
.github/agents.md Updates documentation to use visible policy directive lines instead of HTML comments.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread workflows/squad.md
| `plan activate` | `squad-plan-activate` |
| `implement` | `squad-implement` |

**Planning modes only** — before running the mode skill, also load `squad-planning-policy` (policy resolution) and `squad-planning-ontology` (artifact schemas and the lifecycle state machine). The non-planning modes (Cast, Connect, Adopt, Cast Member, Retire, Status, Implement) must not load them.
@bradygaster
bradygaster merged commit 39f7a2f into dev Aug 18, 2026
17 checks passed
@bradygaster
bradygaster deleted the bradygaster-optimize-shipped-gh-aw-workflows branch August 20, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants