Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

feat(cli): D3 curated --help for the 7 ops-critical commands

garrytana1b53e37d688
diff --git a/scripts/check-compile-autoload.sh b/scripts/check-compile-autoload.sh
index c4670d5b12..0f58a15bae 100755
--- a/scripts/check-compile-autoload.sh
+++ b/scripts/check-compile-autoload.sh
@@ -24,8 +24,11 @@
# Self-test seam: GBRAIN_GUARD_ROOT (fixture tree root) — guard-self-test.sh
# runs this against test/fixtures/guards/check-compile-autoload.sh/{bad,good}.
#
+# Also (agent contract D3): every curated help record in src/cli/command-table.ts
+# loads its module through a literal `() => import('./help/<name>.ts')`.
+#
# Usage: scripts/check-compile-autoload.sh
-# Exit: 0 when every invocation carries the flag, 1 otherwise.
+# Exit: 0 when every invocation carries the flag (and help loads are literal), 1 otherwise.
set -uo pipefail
@@ -61,4 +64,28 @@ if [ -n "$hits" ]; then
exit 1
fi
-echo "OK: every bun build --compile invocation carries $FLAG"
+# Lazy CLI help modules (agent contract D3): each `help:` record in the
+# command table must be `() => import('./help/<name>.ts')` naming an existing
+# file, and every spec module under src/cli/help/ must have a record. A
+# computed specifier would drop the module from the compiled binary; an
+# eager import would load it on `gbrain --version`.
+TABLE="src/cli/command-table.ts"
+if [ -f "$TABLE" ]; then
+ help_hits="$(grep -nE "name: '.*[[:space:],]help:" "$TABLE" | grep -vE "help: \(\) => import\('\./help/[a-z0-9-]+\.ts'\)" || true)"
+ for spec in $(grep -oE "help: \(\) => import\('\./help/[a-z0-9-]+\.ts'\)" "$TABLE" | sed -E "s/.*'\.\/(help\/[a-z0-9-]+\.ts)'.*/\1/"); do
+ [ -f "src/cli/$spec" ] || help_hits="$help_hits"$'\n'"$TABLE: help module src/cli/$spec does not exist"
+ done
+ for f in src/cli/help/*.ts; do
+ [ -f "$f" ] || continue
+ case "$(basename "$f")" in render.ts|validate.ts) continue ;; esac
+ grep -qF "import('./help/$(basename "$f")')" "$TABLE" || help_hits="$help_hits"$'\n'"$f: no command-table record loads it lazily"
+ done
+ help_hits="$(printf '%s' "$help_hits" | sed '/^$/d')"
+ if [ -n "$help_hits" ]; then
+ echo "ERROR: lazy CLI help module(s) not loaded through a literal () => import('./help/<name>.ts'):" >&2
+ echo "$help_hits" >&2
+ exit 1
+ fi
+fi
+
+echo "OK: every bun build --compile invocation carries $FLAG; lazy help modules are literal imports"
diff --git a/scripts/guards-manifest.tsv b/scripts/guards-manifest.tsv
index c434da1acc..bb21180917 100644
--- a/scripts/guards-manifest.tsv
+++ b/scripts/guards-manifest.tsv
@@ -46,7 +46,7 @@ check-key-files-current-state.sh scanner todo
check-exports-count.sh scanner todo was reachable from neither verify nor CI pre-W0 (check:all only)
check-trailing-newline.sh scanner todo was reachable from neither verify nor CI pre-W0 (check:all only)
check-test-isolation.sh scanner todo allowlist data file: check-test-isolation.allowlist
-check-compile-autoload.sh scanner yes every `bun build --compile` invocation (CLI one-liners + TS spawn arrays) in package.json/.github/scripts/docs/CLAUDE.md/CONTRIBUTING.md must carry --no-compile-autoload-bunfig (a cwd bunfig.toml preload runs before cli-preflight in a compiled binary)
+check-compile-autoload.sh scanner yes every `bun build --compile` invocation (CLI one-liners + TS spawn arrays) in package.json/.github/scripts/docs/CLAUDE.md/CONTRIBUTING.md must carry --no-compile-autoload-bunfig (a cwd bunfig.toml preload runs before cli-preflight in a compiled binary); also every curated help record in src/cli/command-table.ts loads its src/cli/help/<name>.ts module through a literal () => import() (D3), and every spec module has a record
check-admin-build.sh buildfresh exempt runs the admin build; the build is the test
check-admin-embedded.sh buildfresh exempt embed freshness diff; not in verify CHECKS: duplicates check:admin-build's build
check-admin-scope-drift.sh buildfresh exempt regenerates + diffs
diff --git a/scripts/lib/cli-pipeline.ts b/scripts/lib/cli-pipeline.ts
index b9af4c17f4..0250aa8dd5 100644
--- a/scripts/lib/cli-pipeline.ts
+++ b/scripts/lib/cli-pipeline.ts
@@ -126,6 +126,8 @@ export interface TableRecordShape {
name: string;
/** Literal specifier of `load: () => import('<literal>')`, or null when load is not that shape. */
loadSpecifier: string | null;
+ /** D3: `help` absent → undefined; `() => import('<literal>')` → the literal; any other shape → null. */
+ helpSpecifier?: string | null;
}
/** Every record of CLI_COMMANDS in table order, read by AST (the EO13 literal-load contract). */
@@ -143,13 +145,11 @@ export function readTableRecords(root: string): TableRecordShape[] {
const prop = (key: string) => el.properties.find((p): p is ts.PropertyAssignment => ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.text === key);
const name = prop('name')?.initializer;
if (!name || !ts.isStringLiteral(name)) throw new Error('cli-pipeline: CLI_COMMANDS record without a string-literal name');
- const load = prop('load')?.initializer;
- let loadSpecifier: string | null = null;
- if (load && ts.isArrowFunction(load) && load.parameters.length === 0 && ts.isCallExpression(load.body)
- && load.body.expression.kind === ts.SyntaxKind.ImportKeyword && load.body.arguments.length === 1
- && ts.isStringLiteral(load.body.arguments[0]!)) {
- loadSpecifier = load.body.arguments[0].text;
- }
- return { name: name.text, loadSpecifier };
+ const literalImport = (init: ts.Expression | undefined): string | null =>
+ init && ts.isArrowFunction(init) && init.parameters.length === 0 && ts.isCallExpression(init.body)
+ && init.body.expression.kind === ts.SyntaxKind.ImportKeyword && init.body.arguments.length === 1
+ && ts.isStringLiteral(init.body.arguments[0]!) ? init.body.arguments[0].text : null;
+ const help = prop('help');
+ return { name: name.text, loadSpecifier: literalImport(prop('load')?.initializer), ...(help ? { helpSpecifier: literalImport(help.initializer) } : {}) };
});
}
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index f1547c510b..29f000ee80 100644
--- a/scripts/module-size-limits.tsv
+++ b/scripts/module-size-limits.tsv
@@ -3,7 +3,7 @@
# Raising a ceiling is a conscious, reviewer-visible act. Lower ceilings in
# the same commit as any peel (the guard fails on >50 lines of stale slack).
# Columns: path max_lines policy note
-src/cli.ts 3167 ratchet +5 agent operator wave C10 (merged from the collector): serve --fail-fast in the connect-failure path; +31 #5950 (D6): connectEngine thin-client backstop, engine-free MCP-twin dispatch, recall/advisor/export refusal hints, refusal fix subcommand (lowered to 3131 by D1's renderCliError seam first); +2 agent operator wave A4: observational startup (probe-only connect for startup:observational commands; completeEngineStartup split out of connectEngine, exposed as ctx.completeStartup); +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5232: write-wait import, reporter-owned verdict in the op catch, thin-client writeWaitMs, ctx.writeWaitMs (logic in persistence/write-wait.ts); +1 #4768: serve --access help line; +4 #5433: list_pages TSV cell escaping in formatResult; +2 #lane-h pricing: help line + thin-client refusal hint for `gbrain pricing`; +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5433: list_pages TSV cell escaping in formatResult
+src/cli.ts 3176 ratchet +9 agent operator wave D3/D4: curated --help short-circuit (renderer in cli/help/render.ts), curated flag-value validation call (cli/help/validate.ts), table-dispatched SELF_HELP_WITHOUT_ENGINE entries for the selfHelp flips; +5 agent operator wave C10 (merged from the collector): serve --fail-fast in the connect-failure path; +31 #5950 (D6): connectEngine thin-client backstop, engine-free MCP-twin dispatch, recall/advisor/export refusal hints, refusal fix subcommand (lowered to 3131 by D1's renderCliError seam first); +2 agent operator wave A4: observational startup (probe-only connect for startup:observational commands; completeEngineStartup split out of connectEngine, exposed as ctx.completeStartup); +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5232: write-wait import, reporter-owned verdict in the op catch, thin-client writeWaitMs, ctx.writeWaitMs (logic in persistence/write-wait.ts); +1 #4768: serve --access help line; +4 #5433: list_pages TSV cell escaping in formatResult; +2 #lane-h pricing: help line + thin-client refusal hint for `gbrain pricing`; +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5433: list_pages TSV cell escaping in formatResult
src/commands/autopilot.ts 1639 ratchet refactor wave 1 split target (W4 autopilot, cut line); ceiling rationale: docs/architecture/key-files/commands-1.md entry for src/commands/autopilot.ts; +2 fix wave 5: nosemgrep justifications on the per-brain job launchctl/systemctl calls (#5195); +2 #5813: boot reconcile names attempted and running versions in log + audit; +2 #5855: Bun floor gate before the swap and the swap-refusal hold (logic in core/bun-floor.ts)
src/commands/doctor.ts 653 ratchet refactor wave 1 split target (W4 doctor); ceiling rationale: docs/architecture/key-files/commands-2.md entry for src/commands/doctor.ts
src/commands/embed.ts 2219 ratchet +2 agent operator wave D2: --json failure envelope via writeCliError; lowered v0.46.26.0: embedBatchWithBackoff + retry cluster peeled to core/embed-retry.ts (core/commands layering fix); grown wave-g (#4530): per-model input-limit wiring; wave-k #3622 reimpl: --stale zero-progress failure quarantine; +29 #4668 (#4530): oversize-heal call sites in both --stale drains — kept low by peeling the healed-row remap to core/embed-oversize-heal.ts (shared with embed-stale.ts); +35 #4647 (refs #4599): per-tick timeout+abort on the single-flight lock heartbeat refresh (interval deliberately NOT unref'd); +122 refs #4599: stall-watchdog race around the drain + shared idempotent flushAndRelease + CLI stall exit mapping (watchdog machinery itself lives in core/embed-stall.ts); +12: adversarial-review hardening (healed_splits progress key + heal-tick comment); #5105: guarded derived projection preparation and read seals; #5105: conditional embedding installer wiring; archived eligibility: active-only dispatch with honest stranded-work reporting; explicit archived admission: live-source snapshots and honest refused-installation failures; +2 fw3: embed --stale --images dispatch (sweep lives in core/embed-stale-images.ts); +5 #5289: dry run reports restamp-only chunks apart from chunks to embed (count lives in core/embedding-invalidation.ts); +6 #4616: keep a partially refused batch in embedPageTexts and name the recovery command in failure samples (guard lives in core/ai/embedding-guard.ts); +5 #5226: embed summary counts distinct pages; +3 #5804: null projection snapshot counted as a failure with one batch summary in embed --stale; +18 wave 8 lane D1: #5527 mixed-space warning subtracts current-model chunks (+4), #5885 takes option/result fields and the stale-drain takes call (pass lives in core/embed-takes.ts); +9 Foundations 1 F4d: time-budget stop result fields, stdout verdict and stop recording in embed --stale (logic in core/embed-budget-stop.ts)
diff --git a/src/cli.ts b/src/cli.ts
index 7e57c12240..92cbe03d5e 100755
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -37,6 +37,7 @@ import { currentCliWriteWait } from './core/persistence/write-wait.ts';
import { isScopeErrorCode } from './core/error-catalogue.ts';
import { shouldForceExitAfterMain, finishCliTeardown, flushThenExit, currentExitCode, setCliExitVerdict, writeStdoutFinal, installStdoutPipeDelivery } from './core/cli-force-exit.ts';
import { agentJsonGuardMode } from './cli/json-guard.ts';
+import { printCuratedHelp } from './cli/help/render.ts';
import { cliCommandOf, exitCliError, unknownFlagError, usageError, writeCliError, writeFatalCliError } from './cli/cli-error.ts';
import { opError } from './core/ops/contract.ts';
import { opParamValue } from './cli/op-param-values.ts';
@@ -411,6 +412,7 @@ async function main() {
? subArgs.slice(0, subArgs.indexOf('--'))
: subArgs;
if (hasHelpFlag(helpScanArgs)) {
+ if (await printCuratedHelp(command, subArgs)) return;
// `eval brainbench` ships a published foreign-runner flag surface — its
// own usage() must win over the generic eval stub (codex P3). Fall
// through to handleCliOnly's no-DB brainbench route, which prints it.
diff --git a/src/cli/command-table.ts b/src/cli/command-table.ts
index 9480d7d362..6fcbfca287 100644
--- a/src/cli/command-table.ts
+++ b/src/cli/command-table.ts
@@ -25,8 +25,9 @@
* degraded-serve recovery and teardown stay an explicit ordered pipeline in
* handleCliOnly; the table does not express them.
*
- * Every `load` is `() => import('<string literal>')` so `bun build --compile`
- * bundles each module and `gbrain --version` loads none of them
+ * Every `load` (and D3 curated `help`, `() => import('./help/<name>.ts')`) is
+ * `() => import('<string literal>')` so `bun build --compile` bundles each
+ * module and `gbrain --version` loads none of them
* (test/cli-command-table.test.ts; scripts/check-compile-autoload.sh).
*
* Adding a CLI-only command: add a record here plus its module under
@@ -200,10 +201,10 @@ export const CLI_COMMANDS: readonly CliCommandRecord[] = [ // Pre-connect: disp
{ name: 'friction', phase: 'pre-connect', thinClient: 'none', selfHelp: true, load: () => import('./commands/friction.ts') },
{ name: 'claw-test', phase: 'pre-connect', thinClient: 'none', load: () => import('./commands/claw-test.ts') },
{ name: 'report', phase: 'pre-connect', thinClient: 'none', load: () => import('./commands/report.ts') },
- { name: 'apply-migrations', phase: 'pre-connect', thinClient: 'refuse', load: () => import('./commands/apply-migrations.ts') },
+ { name: 'apply-migrations', phase: 'pre-connect', thinClient: 'refuse', help: () => import('./help/apply-migrations.ts'), load: () => import('./commands/apply-migrations.ts') },
{ name: 'repair-jsonb', phase: 'pre-connect', thinClient: 'refuse', load: () => import('./commands/repair-jsonb.ts') },
{ name: 'skillpack-check', phase: 'pre-connect', thinClient: 'none', selfHelp: true, load: () => import('./commands/skillpack-check.ts') },
- { name: 'doctor', phase: 'pre-connect-own-engine', thinClient: 'none', json: 'document', load: () => import('./commands/doctor.ts') },
+ { name: 'doctor', phase: 'pre-connect-own-engine', thinClient: 'none', json: 'document', help: () => import('./help/doctor.ts'), load: () => import('./commands/doctor.ts') },
// CLI_ONLY: cathedral-5: deterministic compiled-context views (engine-needing; refused on thin
// clients; help answers engine-free).
// selfHelp: cathedral-5: compile-context ships its own detailed usage (targets, check-mode exit
@@ -238,11 +239,11 @@ export const CLI_COMMANDS: readonly CliCommandRecord[] = [ // Pre-connect: disp
// Post-connect: dispatched by dispatchConnectedCommand after connectEngine(), in master switch order.
{ name: 'mcp', phase: 'post-connect', thinClient: 'none', selfHelp: true, load: () => import('./commands/mcp.ts') },
- { name: 'import', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/import.ts') },
+ { name: 'import', phase: 'post-connect', thinClient: 'none', help: () => import('./help/import.ts'), load: () => import('./commands/import.ts') },
{ name: 'export', phase: 'post-connect', thinClient: 'refuse', selfHelp: true, load: () => import('./commands/export.ts') },
{ name: 'files', phase: 'post-connect', thinClient: 'refuse', load: () => import('./commands/files.ts') },
{ name: 'embed', phase: 'post-connect', thinClient: 'refuse', selfHelp: true, json: 'document', load: () => import('./commands/embed.ts') },
- { name: 'serve', phase: 'post-connect', thinClient: 'refuse', load: () => import('./commands/serve.ts') },
+ { name: 'serve', phase: 'post-connect', thinClient: 'refuse', help: () => import('./help/serve.ts'), load: () => import('./commands/serve.ts') },
// thin client: Agent-bootstrap [CX2-5]: the maintenance sweep runs against the LOCAL engine (the
// serve-resident sweep's trusted CLI entry). On a thin client it would fabricate a scratch PGLite
// and sweep nothing anyone reads. `bootstrap` and `hook` are deliberately NOT here (ENG-2).
@@ -289,7 +290,7 @@ export const CLI_COMMANDS: readonly CliCommandRecord[] = [ // Pre-connect: disp
// caveat, provenance, --reenrich-after). Route around the stub.
{ name: 'enrich', phase: 'post-connect', thinClient: 'refuse', selfHelp: true, load: () => import('./commands/enrich.ts') },
{ name: 'features', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/features.ts') },
- { name: 'autopilot', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/autopilot.ts') },
+ { name: 'autopilot', phase: 'post-connect', thinClient: 'none', help: () => import('./help/autopilot.ts'), load: () => import('./commands/autopilot.ts') },
{ name: 'graph-query', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/graph-query.ts') },
{ name: 'reconcile-links', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/reconcile-links.ts') },
// selfHelp: gbrain repair prints REPAIR_HELP (kinds + dry-run/apply contract).
@@ -301,7 +302,7 @@ export const CLI_COMMANDS: readonly CliCommandRecord[] = [ // Pre-connect: disp
{ name: 'reindex', phase: 'post-connect', thinClient: 'none', selfHelp: true, load: () => import('./commands/reindex.ts') },
{ name: 'salience', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/salience.ts') },
{ name: 'anomalies', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/anomalies.ts') },
- { name: 'status', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/status.ts') },
+ { name: 'status', phase: 'post-connect', thinClient: 'none', help: () => import('./help/status.ts'), load: () => import('./commands/status.ts') },
{ name: 'advisor', phase: 'post-connect', thinClient: 'refuse', load: () => import('./commands/advisor.ts') },
{ name: 'conversation-parser', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/conversation-parser.ts') },
{ name: 'edges-backfill', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/edges-backfill.ts') },
@@ -331,7 +332,7 @@ export const CLI_COMMANDS: readonly CliCommandRecord[] = [ // Pre-connect: disp
// level with a hint pointing at the routable MCP tools; per-subcommand splits are a v0.31.x
// follow-up TODO.
{ name: 'takes', phase: 'post-connect', thinClient: 'route-then-refuse', selfHelp: true, load: () => import('./commands/takes.ts') },
- { name: 'onboard', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/onboard.ts') },
+ { name: 'onboard', phase: 'post-connect', thinClient: 'none', help: () => import('./help/onboard.ts'), load: () => import('./commands/onboard.ts') },
{ name: 'founder', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/founder.ts') },
{ name: 'think', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/think.ts') },
{ name: 'recall', phase: 'post-connect', thinClient: 'none', load: () => import('./commands/recall.ts') },
diff --git a/src/cli/help/apply-migrations.ts b/src/cli/help/apply-migrations.ts
new file mode 100644
index 0000000000..50288e227f
--- /dev/null
+++ b/src/cli/help/apply-migrations.ts
@@ -0,0 +1,41 @@
+/** D3 curated help for `gbrain apply-migrations` (flags read by src/commands/apply-migrations.ts parseArgs). */
+import type { CliHelpSpec } from '../command-table.ts';
+
+export const help: CliHelpSpec = {
+ summary: 'Run pending migration orchestrators (schema, data and host-file migrations).',
+ usage: [
+ 'gbrain apply-migrations [--yes | --non-interactive] [--dry-run [--json]] [--list] [--mode always|pain_triggered|off]',
+ 'gbrain apply-migrations --migration <vX.Y.Z> | --force-retry <vX.Y.Z> | --force-orchestrator | --force-schema | --force',
+ 'gbrain apply-migrations --migration 0.53.0 --export-db-only --content-root <path> [--export-source <id>] --dry-run --json',
+ ].join('\n'),
+ flags: [
+ { name: '--yes', type: 'boolean', desc: 'Run without prompting (default mode pain_triggered); authorizes the Phase F autopilot install.', consent: ['persistent_install'] },
+ { name: '--non-interactive', type: 'boolean', desc: 'Never prompt; authorizes only the Phase F autopilot install.', consent: ['persistent_install'] },
+ { name: '--dry-run', type: 'boolean', desc: 'Print the plan; take no action.' },
+ { name: '--json', type: 'boolean', desc: 'With --dry-run or --list: machine-readable plan, inventories and conflicts.' },
+ { name: '--list', type: 'boolean', desc: 'Show applied and pending migrations.' },
+ { name: '--mode', type: 'enum', values: ['always', 'pain_triggered', 'off'], desc: 'Set minion_mode without prompting.' },
+ { name: '--migration', type: 'string', desc: 'Force-run one migration by version.' },
+ { name: '--force-retry', type: 'string', desc: 'Clear a wedged migration (3+ consecutive partials) so the next run treats it as fresh.' },
+ { name: '--force-orchestrator', type: 'boolean', desc: 'Reset every wedged orchestrator migration in one shot.' },
+ { name: '--force-schema', type: 'boolean', desc: 'Reset schema-version drift and re-run the schema migrations.' },
+ { name: '--force', type: 'boolean', desc: 'Alias of --force-all: --force-orchestrator plus --force-schema.' },
+ { name: '--force-all', type: 'boolean', desc: 'Both --force-orchestrator and --force-schema.' },
+ { name: '--skip-verify', type: 'boolean', desc: 'Bypass post-condition verify hooks on non-idempotent migrations.' },
+ { name: '--require-db', type: 'boolean', desc: 'Exit 1 when the database is unreachable instead of running the filesystem-only plan.' },
+ { name: '--host-dir', type: 'string', desc: 'Include this directory in the host-file walk (default $HOME/.claude and $HOME/.openclaw).' },
+ { name: '--no-autopilot-install', type: 'boolean', desc: 'Skip the Phase F autopilot install (also GBRAIN_NO_AUTOPILOT_INSTALL=1).' },
+ { name: '--export-db-only', type: 'boolean', desc: 'Export DB-only content to markdown (needs --content-root and one backup choice).' },
+ { name: '--content-root', type: 'string', desc: 'Directory the DB-only export writes into.' },
+ { name: '--export-source', type: 'string', desc: 'Source id to export (default default).' },
+ { name: '--confirm-quiesced', type: 'boolean', desc: 'Attest old writers and skill servers are stopped.' },
+ { name: '--backup-confirmed', type: 'boolean', desc: 'Attest an operational backup was verified.' },
+ { name: '--acknowledge-no-backup', type: 'boolean', desc: 'Proceed without a verified backup (explicit choice).', consent: ['destructive'] },
+ ],
+ examples: [
+ 'gbrain apply-migrations --dry-run --json',
+ 'gbrain apply-migrations --yes',
+ 'gbrain apply-migrations --yes --no-autopilot-install',
+ 'gbrain apply-migrations --force-retry 0.53.0',
+ ],
+};
diff --git a/src/cli/help/autopilot.ts b/src/cli/help/autopilot.ts
new file mode 100644
index 0000000000..441e4845ae
--- /dev/null
+++ b/src/cli/help/autopilot.ts
@@ -0,0 +1,34 @@
+/** D3 curated help for `gbrain autopilot` (flags read by src/commands/autopilot.ts, autopilot-daemon.ts, autopilot-pause.ts). */
+import type { CliHelpSpec } from '../command-table.ts';
+
+export const help: CliHelpSpec = {
+ summary: 'Self-maintaining brain daemon: lint, backlinks, sync, extract, embed and orphans on an interval.',
+ usage: [
+ 'gbrain autopilot [--repo <path>] [--interval <s>] [--json] [--no-worker] [--inline]',
+ 'gbrain autopilot --install [--repo <path>] [--target macos|linux-systemd|ephemeral-container|linux-cron] [--force]',
+ 'gbrain autopilot --uninstall | --status [--json] | pause [--reason <text>] | resume',
+ ].join('\n'),
+ flags: [
+ { name: '--repo', type: 'string', desc: 'Brain repository to maintain (default: config sync.repo_path).' },
+ { name: '--interval', type: 'number', desc: 'Seconds between cycles (default 300).' },
+ { name: '--json', type: 'boolean', desc: 'Machine-readable output: daemon cycle events, or the --status / pause report as JSON.' },
+ { name: '--no-worker', type: 'boolean', desc: 'Do not spawn the jobs worker child.' },
+ { name: '--inline', type: 'boolean', desc: 'Run each cycle in-process instead of dispatching it through the Postgres job queue.' },
+ { name: '--install', type: 'boolean', desc: 'Install the daemon under the host supervisor (launchd, systemd, cron or a start script).', consent: ['persistent_install'] },
+ { name: '--target', type: 'enum', values: ['macos', 'linux-systemd', 'ephemeral-container', 'linux-cron'], desc: 'With --install: force the supervisor instead of detecting it.' },
+ { name: '--force', type: 'boolean', desc: 'With --install: allow a daemon on a PGLite brain (it holds the single-writer lock).' },
+ { name: '--inject-bootstrap', type: 'boolean', desc: 'With --install in an ephemeral container: add the start script to the agent bootstrap (automatic when OpenClaw is detected).' },
+ { name: '--no-inject', type: 'boolean', desc: 'With --install: never edit the agent bootstrap files.' },
+ { name: '--uninstall', type: 'boolean', desc: 'Remove the installed daemon.' },
+ { name: '--status', type: 'boolean', desc: 'Report whether the daemon is installed and running.' },
+ { name: '--pause', type: 'boolean', desc: 'Operator hold: the daemon skips cycles until resumed (same as `pause`).' },
+ { name: '--resume', type: 'boolean', desc: 'Lift the operator hold (same as `resume`).' },
+ { name: '--reason', type: 'string', desc: 'With --pause: why the brain is held (recorded in the pause marker).' },
+ ],
+ examples: [
+ 'gbrain autopilot --status --json',
+ 'gbrain autopilot --install --repo ~/brain',
+ 'gbrain autopilot --repo ~/brain --interval 600 --json',
+ 'gbrain autopilot pause --reason "migrating"',
+ ],
+};
diff --git a/src/cli/help/doctor.ts b/src/cli/help/doctor.ts
new file mode 100644
index 0000000000..6c1b6719be
--- /dev/null
+++ b/src/cli/help/doctor.ts
@@ -0,0 +1,43 @@
+/** D3 curated help for `gbrain doctor` (flags read by src/cli/commands/doctor.ts, src/commands/doctor.ts, src/commands/doctor/remediate.ts). */
+import type { CliHelpSpec } from '../command-table.ts';
+
+export const help: CliHelpSpec = {
+ summary: 'Check brain health; preview and run remediation.',
+ usage: [
+ 'gbrain doctor [--fast] [--json] [--fix [--dry-run]] [--scope=brain] [--source <id>] [--no-migrate] [--locks]',
+ 'gbrain doctor --remediation-plan [--target-score <n>] [--no-embed] [--json]',
+ 'gbrain doctor --remediate [--yes [--expect <plan_hash>]] [--include-repairs] [--max-usd <n>] [--target-score <n>]',
+ ' [--max-jobs <n>] [--no-embed] [--dry-run] [--resume [<plan_hash>]] [--json]',
+ ].join('\n'),
+ flags: [
+ { name: '--json', type: 'boolean', desc: 'Print one JSON document (checks, score, findings) on stdout.' },
+ { name: '--fast', type: 'boolean', desc: 'Skip database checks; filesystem and config checks only.' },
+ { name: '--fix', type: 'boolean', desc: 'Apply the local fixes doctor knows (skill files, stale locks); pair with --dry-run to preview.' },
+ { name: '--dry-run', type: 'boolean', desc: 'Preview --fix or --remediate without changing anything.' },
+ { name: '--scope', type: 'enum', values: ['all', 'brain'], desc: 'Pass --scope=brain to skip the skill-file check group (default all).' },
+ { name: '--source', type: 'string', desc: 'Scope the orphan_ratio check to one source id.' },
+ { name: '--skills-dir', type: 'string', desc: 'Override the auto-detected skills/ directory.' },
+ { name: '--no-migrate', type: 'boolean', desc: 'Report on the database as-is; do not apply pending schema migrations first.' },
+ { name: '--locks', type: 'boolean', desc: 'List idle-in-transaction backends holding locks (Postgres) and exit.' },
+ { name: '--probe-pglite', type: 'boolean', desc: 'Run the PGLite runtime probe (a 5-20 s cold start) even when the disk diagnosis explains a failed connect.' },
+ { name: '--index-audit', type: 'boolean', desc: 'Report Postgres indexes with zero recorded scans (informational; never drops anything).' },
+ { name: '--content-audit', type: 'boolean', desc: 'Scan every page in the content-quality check instead of the first 1000.' },
+ { name: '--remediation-plan', type: 'boolean', desc: 'Read-only: the job and repair steps that would raise the brain score, each with its exact command.' },
+ { name: '--remediate', type: 'boolean', desc: 'Run the remediation job steps (asks before any work; non-interactive runs need --yes).', consent: ['paid'] },
+ { name: '--yes', type: 'boolean', desc: 'Authorize the paid job steps (and, with --include-repairs, the repair steps). Capped at the estimate x1.5 without --max-usd.', consent: ['paid', 'destructive'] },
+ { name: '--expect', type: 'string', desc: 'With --include-repairs: the plan_hash the user approved; a changed plan asks again.' },
+ { name: '--include-repairs', type: 'boolean', desc: 'Also run the protected repair steps (local brain host only; needs the user\'s agreement).', consent: ['destructive'] },
+ { name: '--max-usd', type: 'number', desc: 'Cumulative USD cap across the run and every --resume; authorizes paid steps up to it.', consent: ['paid'] },
+ { name: '--max-cost', type: 'number', desc: 'Alias of --max-usd.', consent: ['paid'] },
+ { name: '--target-score', type: 'number', desc: 'Brain score the job steps aim for (default 90).' },
+ { name: '--max-jobs', type: 'number', desc: 'Submit at most this many job steps.' },
+ { name: '--no-embed', type: 'boolean', desc: 'Repair steps re-seal or stamp text only (no paid embeddings).' },
+ { name: '--resume', type: 'string', desc: 'Resume a budget-stopped --remediate run (optionally naming its plan_hash).' },
+ ],
+ examples: [
+ 'gbrain doctor --json',
+ 'gbrain doctor --remediation-plan --json',
+ 'gbrain doctor --remediate --yes --max-usd 5 --target-score 90',
+ 'gbrain doctor --remediate --yes --include-repairs --expect <plan_hash> --max-usd 5',
+ ],
+};
diff --git a/src/cli/help/import.ts b/src/cli/help/import.ts
new file mode 100644
index 0000000000..61c928f842
--- /dev/null
+++ b/src/cli/help/import.ts
@@ -0,0 +1,23 @@
+/** D3 curated help for `gbrain import` (flags read by src/commands/import.ts runImport). */
+import type { CliHelpSpec } from '../command-table.ts';
+
+export const help: CliHelpSpec = {
+ summary: 'Import a directory (or one file) of markdown into the brain.',
+ usage: 'gbrain import <dir> [--source <id> | --source-id <id>] [--no-embed] [--workers <n>] [--fresh] [--include-gitignored] [--allow-noncanonical-root] [--log-noop] [--json]',
+ flags: [
+ { name: '--source', type: 'string', desc: 'Write into this source id (must already exist; see `gbrain sources list`).' },
+ { name: '--source-id', type: 'string', desc: 'Same as --source; pass one or the other.' },
+ { name: '--no-embed', type: 'boolean', desc: 'Skip embeddings (no provider calls); run `gbrain embed --stale` later.' },
+ { name: '--workers', type: 'number', desc: 'Parallel import workers (positive integer, default 1; clamped to the connection budget).' },
+ { name: '--fresh', type: 'boolean', desc: 'Ignore the resume checkpoint and walk every file again.' },
+ { name: '--include-gitignored', type: 'boolean', desc: 'Also import files git ignores.' },
+ { name: '--allow-noncanonical-root', type: 'boolean', desc: 'Import even when the directory is not the source\'s configured root.' },
+ { name: '--log-noop', type: 'boolean', desc: 'Write an ingest_log row even when nothing changed.' },
+ { name: '--json', type: 'boolean', desc: 'Print the import summary as JSON on stdout (progress stays on stderr).' },
+ ],
+ examples: [
+ 'gbrain import ~/notes',
+ 'gbrain import ~/notes --source notes --no-embed',
+ 'gbrain import ./brain --workers 4 --json',
+ ],
+};
diff --git a/src/cli/help/onboard.ts b/src/cli/help/onboard.ts
new file mode 100644
index 0000000000..3b1bc938db
--- /dev/null
+++ b/src/cli/help/onboard.ts
@@ -0,0 +1,26 @@
+/** D3 curated help for `gbrain onboard` (flags read by src/commands/onboard.ts runOnboard). */
+import type { CliHelpSpec } from '../command-table.ts';
+
+export const help: CliHelpSpec = {
+ summary: 'Onboarding plan for the brain: what to fix to reach the target score, and optionally run it.',
+ usage: [
+ 'gbrain onboard [--check] [--target-score <n>] [--explain] [--json]',
+ 'gbrain onboard --auto --max-usd <n|off> [--yes] [--target-score <n>] [--json]',
+ 'gbrain onboard --history [--json]',
+ ].join('\n'),
+ flags: [
+ { name: '--check', type: 'boolean', desc: 'Print the plan; submit nothing (the default mode).' },
+ { name: '--auto', type: 'boolean', desc: 'Submit the auto_apply tier (refuses without --max-usd unless spend.posture=tokenmax).', consent: ['paid'] },
+ { name: '--yes', type: 'boolean', desc: 'With --auto: also submit the prompt_required tier.', consent: ['paid'] },
+ { name: '--max-usd', type: 'string', desc: 'USD cap for --auto, or off / unlimited / none to run uncapped (spend still ledgered).', consent: ['paid'] },
+ { name: '--target-score', type: 'number', desc: 'Brain score the plan aims for (default 90).' },
+ { name: '--explain', type: 'boolean', desc: 'With --check: per-cluster narrative for an available schema-pack upgrade.' },
+ { name: '--history', type: 'boolean', desc: 'Show recent migration impact log entries.' },
+ { name: '--json', type: 'boolean', desc: 'Print the stable JSON envelope.' },
+ ],
+ examples: [
+ 'gbrain onboard --json',
+ 'gbrain onboard --auto --max-usd 5',
+ 'gbrain onboard --history --json',
+ ],
+};
diff --git a/src/cli/help/render.ts b/src/cli/help/render.ts
new file mode 100644
index 0000000000..d222794b44
--- /dev/null
+++ b/src/cli/help/render.ts
@@ -0,0 +1,46 @@
+/**
+ * Agent contract v1 (D3): `gbrain <cmd> --help` from a command's curated help
+ * module (`src/cli/help/<command>.ts`, loaded lazily through the record's
+ * `help`). Engine-free: reads the spec and prints; never opens a brain.
+ * Human text on stdout; `--help --json` prints the spec as one JSON document.
+ */
+import { CONTRACT_VERSION } from '../../core/agent-output.ts';
+import { jsonRequested, writeJsonDocument } from '../../core/cli-force-exit.ts';
+import { findCliCommand, type CliHelpFlag, type CliHelpSpec } from '../command-table.ts';
+
+/** The command's curated help spec, or null when its record has no help module. */
+export async function loadCuratedHelp(command: string): Promise<CliHelpSpec | null> {
+ const load = findCliCommand(command)?.help;
+ return load ? (await load()).help : null;
+}
+
+const VALUE_PLACEHOLDER: Record<CliHelpFlag['type'], string> = { boolean: '', string: ' <value>', number: ' <n>', enum: ' <choice>' };
+
+export function renderCuratedHelp(command: string, spec: CliHelpSpec): string {
+ const [first, ...rest] = spec.usage.split('\n');
+ const lines = [`gbrain ${command}: ${spec.summary}`, '', `Usage: ${first}`, ...rest.map(l => ` ${l}`)];
+ if (spec.flags.length > 0) {
+ const labels = spec.flags.map(f => `${f.name}${VALUE_PLACEHOLDER[f.type]}`);
+ const width = Math.max(...labels.map(l => l.length));
+ lines.push('', 'Flags:');
+ spec.flags.forEach((f, i) => {
+ const values = f.values?.length ? ` One of: ${f.values.join('|')}.` : '';
+ const consent = f.consent?.length ? ` [consent: ${f.consent.join(', ')}]` : '';
+ lines.push(` ${labels[i]!.padEnd(width)} ${f.type.padEnd(7)} ${f.desc}${values}${consent}`);
+ });
+ }
+ lines.push('', 'Examples:', ...spec.examples.map(e => ` ${e}`));
+ if (spec.end_of_options) lines.push('', 'A bare `--` ends options; every later argument is a positional.');
+ if (spec.flags.some(f => f.consent?.length)) lines.push('', 'A flag marked [consent: …] authorizes that effect: get the user\'s agreement before passing it.');
+ lines.push('', `Machine-readable: gbrain ${command} --help --json`);
+ return `${lines.join('\n')}\n`;
+}
+
+/** Prints the curated help when the command has one; returns false otherwise. */
+export async function printCuratedHelp(command: string, args: readonly string[]): Promise<boolean> {
+ const spec = await loadCuratedHelp(command);
+ if (!spec) return false;
+ if (jsonRequested(args)) await writeJsonDocument(JSON.stringify({ command, ...spec, contract_version: CONTRACT_VERSION }));
+ else process.stdout.write(renderCuratedHelp(command, spec));
+ return true;
+}
diff --git a/src/cli/help/serve.ts b/src/cli/help/serve.ts
new file mode 100644
index 0000000000..586acc71ea
--- /dev/null
+++ b/src/cli/help/serve.ts
@@ -0,0 +1,32 @@
+/** D3 curated help for `gbrain serve` (flags read by src/commands/serve.ts, src/mcp/surface.ts, src/core/serve-fail-fast.ts). */
+import type { CliHelpSpec } from '../command-table.ts';
+
+export const help: CliHelpSpec = {
+ summary: 'Run the MCP server: stdio by default, or OAuth 2.1 HTTP with --http.',
+ usage: [
+ 'gbrain serve [--surface verbs|starter|full] [--access full|read-only] [--source-guard] [--stdio-idle-timeout <s>] [--fail-fast]',
+ 'gbrain serve --http [--port <n>] [--bind <host>] [--public-url <url>] [--token-ttl <s>] [--enable-dcr] [--surface …]',
+ ].join('\n'),
+ flags: [
+ { name: '--http', type: 'boolean', desc: 'Serve over HTTP with OAuth 2.1, the admin dashboard and per-token scopes.' },
+ { name: '--surface', type: 'enum', values: ['verbs', 'starter', 'full'], desc: 'Tool surface: the 7 memory verbs, the ~20 daily-driver ops, or every operation (default: config mcp_surface, else full).' },
+ { name: '--access', type: 'enum', values: ['full', 'read-only'], desc: 'stdio only: read-only exposes read-scoped, non-mutating operations.' },
+ { name: '--source-guard', type: 'boolean', desc: 'stdio only: refuse writes unless the source binding is deliberate or unambiguous.' },
+ { name: '--stdio-idle-timeout', type: 'number', desc: 'stdio only: exit after this many idle seconds (0 = never).' },
+ { name: '--fail-fast', type: 'boolean', desc: 'Exit non-zero with the classified error when the database is unreachable (no degraded mode).' },
+ { name: '--port', type: 'number', desc: 'HTTP port (default 3131).' },
+ { name: '--bind', type: 'string', desc: 'HTTP interface to listen on (default 127.0.0.1; 0.0.0.0 for remote access).' },
+ { name: '--public-url', type: 'string', desc: 'The externally reachable base URL (OAuth issuer and redirect checks).' },
+ { name: '--token-ttl', type: 'number', desc: 'Access-token lifetime in seconds (default 3600).' },
+ { name: '--enable-dcr', type: 'boolean', desc: 'Allow OAuth dynamic client registration (consent-bearing authorization_code clients).' },
+ { name: '--enable-dcr-insecure', type: 'boolean', desc: 'Also allow consent-bypassing client_credentials DCR clients (implies --enable-dcr).' },
+ { name: '--log-full-params', type: 'boolean', desc: 'Log raw request payloads instead of redacted summaries (debug only).' },
+ { name: '--suppress-bootstrap-token', type: 'boolean', desc: 'Never print the admin bootstrap token (pair with GBRAIN_ADMIN_BOOTSTRAP_TOKEN).' },
+ { name: '--print-admin-token', type: 'boolean', desc: 'Print the generated admin token even when stdout is not a TTY.' },
+ ],
+ examples: [
+ 'gbrain serve',
+ 'gbrain serve --surface starter --access read-only',
+ 'gbrain serve --http --port 3131 --public-url https://brain.example.com',
+ ],
+};
diff --git a/src/cli/help/status.ts b/src/cli/help/status.ts
new file mode 100644
index 0000000000..ccc2d39eba
--- /dev/null
+++ b/src/cli/help/status.ts
@@ -0,0 +1,18 @@
+/** D3 curated help for `gbrain status` (flags read by src/commands/status.ts runStatus). */
+import type { CliHelpSpec } from '../command-table.ts';
+
+export const help: CliHelpSpec = {
+ summary: 'One-screen operational snapshot: sync, cycle, locks, workers, queue and autopilot.',
+ usage: 'gbrain status [--json] [--section sync|cycle|locks|workers|queue|autopilot] [--fast | --deadline-ms <ms>]',
+ flags: [
+ { name: '--json', type: 'boolean', desc: 'Print the snapshot as one JSON document.' },
+ { name: '--section', type: 'enum', values: ['sync', 'cycle', 'locks', 'workers', 'queue', 'autopilot'], desc: 'Report only this section.' },
+ { name: '--fast', type: 'boolean', desc: 'Bound the snapshot to 2000 ms; a section past the budget returns stale with a warning.' },
+ { name: '--deadline-ms', type: 'number', desc: 'Bound the snapshot to this many milliseconds (positive).' },
+ ],
+ examples: [
+ 'gbrain status',
+ 'gbrain status --json --fast',
+ 'gbrain status --section queue --json',
+ ],
+};
diff --git a/test/cli-command-table.test.ts b/test/cli-command-table.test.ts
index ecd32d1d75..aa0f249178 100644
--- a/test/cli-command-table.test.ts
+++ b/test/cli-command-table.test.ts
@@ -91,6 +91,27 @@ describe('CLI command table', () => {
expect(outside).toEqual([...shape.thinClientGuard.members, 'jobs'].sort());
});
+ test("D3: every curated help is () => import('./help/<name>.ts') naming an existing module that exports help", async () => {
+ const withHelp = astRecords.filter((r) => r.helpSpecifier !== undefined);
+ expect(withHelp.map((r) => r.name)).toEqual(CLI_COMMANDS.filter((r) => r.help).map((r) => r.name));
+ for (const r of withHelp) {
+ expect(r.helpSpecifier, `${r.name}: help is not an arrow returning import('<literal>')`).toBe(`./help/${r.name}.ts`);
+ expect(existsSync(join(ROOT, 'src/cli', r.helpSpecifier!)), `${r.name}: ${r.helpSpecifier} does not exist`).toBe(true);
+ expect((await findCliCommand(r.name)!.help!()).help.summary.length).toBeGreaterThan(0);
+ }
+ });
+
+ test('D3: every src/cli/help spec module has a record; the renderer and validator import none of them (cold start)', () => {
+ const shared = new Set(['render.ts', 'validate.ts']);
+ const files = readdirSync(join(ROOT, 'src/cli/help')).filter((f) => f.endsWith('.ts') && !shared.has(f)).sort();
+ expect(files).toEqual(astRecords.filter((r) => r.helpSpecifier).map((r) => r.helpSpecifier!.slice('./help/'.length)).sort());
+ for (const f of shared) {
+ const imports = parseSource(ROOT, `src/cli/help/${f}`).statements.filter(ts.isImportDeclaration)
+ .map((st) => (st.moduleSpecifier as ts.StringLiteral).text);
+ expect(imports.filter((spec) => files.some((h) => spec === `./${h}`))).toEqual([]);
+ }
+ });
+
test('the table module loads no command module at import time (cold start)', () => {
const sf = parseSource(ROOT, COMMAND_TABLE_PATH);
const runtimeImports = sf.statements.filter((st) => ts.isImportDeclaration(st) && !st.importClause?.isTypeOnly);
diff --git a/test/fixtures/guards/check-compile-autoload.sh/bad-help/package.json b/test/fixtures/guards/check-compile-autoload.sh/bad-help/package.json
new file mode 100644
index 0000000000..b2e92b4a78
--- /dev/null
+++ b/test/fixtures/guards/check-compile-autoload.sh/bad-help/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "fixture-bad-help",
+ "scripts": {
+ "build": "bun build --compile --no-compile-autoload-bunfig --outfile bin/tool src/cli.ts"
+ }
+}
diff --git a/test/fixtures/guards/check-compile-autoload.sh/bad-help/src/cli/command-table.ts b/test/fixtures/guards/check-compile-autoload.sh/bad-help/src/cli/command-table.ts
new file mode 100644
index 0000000000..5cedecea60
--- /dev/null
+++ b/test/fixtures/guards/check-compile-autoload.sh/bad-help/src/cli/command-table.ts
@@ -0,0 +1,5 @@
+// Known-bad: a computed help specifier is dropped from a compiled binary.
+const name = 'example';
+export const CLI_COMMANDS = [
+ { name: 'example', help: () => import(`./help/${name}.ts`), load: () => import('./commands/example.ts') },
+];
diff --git a/test/fixtures/guards/check-compile-autoload.sh/bad-help/src/cli/commands/example.ts b/test/fixtures/guards/check-compile-autoload.sh/bad-help/src/cli/commands/example.ts
new file mode 100644
index 0000000000..c57a8be4d8
--- /dev/null
+++ b/test/fixtures/guards/check-compile-autoload.sh/bad-help/src/cli/commands/example.ts
@@ -0,0 +1 @@
+export async function run(): Promise<void> {}
diff --git a/test/fixtures/guards/check-compile-autoload.sh/bad-help/src/cli/help/example.ts b/test/fixtures/guards/check-compile-autoload.sh/bad-help/src/cli/help/example.ts
new file mode 100644
index 0000000000..cce5cb47ac
--- /dev/null
+++ b/test/fixtures/guards/check-compile-autoload.sh/bad-help/src/cli/help/example.ts
@@ -0,0 +1 @@
+export const help = { summary: 'x', usage: 'gbrain example', flags: [], examples: [] };