Skip to content

Claude Code skills run their start step as they load, so it can't be skipped (GST-3157) - #4509

Merged
capy-ai[bot] merged 5 commits into
mainfrom
skills-start-at-load-in-claude-code
Nov 19, 2026
Merged

capy-ai[bot] merged 5 commits into
mainfrom
skills-start-at-load-in-claude-code

Conversation

@garrytan

@garrytan garrytan commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

In Claude Code, every gstack skill now runs its start command and loads the shared preamble while the skill loads, so the model starts with their output instead of an instruction it can skip.
Why: in test runs, loaded skills' steps were followed in only 45% to 62% of sessions, and /autoplan's start command never ran in 5 of 10.
Nothing to do: other hosts keep today's instructions, and if Claude Code can't run the step, the skill says so and the model runs it as before.

What changed

People running a gstack skill in Claude Code saw the model skip its start step. The instruction to run it sat in the skill text, and in test runs it was followed in only 45% to 62% of sessions. Now Claude Code runs the step itself while the skill loads, so the model starts with the step's output already in front of it.

  • Claude Code runs a skill's !\command` lines while it loads the skill and puts their output into the skill text. Each Claude Code skill now has two such lines: one prints the shared preamble file (sections/preamble.md), the other runs gstack-skill-start`. The plain start command stays right below as the fallback.
  • Both lines run a new helper, bin/gstack-skill-load. Claude Code aborts the whole skill load when an injected command exits non-zero, so the helper always exits 0. It stops the start after 15 seconds (GSTACK_SKILL_LOAD_TIMEOUT), killing everything the start launched, keeps any output the start printed before the limit, and turns any failure into one line that tells the model to run the start itself. It closes stdin and sends the start's output to a temp file, so nothing left running can hold Claude Code's pipe open. It runs nothing beyond what gstack-skill-start already does, network included.
  • The preamble line prints the file only when its first line is the preamble header (# gstack shared preamble <id>), so it can't be pointed at another file. This works for every install layout, including installs served from a render directory.
  • In plan mode, a bare Bash in allowed-tools doesn't let an injected command run. The classifier or a prompt decides, and anything short of "allow" aborts the load. So each Claude Code skill's allowed-tools also names the helper (Bash(~/.claude/skills/gstack/bin/gstack-skill-load:*)), which Claude Code allows in every mode.
  • Each injected line is one plain command with no variables or fallbacks, which worktree-isolated sessions require (Every skill's start preamble is refused by worktree-isolated Claude Code sessions (compound shape; 49 SKILL.md files) #2763).
  • /plan-eng-review and /plan-design-review still run their start command after their scope question, so only their shared preamble loads early.
  • The instruction-block rule now trusts blocks in the start output shown in the skill, or in the tool result when the model ran the start itself.
Why

"Loaded skills' steps were followed in only 45% to 62% of sessions, and /autoplan's start command never ran in 5 of 10." Running the start step at load means the model can't skip it, so every Claude Code skill begins with its session state, settings and preamble in context.

Blast radius

Only Claude Code skill files change, and the other hosts' generated skills are byte-identical, and of the four ship goldens only the Claude one changed (script ran: gen:skill-docs for every host plus the golden tests). The new helper can't break a load by exiting non-zero, because every path through bin/gstack-skill-load ends in exit 0 (walked failure path, covered by test/gstack-skill-load.test.ts).

Which hosts get which
  • Claude Code: load-time lines, with the old instruction kept below each one as the fallback.
  • Codex, Factory, OpenCode, Cursor, Copilot, Gemini, Kiro, OpenClaw, Hermes, gbrain, Slate and agy: unchanged instruction text.
  • Claude Code with disableSkillShellExecution on, or any agent that reads a Claude skill file directly (Capy, for example): it sees the command or Claude Code's placeholder, and the text tells it to run the start command and read the preamble itself, as before.
Known limits, queued for a follow-up
  • A missing helper, or a deny rule on Bash or on bin/gstack-skill-load, makes Claude Code abort the skill load instead of falling back to the plain instruction.
  • Paid end-to-end tests that look for a gstack-skill-start Bash call may miss the start, because it now runs at load and makes no tool call.
Proof on the real claude binary ($0, local stub API)

The real claude binary ran /autoplan against a local stub that logs each request body, with this branch installed in a fresh HOME. In every run below, the first request already held the shared preamble (# gstack shared preamble d8804c5ab6bf) and the start's STATUS lines (SESSION_ID: and the rest), with no tool call.

Claude Code Mode Preamble inlined Start output inlined Tool calls
2.1.292 (pinned) default yes yes 0
2.1.292 plan yes yes 0
2.1.292 auto yes yes 0
2.1.328 (latest) default yes yes 0
2.1.328 plan yes yes 0
2.1.292, start missing default yes one SKILL_START: failed at load (exit 127) line; the skill still loaded 0
2.1.292, disableSkillShellExecution default placeholder placeholder; the fallback text applies 0

Probes with a dummy skill showed why the helper and the grant are needed. On both versions, a non-zero exit, a missing command or a deny rule aborted the skill load with no API call. In plan mode, a bare Bash grant aborted the load, and a specific Bash(<path>:*) grant ran the command. A PreToolUse hook's "allow" did not help.

Size caps raised (Garry, 2026-11-19, "Do it" on I1 (GST-3157))

Each Claude Code skill file grows by about 380 to 400 bytes, plus one 58-byte frontmatter line. Each cap is set to the value measured on this tree:

  • Always-on context budget, test/fixtures/context-budget.json alwaysOnTotal: 8,647 to 9,498 tokens. The counter includes every skill's whole frontmatter, so the grant line costs about 399 tokens there. Claude Code's skill list shows only names and descriptions.
  • test/helpers/carve-guards.ts: 15 skeleton caps and 9 size-ratio caps (design-html gets its own ratio in place of the 1.05 default).
  • test/size-ledger/ship: one +378-byte entry.
Pre-Landing Review

No blocking issues. The final full review of this head found nothing that would fail a test, break production or lose data; its six notes are listed below and none is fixed here. Second-model review (GPT-6.1 Sol): clean.

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL scripts/resolvers/load-injection.ts:27 1. A missing or uncallable helper now stops the skill from loading at all (scripts/resolvers/load-injection.ts:27, generate-preamble-bash.ts). The module's own header says a non-zero ! command aborts the whole skill load. The rendered line calls the helper at a fixed path, ~/.claude/skills/gstack/bin/gstack-skill-load, or an install-root rewrite of it. When that file is absent, the shell exits 127 and the skill no longer loads. That happens when an install outside the default path falls back to the committed render, for example when its first per-install render fails (setup keeps t
  • INFORMATIONAL scripts/resolvers/load-injection.ts:14 2. Sessions that deny Bash can no longer load any gstack skill (load-injection.ts:14-16, the addLoadGrant grant). The docstring says a ! line whose permission check fails aborts the load. In Claude Code a deny rule outranks a skill's allowed-tools grant. So a managed-settings deny on Bash, or --disallowedTools Bash, now turns every gstack skill into a load failure instead of a skill whose start step the model can't run. The changelog covers disableSkillShellExecution but not deny rules. I did not run Claude Code to confirm this; the precedence is inferred from Claude Code's doc
  • INFORMATIONAL bin/gstack-skill-load:57 3. The 15-second limit can kill the start mid-way through its daily brain pull and sync (bin/gstack-skill-load:57-75). gstack-skill-start runs a daily git fetch plus merge --ff-only in $GSTACK_HOME and gstack-brain-sync --once. Both are network-bound (the low-speed limit alone allows 5 s of stall), and both are now inside the TERM-then-KILL of the whole process group. The brain lock clears locks whose pid is dead, and the drain treats an old .git/index.lock as abandoned, so I found no lasting corruption. The cost is a killed fetch on slow networks, no record of the pull, a 15-second
  • INFORMATIONAL bin/gstack-skill-load:77 4. When the start fails at load, its own error message is dropped (bin/gstack-skill-load:77-80). On a non-zero exit the helper prints only failed at load (exit N) and throws away $OUT, which holds the actionable text (for example "cannot resolve the gstack state root… reinstall with ./setup"). The model recovers by running the start again, but that costs a step. FIXABLE: print $OUT, or its last few lines, before the failure line. Severity: Low. Blocks: no.
  • INFORMATIONAL sf-df685ec1d8a7 security finding, details recorded privately
  • INFORMATIONAL test/helpers/carve-guards.ts:794 6. A trailing-whitespace line in test/helpers/carve-guards.ts:794 (git diff --check). FIXABLE. Severity: Low. Blocks: no.
Documentation

Status: updated (one factual edit, no blockers)

Scope: the branch skills-start-at-load-in-claude-code against base 5afef04, at a clean tree with head 7c87504. The change makes Claude Code skills run their start step and shared preamble at load time through bin/gstack-skill-load. I audited the authored docs that describe the preamble, the generator and host behavior.

Documentation health

File Status
ARCHITECTURE.md Updated: the preamble section now explains load-time injection on Claude Code, the helper's always-exit-0 rule and timeout, the allowed-tools grant, the fallback, and the plan-review exception
CLAUDE.md Current
CONTRIBUTING.md Current
docs/hosts.md Current: describes other hosts, which are unchanged
docs/inventory.md Current
changelog.d/skills-start-at-load-in-claude-code.md Current, checked against the code (not edited)

Coverage debt: no user-facing troubleshooting entry covers the SKILL_START: timed out or SHARED_PREAMBLE: not loaded lines. Diagram drift: none.

Tests
  • Focused tests (test/gstack-skill-load.test.ts, hermetic skill runtime, exercised map, parity suite, preamble hoist, carve guards, skill size and context budgets): 83 passed, 0 failed
  • Full free suite in CI (run 44618766912 at this head): passed, 1703 test files
  • macOS named regressions and Windows smoke in CI at this head: passed
  • Typecheck and the test typecheck ratchet: clean

No paid eval: gstack-evals measures the effect after this lands.

Agent notes

Refs GST-3157

Approvals

Approved: yes (record r-6a68104214ad). The full approval record stays private.
Plan: approved (record r-0c0beb9d93c8)
Plan check: approved (record r-0c0beb9d93c8)

REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=6 fixed=0 scope=frozen unbound=2 ledgers_read=3 dispatches=3

Ruled note: test/gstack-skill-load.test.ts:79:testing at af92614 ruled by Captain GStack Minder (GSTA-36) (relayed from GSTA-634:2026-11-19T21:25:04Z) at 2026-11-19T21:25:04.735Z: fixed by 7c87504 (30 s per-test timeout) under the one-round grant (approval a-9fab181d3bfb)

{
  "schema_version": 1,
  "pr": 4509,
  "head": "dd98bcca98a8b32c2d1e32559322b05d8387b83e",
  "version": "1.101.0.0",
  "base": "main",
  "gate": {
    "focused": {
      "pass": 83,
      "fail": 0,
      "skip": 0
    },
    "free": {
      "pass": 1703,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "free",
      "run": 44618766912,
      "attempt": 1,
      "tree": "1e4ace3b10f565bf04247dd61fb2c57558fb3761"
    }
  ],
  "calls": 25,
  "session_kind": "unattended",
  "run": "/home/user/.capy/work/gsta634-ship/run2",
  "head_tree": "1e4ace3b10f565bf04247dd61fb2c57558fb3761",
  "product_patch_id": "97010f4d47bab362dafca077ebb40ad29ffa1117",
  "gstack_version": "1.102.0.0",
  "review_depth": {
    "depth": "full",
    "class": "code",
    "runtime_lines": 180,
    "rules": "1afa38a4be3b5eef",
    "base": "12cc21872d8614eafcbb9c28ac9ce79c5eae235c",
    "registry": "12cc21872d8614eafcbb9c28ac9ce79c5eae235c",
    "gate_scan": {
      "tagged": 0,
      "head": "dd98bcca98a8b32c2d1e32559322b05d8387b83e"
    },
    "reasons": [
      "risk:data",
      "runtime=180"
    ],
    "risk": [
      "data"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @1e4ace3b10f5 (8 checks, current for dd98bcca98a8)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44618766912/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44617365271/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=1e4ace3b10f5 tests=37905 skipped=104 runs=44618766912/1 profiles=ci-reuse/free-tests heads=dd98bcca98a8 verified=2026-11-19T21:34:51.499Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "ARCHITECTURE.md, CLAUDE.md, CONTRIBUTING.md, README.md, AGENTS.md and docs/ against the PR diff"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 6,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "ledgers_read": 3,
    "unbound": 2,
    "dispatches": {
      "specialist": 3
    }
  },
  "ruled_notes": [
    {
      "finding": "test/gstack-skill-load.test.ts:79:testing",
      "head": "af926145fd614262affa21d0a988af9116ccd8c8",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "fixed by 7c87504 (30 s per-test timeout) under the one-round grant",
      "at": "2026-11-19T21:25:04.735Z",
      "approval": "a-9fab181d3bfb",
      "relayed": "GSTA-634:2026-11-19T21:25:04Z"
    }
  ],
  "gate_dispositions": []
}
{"head":"af926145fd614262affa21d0a988af9116ccd8c8","run":"run1","status":"started","review_loop":{"passes":1,"blocking_found":0,"deferred":0,"noted":0,"fixed":4,"scope":"frozen","rounds":1,"dispatches":{"specialist":3}}}
{"head":"7c875045176961c2c025bc1e30b1cba3abc9f3af","run":"run2","status":"started","review_loop":{"passes":1,"blocking_found":0,"deferred":0,"noted":0,"fixed":0,"scope":"frozen","rounds":1,"dispatches":{"specialist":3}}}

…skipped (GST-3157)

In Claude Code, each gstack skill now loads the shared preamble and the
start command's output while the skill loads, through bin/gstack-skill-load,
instead of asking the model to read a file and run a command. Other hosts
keep the instruction text. Size caps are raised to the measured values per
Garry, 2026-11-19, "Do it" on I1.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 4 commits November 19, 2026 20:11
The Claude Code render now shows the load-time start line and a short
fallback sentence between the Preamble heading and the bash block, so
the test finds the first bash block after the heading instead of
expecting it on the next line.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…tart's output, and reads its timeout as decimal

Review-Finding: p1/specialist-batched#1 reader=security
Review-Finding: p1/specialist-batched#3 reader=testing
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#2 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…installs served from a render directory load it too

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ut and shared preamble

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit 7f9c1bc into main Nov 19, 2026
78 checks passed
capy-ai Bot added a commit that referenced this pull request Nov 19, 2026
…ll loaded (#4543)

Since #4509, Claude Code skills run their start step as they load, so
the paid /plan-ceo-review auto-decide check could miss a run that really
did auto-decide. It now accepts the start output in the loaded skill
text.

Why: one of the five passing runs captured for that check was credited
only through the session journal, and that path needed a start command
in the tool calls.

Nothing to do: this changes test code and the journal reader the tests
use; no skill text changes.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@garrytan garrytan mentioned this pull request Nov 20, 2026
capy-ai Bot added a commit that referenced this pull request Nov 20, 2026
- Two /ship approval records stop needing workarounds. (#4549)
- For contributors: the paid auto-decide check counts a start step that ran while the skill loaded. (#4543)
- The destructive-command check closes three ways past its disk-wipe and force-push blocks. (#4534)
- A green CI run still counts when the repository's artifact storage is full. (#4536)
- `/cso` now audits repositories that track symlinks. (#4567)
- A doc-sync eval stops failing when the audit child drops one field from its result line. (#4555)
- The browse daemon no longer picks port 10080, which Chromium refuses to open. (#4554)
- Opted-in telemetry now says why a skill run ended, which coding agent and model family ran it, and whether an upgrade worked. (#4542)
- A preregistration with only its write-up and plain data now gets the write-up review: one reviewer, one round. (#4544)
- When owner rulings don't clear a stopped review, `gstack-review-read` now says which findings are left. (#4553)
- The prompt-routing hook now names your installed bug-fix skill on bug reports, alone, and never puts /verify ahead of it. (#4539)
- Owner rulings now close a stopped review whose findings were logged in a findings file. (#4568)
- /ship can finish after the owner accepts a stopped review's findings as open notes. (#4552)
- /ship no longer starts the full test suite on your machine when CI's earlier run can't be reused (GST-3277). (#4565)
- The prompt-routing hook no longer acts on words inside backticks. (#4566)
- In Claude Code, a gstack skill's start step now runs when the skill loads, so the model can't skip it. (#4509)
- gstack's telemetry backend only accepts writes through its own validated endpoint, and the community dashboard now counts real use. (#4537)
- gstack now says what it's adding before it adds a background job or a browser extension. (#4538)
- For contributors: every flaky pass in Free Tests is now recorded. (#4572)
- For contributors: Free Tests on pull requests starts its test shards one round of small jobs sooner. (#4570)
- Secret values written as `name=value` at the end of a path are now hidden. (#4571)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
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.

1 participant