Repository navigation
Description
Problem
When executing a long plan that invokes 5–8 gstack-flavored skills sequentially (/investigate → /plan-eng-review → /codex → /review → /ship etc.), the SKILL.md "Preamble (run first)" bash block is re-injected and re-executed on every invocation. Each preamble is ~200 lines of bash producing 30+ echoed lines (PROACTIVE / PROACTIVE_PROMPTED / BRANCH / SKILL_PREFIX / REPO_MODE / LAKE_INTRO / TELEMETRY / TEL_PROMPTED / EXPLAIN_LEVEL / QUESTION_TUNING / LEARNINGS / HAS_ROUTING / ROUTING_DECLINED / VENDORED_GSTACK / MODEL_OVERLAY / CHECKPOINT_MODE / CHECKPOINT_PUSH / ARTIFACTS_SYNC / etc.).
Within a single session these values do not change. The repeated gstack-config get, find ~/.gstack/sessions, gstack-learnings-search, gstack-timeline-log calls add noise to the agent's context and slow the skill startup.
Measured impact
In a recent 10-task implementation plan (PR #309-like, schema migration + 5 route refactor + double review), the same preamble executed 8 times, ~1600+ lines of duplicated state echo consumed in agent context across the run.
Proposal
Session-scoped cache for preamble outputs:
- On first invoke per session: full preamble runs, output written to
~/.gstack/sessions/<ppid>/preamble.env(or similar) - Subsequent invokes within the same session: skill checks the cache file age (mtime < 2 hours, same PPID), if valid → emit cached values, skip the bash block entirely
- One-shot invalidations (
gstack-config set ..., telemetry toggle, etc.) write a marker to invalidate cache
Alternative lighter-weight: extract preamble into a single shared gstack-session-init helper that all skills source, which itself checks cache.
Repro
# In a Claude Code session, invoke several gstack skills in sequence:
/investigate
/plan-eng-review
/codex review
/review
# Each skill emits the full preamble block — values are identical across invocations.Why now
PR-level plans now routinely chain 5+ skills (investigate → write-plans → execute → codex → kimi review → finishing-a-branch). Preamble overhead is no longer a one-time cost.
Activity
time-attack commentedon Jul 15, 2026
Thanks for this. The blocker is that caching the complete preamble would also cache mutable repository state and suppress required per-invocation side effects. Limit caching to an explicitly pure data subset and define durable session identity, invalidation, repository isolation, permissions, and concurrent access behavior.
docs(preamble): proposal to carve tier-2+ interaction prose into sect…
capy-ai commentedon Oct 11, 2026
Thanks @shizeqin for the idea. In the Oct 11 triage we grouped the open feature requests by theme so related asks get built together instead of one at a time. This one is part of the Prompt cost and skill shape theme in TODOS.md (https://github.com/garrytan/gstack/blob/50d020ad9/TODOS.md#L54-L69). Closing it here so the open list stays actionable; it isn't rejected, and the theme credits every linked reporter when it's picked up.
capy-ai commentedon Oct 25, 2026
Reopened under the
parkedlabel: this is tracked in the Prompt cost and skill shape theme in TODOS.md (https://github.com/garrytan/gstack/blob/main/TODOS.md#p3-feature-themes-from-the-wave-9-triage-filed-2026-10-11), and what fixes it is the shared-preamble trim (GSTA-96), which removes most of the duplicated preamble weight each skill run pays. Closed-but-tracked read as closed, so parked issues now stay open until they ship, are duplicates, or are declined (https://github.com/garrytan/gstack/blob/main/docs/triage.md).capy-ai commentedon Oct 31, 2026
Thanks for the idea, @shizeqin. Caching the startup check would hide repo changes made in the middle of a session, and the shared startup text is already read only once. Closing as not planned.