Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA
TypeScript
Skills load their declared gbrain context at start, and harness status says unknown when its list fails (#4687)
Garry Tan296b252a34d8
diff --git a/bin/gstack-brain-context-load.ts b/bin/gstack-brain-context-load.tsindex 6af90eb3f..da1bc948c 100644--- a/bin/gstack-brain-context-load.ts+++ b/bin/gstack-brain-context-load.ts@@ -2,7 +2,8 @@/*** gstack-brain-context-load — V1 retrieval surface (Lane C).*- * Called from the gstack preamble at every skill start. Reads the active skill's+ * Called from bin/gstack-skill-start when the active skill's SKILL.md declares+ * `gbrain.context_queries:` and gbrain is configured. Reads the active skill's* `gbrain.context_queries:` frontmatter (Layer 2) or falls back to a generic* salience block (Layer 1). Dispatches each query by kind:*diff --git a/bin/gstack-harness b/bin/gstack-harnessindex a80024b9f..9c10bb5a9 100755--- a/bin/gstack-harness+++ b/bin/gstack-harness@@ -127,7 +127,7 @@ async function main(): Promise<number> {const extra = (['muse', 'grok'] as TargetName[]).filter(n => TARGETS[n].present(env, home)).map(n => ({ target: n, ...(check ? harnessSees(TARGETS[n], '', env, ['review', 'gstack-review'], true) : { visible: 'unknown' as const }) }));if (json) { console.log(JSON.stringify({ registrations: rows, detected: extra })); return 0; }if (!rows.length && !extra.length) console.log('gstack-harness: no harness registrations on this machine');- for (const r of rows) console.log(r.target + '\t' + r.mode + '\t' + r.dest + '\t' + r.files + ' files\t' + (r.stale ? 'stale (' + r.version + '; refresh: ' + self + ' refresh)' : r.version) + '\tvisible to harness: ' + r.visible + (r.checked ? ' (' + r.checked + ')' : '') + (r.missing?.length ? ' missing: ' + r.missing.slice(0, 5).join(', ') : '') + '\t' + r.id+ for (const r of rows) console.log(r.target + '\t' + r.mode + '\t' + r.dest + '\t' + r.files + ' files\t' + (r.stale ? 'stale (' + r.version + '; refresh: ' + self + ' refresh)' : r.version) + '\tvisible to harness: ' + r.visible + (r.checked ? ' (' + r.checked + ')' : '') + (r.error ? ': ' + r.error : '') + (r.missing?.length ? ' missing: ' + r.missing.slice(0, 5).join(', ') : '') + '\t' + r.id+ (r.hook ? '\n start hook: ' + r.hook.state + (r.hook.detail ? ' - ' + r.hook.detail : '') + (r.hook.state !== 'active' && r.hook.fix ? '; ' + r.hook.fix : '') : ''));for (const x of extra) console.log(x.target + '\tdetect\t~/.claude/skills\t' + (x.visible === 'yes' ? 'discovered (Claude-rendered, unverified)' : 'unverified') + (x.checked ? ' (' + x.checked + ')' : ''));return 0;diff --git a/bin/gstack-skill-start b/bin/gstack-skill-startindex c2ddae719..ce91b077a 100755--- a/bin/gstack-skill-start+++ b/bin/gstack-skill-start@@ -36,6 +36,7 @@# (same guard as bin/gstack-brain-sync; pinned by# test/heredoc-pipe-deadlock.test.ts).BASH_COMPAT=50+GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esacSKILL_NAME=""MODEL_OVERLAY="none"@@ -404,16 +405,39 @@ if [ -n "$_GBRAIN_CONFIG" ] && [ -f "$_GBRAIN_CONFIG" ] && command -v gbrain >/dif [ -n "$_REPO_TOP" ] && [ -f "$_REPO_TOP/.gbrain-source" ]; then_GBRAIN_PIN_PATH="$_REPO_TOP/.gbrain-source"fi+ # The repo's gbrain policy tier: read-only never indexes code (so no pin+ # ever comes), deny allows no gbrain use at all (#4419). get --batch never+ # quarantines a corrupt store; any read it refuses counts as deny.+ _GBRAIN_REPO_TIER=$(printf '%s\n' "$(git config --get remote.origin.url 2>/dev/null)" | "$_BIN/gstack-gbrain-repo-policy" get --batch 2>/dev/null) || _GBRAIN_REPO_TIER=deny+ case "$_GBRAIN_REPO_TIER" in+ none) _GBRAIN_REPO_TIER=unset ;;+ read-write|read-only|deny) ;;+ *) _GBRAIN_REPO_TIER=deny ;;+ esacif [ -n "$_GBRAIN_PIN_PATH" ]; thenecho "GBrain configured. Prefer \`gbrain search\`/\`gbrain query\` over Grep for"echo "semantic questions; use \`gbrain code-def\`/\`code-refs\`/\`code-callers\` for"echo "symbol-aware code lookup. See \"## GBrain Search Guidance\" in CLAUDE.md."echo "Run /sync-gbrain to refresh."- else+ elif [ "$_GBRAIN_REPO_TIER" = "read-only" ]; then+ echo "GBrain configured, but this repo's gbrain policy is read-only, so its code is"+ echo "never indexed and this worktree stays unpinned. Use Grep for code questions."+ echo "To index it: gstack-gbrain-repo-policy set <origin url> read-write, then /sync-gbrain --full."+ elif [ "$_GBRAIN_REPO_TIER" != "deny" ]; thenecho "GBrain configured but this worktree isn't pinned yet. Run \`/sync-gbrain --full\`"echo "before relying on \`gbrain search\` for code questions in this worktree."echo "Falls back to Grep until pinned."fi+ # A skill whose SKILL.md declares gbrain.context_queries gets them here,+ # rendered by gstack-brain-context-load (#4329). Off with+ # \`gstack-config set gbrain_context_load off\`, and never in a deny repo.+ _CTX_SKILL_FILE="$_BIN/../$SKILL_NAME/SKILL.md"+ if [ "$_GBRAIN_REPO_TIER" != "deny" ] && [[ "$SKILL_NAME" =~ ^[a-z0-9-]{1,60}$ ]] \+ && grep -q '^ context_queries:' "$_CTX_SKILL_FILE" 2>/dev/null \+ && [ "$("$_BRAIN_CONFIG_BIN" get gbrain_context_load 2>/dev/null)" != "off" ]; then+ bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$_BIN/gstack-brain-context-load.ts" \+ --skill-file "$_CTX_SKILL_FILE" --skill "$SKILL_NAME" --repo "${SLUG:-unknown}" 2>/dev/null | _sanitize || true+ fififidiff --git a/changelog.d/skill-start-gbrain-context-and-harness-status.md b/changelog.d/skill-start-gbrain-context-and-harness-status.mdnew file mode 100644index 000000000..90d19f5b7--- /dev/null+++ b/changelog.d/skill-start-gbrain-context-and-harness-status.md@@ -0,0 +1 @@+**Skills that declare gbrain context queries now get them at start.** `/office-hours`, `/plan-ceo-review`, `/design-shotgun`, `/design-consultation` and `/retro` load their declared brain context at skill start when gbrain is configured, as the docs said they did, and `gstack-config set gbrain_context_load off` turns it off (#4329). In a repo whose gbrain policy is read-only, skill start now says code isn't indexed there instead of telling you to run a `/sync-gbrain --full` that won't pin it, and a deny repo gets no gbrain hint or context (#4419). `gstack-harness status` reports `unknown` with the harness's error when its skill list command fails, instead of listing every skill as missing (#4412).diff --git a/docs/hosts.md b/docs/hosts.mdindex 200bae2ed..395e8dd3d 100644--- a/docs/hosts.md+++ b/docs/hosts.md@@ -61,7 +61,7 @@ characters, the part of a description Hermes's skills index shows.| Harness | What gstack registers | Install | Verify | Remove ||---|---|---|---|---|-| OpenClaw | default `--skills hybrid`: `gstack-review`, `gstack-qa`, `gstack-ship` and `gstack-plan-eng-review` as top-level skills plus one `gstack` router skill whose body lists every other skill and its path, in `${OPENCLAW_STATE_DIR:-~/.openclaw}/skills`. With OpenClaw 2026.10.6's 19 eligible bundled skills, hybrid's skills section stays in full format under its 18,000-character budget; `--skills all` (17,971, compact format, descriptions cut) lists every skill as its own folder, `--skills router` (6,701) only the router. OpenClaw serves a registered skill's `SKILL.md` whole or refuses it ("Skill instructions cannot be partially served"), at most 32,768 bytes when its model catalog has no context window for the model and 32,000 characters with a 100K-200K-token window, so any registered skill over 32,000 bytes (review, ship and plan-eng-review among the four task skills in hybrid, 26 of 63 in `all` today) is a short entry `SKILL.md` with the same name and description that sends the agent to its full `SKILL.md` in a plain copy of every skill (the router's `gstack/skills/`, or `.gstack-skills/` under `--skills all`, a folder OpenClaw's skill scan skips), which OpenClaw reads in pages. A context window under 100K tokens lowers that budget to 16,000 characters, which this limit does not cover | `./setup --host openclaw`, or `./setup` inside OpenClaw | `openclaw skills list --json` shows `gstack` and the four task skills (source `openclaw-managed`, eligible) | `gstack-harness unregister openclaw` |+| OpenClaw | default `--skills hybrid`: `gstack-review`, `gstack-qa`, `gstack-ship` and `gstack-plan-eng-review` as top-level skills plus one `gstack` router skill whose body lists every other skill and its path, in `${OPENCLAW_STATE_DIR:-~/.openclaw}/skills`. With OpenClaw 2026.10.6's 19 eligible bundled skills, hybrid's skills section stays in full format under its 18,000-character budget; `--skills all` (17,971, compact format, descriptions cut) lists every skill as its own folder, `--skills router` (6,701) only the router. OpenClaw serves a registered skill's `SKILL.md` whole or refuses it ("Skill instructions cannot be partially served"), at most 32,768 bytes when its model catalog has no context window for the model and 32,000 characters with a 100K-200K-token window, so any registered skill over 32,000 bytes (review, ship and plan-eng-review among the four task skills in hybrid, 26 of 63 in `all` today) is a short entry `SKILL.md` with the same name and description that sends the agent to its full `SKILL.md` in a plain copy of every skill (the router's `gstack/skills/`, or `.gstack-skills/` under `--skills all`, a folder OpenClaw's skill scan skips), which OpenClaw reads in pages. A context window under 100K tokens lowers that budget to 16,000 characters, which this limit does not cover | `./setup --host openclaw`, or `./setup` inside OpenClaw | `openclaw skills list --json` shows `gstack` and the four task skills (source `openclaw-managed`, eligible); with several agents and explicit ownership, run it inside an agent's workspace or add `--agent <id>`, and `gstack-harness status` reports `unknown` with OpenClaw's error when the unscoped list fails | `gstack-harness unregister openclaw` || Hermes | every skill, as `gstack-<skill>` in one `gstack` category, in `${HERMES_HOME:-~/.hermes}/skills/gstack`. Hermes's skills index lists only skills registered as folders, so a router would leave the rest out of the listing (`skill_view` still loads an unlisted skill by name, but nothing tells the model it exists) | `./setup --host hermes`, or `./setup` inside Hermes | `hermes skills list` shows the `gstack-*` skills in category `gstack` | `gstack-harness unregister hermes` || dots (feder-cr) | the `gstack` router in `/home/dot/skills/gstack`, which the Dot lists every turn | `./setup` on the Dot's computer, or `gstack-harness register dots` | the Dot's Skills page, or `GET /skills` | `gstack-harness unregister dots` || QM | one skill (`gstack-plan`) in QM's own skill format, from `qm/sandbox/skills/` ([qm/README.md](../qm/README.md)). `gstack-harness register qm --yes` still stops before sending anything: QM imports a skill pack by cloning the whole repository and caps it at 32 MiB and 5,000 files, and gstack's repository is about 73 MiB ([why](troubleshooting.md#harness-qm-pack-too-large)) | copy `qm/sandbox/skills/gstack-*` into `<deploy dir>/sandbox/skills/` and run `qm up` | ask it for a gstack skill | remove the folders and run `qm up` again |diff --git a/lib/harness-register.ts b/lib/harness-register.tsindex 32af0be84..4324f061d 100644--- a/lib/harness-register.ts+++ b/lib/harness-register.ts@@ -731,17 +731,19 @@ export function refresh(base: Omit<RegisterOptions, 'target'>, skip: Set<string>}));}-export interface StatusRow { id: string; target: string; dest: string; mode: string; files: number; version: string; stale: boolean; visible: 'yes' | 'no' | 'unknown'; checked?: string; missing?: string[]; hook?: HookResult }+export interface StatusRow { id: string; target: string; dest: string; mode: string; files: number; version: string; stale: boolean; visible: 'yes' | 'no' | 'unknown'; checked?: string; error?: string; missing?: string[]; hook?: HookResult }-/** Runs the harness's own skill list: 'yes' when every name shows (or, with any, at least one). */-export function harnessSees(t: Target, dest: string, env: Env, names: string[], any = false): { visible: 'yes' | 'no' | 'unknown'; checked?: string; missing?: string[] } {+/** Runs the harness's own skill list: 'yes' when every name shows (or, with any, at least one); 'unknown' with its first error line when the list command fails (#4412). */+export function harnessSees(t: Target, dest: string, env: Env, names: string[], any = false): { visible: 'yes' | 'no' | 'unknown'; checked?: string; error?: string; missing?: string[] } {const lc = t.listCommand?.(dest);if (!lc || !names.length || !onPath(lc.argv[0], env)) return { visible: 'unknown' };const r = spawnSync(lc.argv[0], lc.argv.slice(1), { env: { ...process.env, ...env, ...lc.env }, encoding: 'utf8', timeout: 120_000 });+ const checked = lc.argv.join(' ');+ if (r.error || r.status !== 0) return { visible: 'unknown', checked, error: (r.stderr ?? '').split('\n').map(l => l.trim()).find(Boolean) || r.error?.message || 'exit ' + (r.status ?? r.signal) };const text = (r.stdout ?? '') + (r.stderr ?? '');const missing = names.filter(n => !lc.listed(n).test(text));const ok = any ? missing.length < names.length : missing.length === 0;- return { visible: ok ? 'yes' : 'no', checked: lc.argv.join(' '), ...(ok || any ? {} : { missing }) };+ return { visible: ok ? 'yes' : 'no', checked, ...(ok || any ? {} : { missing }) };}export function status(stateRoot: string, version: string, env: Env, check = true): StatusRow[] {diff --git a/setup-gbrain/memory.md b/setup-gbrain/memory.mdindex d2a45123b..47a4d6072 100644--- a/setup-gbrain/memory.md+++ b/setup-gbrain/memory.md@@ -261,8 +261,10 @@ replaceable from disk on each Mac.## How the agent uses it-At every gstack skill start, the preamble runs-`gstack-brain-context-load` which:+When a skill that declares `gbrain.context_queries` starts (`/office-hours`,+`/plan-ceo-review`, `/design-shotgun`, `/design-consultation`, `/retro`) in a+repo whose gbrain policy is not `deny`, the preamble runs+`gstack-brain-context-load`, which:1. Reads the active skill's `gbrain.context_queries:` frontmatter2. Dispatches each query to gbrain (vector / list / filesystem)diff --git a/test/harness-sees-failed-list.test.ts b/test/harness-sees-failed-list.test.tsnew file mode 100644index 000000000..ec9fabe9b--- /dev/null+++ b/test/harness-sees-failed-list.test.ts@@ -0,0 +1,41 @@+/**+ * #4412: a harness list command that fails (OpenClaw's AGENT_SELECTION_REQUIRED+ * with several agents) is an unknown visibility with its error, never a list of+ * every registered skill as missing.+ */+import { afterEach, describe, expect, test } from 'bun:test';+import * as fs from 'node:fs';+import * as os from 'node:os';+import * as path from 'node:path';+import { TARGETS, harnessSees } from '../lib/harness-register';++const dirs: string[] = [];+afterEach(() => { for (const d of dirs.splice(0)) fs.rmSync(d, { recursive: true, force: true }); });++function fakeOpenclaw(script: string): Record<string, string> {+ const d = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-harness-sees-'));+ dirs.push(d);+ fs.writeFileSync(path.join(d, 'openclaw'), '#!/bin/sh\n' + script, { mode: 0o755 });+ return { PATH: d + path.delimiter + process.env.PATH, OPENCLAW_STATE_DIR: path.join(d, 'oc') };+}++describe.skipIf(process.platform === 'win32')('harnessSees with a failing list command (#4412)', () => {+ const dest = (env: Record<string, string>) => path.join(env.OPENCLAW_STATE_DIR, 'skills');++ test('a failed list is unknown, keeps the command and its first error line, and lists nothing missing', () => {+ const env = fakeOpenclaw('echo "Multiple agents are configured, but the skills command has no explicit owner. Pass --agent <id>." >&2\nexit 1\n');+ const seen = harnessSees(TARGETS.openclaw, dest(env), env, ['gstack', 'review', 'ship']);+ expect(seen.visible).toBe('unknown');+ expect(seen.checked).toBe('openclaw skills list --json');+ expect(seen.error).toContain('Pass --agent <id>');+ expect(seen.missing).toBeUndefined();+ });++ test('a list that completes still reports what is missing', () => {+ const env = fakeOpenclaw('echo \'{"skills":[{"name": "gstack"},{"name": "review"}]}\'\n');+ const seen = harnessSees(TARGETS.openclaw, dest(env), env, ['gstack', 'review', 'ship']);+ expect(seen.visible).toBe('no');+ expect(seen.missing).toEqual(['ship']);+ expect(seen.error).toBeUndefined();+ });+});diff --git a/test/skill-start-gbrain-context.test.ts b/test/skill-start-gbrain-context.test.tsnew file mode 100644index 000000000..d5cf914b8--- /dev/null+++ b/test/skill-start-gbrain-context.test.ts@@ -0,0 +1,109 @@+/**+ * gstack-skill-start's gbrain block: a skill that declares+ * gbrain.context_queries gets them at start (#4329), and the unpinned+ * /sync-gbrain hint follows the repo's gbrain policy tier (#4419).+ */+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';+import { execFileSync } from 'node:child_process';+import * as fs from 'node:fs';+import * as os from 'node:os';+import * as path from 'node:path';++const ROOT = path.resolve(import.meta.dir, '..');+const START = path.join(ROOT, 'bin', 'gstack-skill-start');+const ORIGIN = 'https://github.com/acme/widgets.git';++let home: string;+let repo: string;+let bin: string;++function gh(): string {+ const d = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-ssgc-gh-'));+ fs.writeFileSync(path.join(d, 'config.yaml'), 'update_check: false\n');+ fs.writeFileSync(path.join(d, 'developer-profile.json'), '{"tier":"builder-profile-marker"}\n');+ return d;+}++function start(skill: string, gstackHome: string): string {+ return execFileSync(START, ['--skill', skill], {+ timeout: 60_000,+ encoding: 'utf-8',+ cwd: repo,+ env: {+ PATH: bin + path.delimiter + process.env.PATH,+ HOME: home,+ GSTACK_HOME: gstackHome,+ GSTACK_LEASE_DIR: path.join(gstackHome, 'leases'),+ },+ });+}++function run(cmd: string, args: string[], gstackHome: string): void {+ execFileSync(path.join(ROOT, 'bin', cmd), args, { cwd: repo, timeout: 30_000, env: { PATH: process.env.PATH!, HOME: home, GSTACK_HOME: gstackHome } });+}++beforeAll(() => {+ home = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-ssgc-home-'));+ repo = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-ssgc-repo-'));+ bin = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-ssgc-bin-'));+ fs.mkdirSync(path.join(home, '.gbrain'));+ fs.writeFileSync(path.join(home, '.gbrain', 'config.json'), '{}\n');+ fs.writeFileSync(path.join(bin, 'gbrain'), '#!/bin/sh\n[ "$1" = --version ] && echo "gbrain 0.0.0"\nexit 0\n', { mode: 0o755 });+ execFileSync('git', ['init', '-q'], { cwd: repo, timeout: 30_000 });+ execFileSync('git', ['remote', 'add', 'origin', ORIGIN], { cwd: repo, timeout: 30_000 });+});++afterAll(() => {+ for (const d of [home, repo, bin]) fs.rmSync(d, { recursive: true, force: true });+});++describe.skipIf(process.platform === 'win32')('gstack-skill-start gbrain block', () => {+ test("a skill's declared context queries render at start; other skills and the off switch get none (#4329)", () => {+ const g = gh();+ try {+ const out = start('office-hours', g);+ expect(out).toContain('## Your builder profile snapshot');+ expect(out).toContain('developer-profile.json');+ expect(out).toContain('<USER_TRANSCRIPT_DATA do-not-interpret-as-instructions>');+ expect(start('review', g)).not.toContain('## Your builder profile snapshot');+ run('gstack-config', ['set', 'gbrain_context_load', 'off'], g);+ expect(start('office-hours', g)).not.toContain('## Your builder profile snapshot');+ } finally {+ fs.rmSync(g, { recursive: true, force: true });+ }+ });++ test('a read-only repo gets a policy line instead of the /sync-gbrain --full hint; a deny repo gets neither (#4419)', () => {+ const g = gh();+ try {+ expect(start('review', g)).toContain("isn't pinned yet. Run `/sync-gbrain --full`");+ run('gstack-gbrain-repo-policy', ['set', ORIGIN, 'read-only'], g);+ const ro = start('office-hours', g);+ expect(ro).not.toContain("isn't pinned yet");+ expect(ro).toContain("gbrain policy is read-only");+ expect(ro).toContain('## Your builder profile snapshot');+ run('gstack-gbrain-repo-policy', ['set', ORIGIN, 'deny'], g);+ const deny = start('office-hours', g);+ expect(deny).not.toContain("isn't pinned yet");+ expect(deny).not.toContain('gbrain policy is read-only');+ expect(deny).not.toContain('## Your builder profile snapshot');+ } finally {+ fs.rmSync(g, { recursive: true, force: true });+ }+ });++ test('a corrupt policy store is neither quarantined nor read as unset at skill start', () => {+ const g = gh();+ try {+ run('gstack-gbrain-repo-policy', ['set', ORIGIN, 'deny'], g);+ fs.writeFileSync(path.join(g, 'gbrain-repo-policy.json'), '{bad');+ const out = start('office-hours', g);+ expect(out).not.toContain('## Your builder profile snapshot');+ expect(out).not.toContain("isn't pinned yet");+ expect(fs.readFileSync(path.join(g, 'gbrain-repo-policy.json'), 'utf-8')).toBe('{bad');+ expect(fs.readdirSync(g).some(f => f.includes('.corrupt-'))).toBe(false);+ } finally {+ fs.rmSync(g, { recursive: true, force: true });+ }+ });+});