gstack icon indicating copy to clipboard operation
gstack copied to clipboard

Reduce static skill context after one-time setup is settled

Open ajillepalli opened this issue 3 months ago • 2 comments

Problem

Even after one-time setup prompts have been answered and their runtime branches skip, the prose that explains those branches remains inline in every generated SKILL.md. The host loads that static text on every skill invocation.

Measured on gstack v1.63.0.0 in the Codex install on 2026-08-17:

  • office-hours/SKILL.md: 2,102 lines
  • review/SKILL.md: 1,457 lines
  • multiset line intersection: 1,051 identical lines

That is a static context cost, separate from whether the preamble shell actually executes.

Why this is not #1572

#1572 proposes caching repeated runtime preamble output within a session. This report is about the already-loaded SKILL.md prose: a branch can do no work and still consume context because its full setup instructions were injected before execution.

Why this is not fully covered by #2342

#2342 factors the shared behavioral/conduct block for the Claude host and fixes a duplicated macro. It deliberately leaves operational/setup prose inline, and notes that external hosts keep the full inline block. The current Codex-host skill files above still share 1,051 lines.

Suggested direction

Factor settled one-time setup and operational explanations into a shared on-demand reference, while leaving a compact executable contract inline. Alternatively, generate a post-setup skill variant selected from marker state so machines that have completed onboarding do not keep loading onboarding prose.

The important test is static: after setup is settled, compare generated skill file size/context, not only emitted shell output.

Downstream evidence

BucketMap issue areddy294/BucketMap#927 measured this as the largest local gstack token-cost source. That repo can reduce its own always-loaded CLAUDE.md and wrap Codex output, but it cannot remove generated gstack skill context locally without forking the install.

ajillepalli avatar Aug 17 '26 19:08 ajillepalli

A related cost on the Claude Code host: after auto-compaction, Claude Code re-attaches only the first 5,000 tokens of each invoked skill (25,000 in total across skills; see https://code.claude.com/docs/en/skills).

On 1.91.6.0 the inline preamble alone is roughly 7-12k tokens, so that cut lands inside the preamble (around line 250-280 of each generated file) and none of a skill's own procedure or hard rules survive compaction. Examples: ship's "never force-push / never push without fresh test evidence" (~line 1011), land-and-deploy's merge gate, investigate's Iron Law (line 416).

Besides shrinking the static block, emitting each skill's handful of core rules above {{PREAMBLE}} would keep them inside the re-attached window.

jtheyse avatar Oct 07 '26 19:10 jtheyse

Thanks @ajillepalli: the settled-setup prose was moved out of the inline skill bodies in v1.71.0.0 (gate-emitted onboarding, on-demand sections, a CI context-budget ratchet). The compaction point from @jtheyse (core rules above the preamble) is a separate idea; please file it on its own if you want it tracked.

capy-ai[bot] avatar Oct 11 '26 14:10 capy-ai[bot]