#!/usr/bin/env bash # gstack-skill-load — what a gstack skill runs when Claude Code loads it (GST-3157). # # Claude Code runs a skill's `!\`\`` lines while the skill loads and # puts their output into the skill text, so the model starts with the result # instead of an instruction it may skip. An injected command that exits # non-zero aborts the whole skill load, so this helper always exits 0 and turns # a failure into one line that tells the model to run the step itself. # # gstack-skill-load preamble FILE print the shared preamble file # gstack-skill-load start ARGS... run gstack-skill-start ARGS under a hard # timeout (GSTACK_SKILL_LOAD_TIMEOUT # seconds, default 15) # # Read-only except for what gstack-skill-start already writes; no network # beyond its update check. stdin is closed and the start's output goes to a # temp file, so nothing it leaves running can hold Claude Code's pipe open. exec 2>/dev/null _BIN=$(cd "$(dirname "$0")" 2>/dev/null && pwd) MODE=${1:-} [ $# -gt 0 ] && shift case "$MODE" in preamble) # Only a gstack shared preamble: the allowed-tools grant auto-approves this # helper, so it prints a file only when its first line after the generated # comments is `# gstack shared preamble <12-hex id>`. Renders served from # another root (--link-root) keep their preambles outside the install root. if [ -n "${1:-}" ] && [ -f "$1" ] && [ -r "$1" ] \ && awk '!/^