grok-build-init
Initialize grok-build (v1.0+) on a host with the karlorz subagent harness:
custom user-scope agents, global routing rules, the BYOK model/config layer,
and the companion plugin set. The skill runs scripts/install.sh from this
plugin; it is idempotent and backup-first.
Prerequisites
python3 on PATH (installer scripts).
git on PATH (marketplace clone), unless you pass --skip-plugins.
grok installed, authenticated, and runnable: grok --version must succeed.
On musl/Alpine, a glibc grokgod binary often cannot exec; use a musl grok
(often $GROK_HOME/downloads/grok-linux-*) and do not leave PATH pointing
at a broken grokgod shim. The installer will not rewrite that shim.
On the fresh host, this plugin itself must be installed first:
grok plugin marketplace add karlorz/agent-skills
grok plugin install grok-build-harness --trust
Then start a new session (or press r in the Plugins tab) and run
/grok-build-init.
Remote / SSH hosts
Do not allocate a TTY and run unknown grok words such as grok whoami.
Grok 1.0.x treats those as a chat turn and opens the TUI. Health checks:
grok --version
grok inspect --json
grok plugin list
Locate install.sh (below) and run it directly:
bash "$INSTALL" --hub-key "$HUB_KEY" --new-key "$NEW_KEY" --context7-key "$CTX7_KEY" --verify -y
Locating install.sh
The installer ships with this plugin at scripts/install.sh. Resolve it from
the installed plugin root:
INSTALL="$(find ~/.grok/installed-plugins -maxdepth 3 -type f -name install.sh -path '*grok-build-harness*' | head -1)"
or from the agent-skills repo checkout: skills/grok-build-harness/scripts/install.sh.
Procedure
Update the plugin and locate installer: On an existing install, refresh the plugin and find install.sh:
grok plugin update grok-build-harness
INSTALL="$(find ~/.grok/installed-plugins -maxdepth 3 -type f -name install.sh -path '*grok-build-harness*' | head -1)"
Collect API keys from the user (or read HARNESS_HUB_KEY,
HARNESS_NEW_KEY, HARNESS_CONTEXT7_KEY). Two gateway keys
(hub.karldigi.dev, new.karldigi.dev) and the context7 MCP key. If the user
declines, install continues env-only — the generated config keeps
env_key lines so HUB_API_KEY exports work.
Run the installer with the keys and any skip flags the user wants:
bash "$INSTALL" --hub-key "$HUB_KEY" --new-key "$NEW_KEY" --context7-key "$CTX7_KEY" --verify
Optional flags: --skip-codex, --skip-vault-sync, --skip-playwright-cli
(heavy or host-specific plugins); --require-keys (hard-fail when hub/new
gateway keys are missing — use for unattended runs); --restrictive
(render permission_mode = "plan" instead of "always-approve" for
shared hosts); --with-grokgod / --skip-grokgod (force or skip grokgod
[plan_mode] implement_via_subagents = true merge; auto-detected by default);
--strict (fail verify if config has unexpected top-level keys);
--force-render (rewrite an existing keyed config env-only
when no keys are provided — the default is to skip the config render
instead, to avoid silently downgrading a working keyed config); --dry-run
to preview without writing; --no-config to skip config.toml. When keys
are missing the installer always warns that the config will be env-only
(model aliases won't resolve until HARNESS_HUB_KEY / HARNESS_NEW_KEY
are exported).
Verify (installer's --verify step): grok plugin list --json shows
the 14 enabled plugins (13 companions + grok-build-harness itself), grok inspect --json reports agents discovered
(asserts grok-build-byok with a path under $GROK_HOME/agents/; Grok 1.0.5
may label that source.type=project and 1.0.12 user — type is ignored), stamp file is inspected,
config does not pair [agent] name = grok-build-byok with agent_type = "codex",
schema-checks config.toml across template-owned, docs-known, and runtime extras layers
(validating consent extra while protecting PII; fails on unexpected tables with --strict),
and verifies no unresolved key tokens in config.toml.
Finish: tell the user to start a new session so ~/.grok/AGENTS.md and
the agents load. The skillwiki activation file (~/.grok/skillwiki.md and
the AGENTS.md marker block) is owned by the llm-wiki plugin's
install:activation — the harness installer preserves any existing marker;
no manual step needed.
What gets installed
Path (under ~/.grok/) |
Content |
agents/grok-build-byok.md, agents/scout.md |
Custom parent agent + disposable read-only scout (verbatim) |
agentrules.md |
Global subagent routing/workflow rules (verbatim) |
AGENTS.md |
Subagent contract in a <!-- grok-build-harness:begin/end --> block — spliced in: all other content (user sections, skillwiki marker) is preserved |
config.toml |
Rendered from the sanitized template: model aliases (sonnet/haiku → deepseek-v4-flash-max via hub), [subagents.models] pins, [subagents.toggle] grok-build-byok = false, [agent] name, plugin enable list, context7 MCP |
.grok-build-harness-stamp.json |
Harness install stamp (grok-build-harness-stamp/v1): plugin version, root, install timestamp, and grokgod detection |
Existing files are backed up to
~/.grok/backups/grok-build-harness-<timestamp>/ before overwrite; identical
files are skipped. Re-runs preserve host-set config keys the template does
not emit ([plugins].disabled, extra marketplace sources, extra tables),
and a re-run with no keys over a keyed config skips the render (use
--force-render to override).
Troubleshooting
Harness rules not active → confirm ~/.grok/AGENTS.md + agentrules.md
exist and start a new session.
Plugin skills missing → grok plugin list; add the name to
[plugins].enabled or press Space in the Plugins tab; reload with r.
Hooks/MCP servers inactive → plugins were installed without trust;
reinstall with --trust (grok plugin uninstall <name> --confirm && grok plugin install <name> --trust).
Models don't resolve ("sonnet" unknown) → the [model.*] aliases are
missing or keys were not injected; re-run install.sh with keys, or export
HUB_API_KEY / NEW_API_KEY (env_key fallback).
grok --version fails on Alpine/musl → the grokgod/glibc binary cannot
exec. Point grok at a musl build; do not rewrite the shim via this installer.
SSH session opened a grok TUI → a TTY plus an unknown subcommand (e.g.
whoami) is a chat turn. Use install.sh and grok --version / inspect.
Test without touching the host →
GROK_HOME=/tmp/grok-home bash "$INSTALL" --dry-run
GROK_HOME relocates the whole grok tree; grok inspect against the scratch
home validates the generated config safely.
References
- Design and rationale:
docs/harness-design.md in this plugin.
- Config semantics:
~/.grok/docs/user-guide/05-configuration.md,
09-plugins.md, 16-subagents.md.
1---2name: grok-build-init3description: Bootstrap grok-build with the karlorz subagent harness and companion plugins. Use when initializing grok-build on a new host.4---56# grok-build-init78Initialize grok-build (v1.0+) on a host with the karlorz subagent harness:9custom user-scope agents, global routing rules, the BYOK model/config layer,10and the companion plugin set. The skill runs `scripts/install.sh` from this11plugin; it is idempotent and backup-first.1213## Prerequisites1415- `python3` on PATH (installer scripts).16- `git` on PATH (marketplace clone), unless you pass `--skip-plugins`.17- `grok` installed, authenticated, and **runnable**: `grok --version` must succeed.18 On musl/Alpine, a glibc grokgod binary often cannot exec; use a musl grok19 (often `$GROK_HOME/downloads/grok-linux-*`) and do **not** leave PATH pointing20 at a broken grokgod shim. The installer will not rewrite that shim.21- On the fresh host, this plugin itself must be installed first:2223 ```bash24 grok plugin marketplace add karlorz/agent-skills25 grok plugin install grok-build-harness --trust26 ```2728 Then start a new session (or press `r` in the Plugins tab) and run29 `/grok-build-init`.3031### Remote / SSH hosts3233Do **not** allocate a TTY and run unknown `grok` words such as `grok whoami`.34Grok 1.0.x treats those as a chat turn and opens the TUI. Health checks:3536```bash37grok --version38grok inspect --json39grok plugin list40```4142Locate `install.sh` (below) and run it directly:4344```bash45bash "$INSTALL" --hub-key "$HUB_KEY" --new-key "$NEW_KEY" --context7-key "$CTX7_KEY" --verify -y46```4748## Locating install.sh4950The installer ships with this plugin at `scripts/install.sh`. Resolve it from51the installed plugin root:5253```bash54INSTALL="$(find ~/.grok/installed-plugins -maxdepth 3 -type f -name install.sh -path '*grok-build-harness*' | head -1)"55```5657or from the agent-skills repo checkout: `skills/grok-build-harness/scripts/install.sh`.5859## Procedure60611. **Update the plugin and locate installer**: On an existing install, refresh the plugin and find `install.sh`:6263 ```bash64 grok plugin update grok-build-harness65 INSTALL="$(find ~/.grok/installed-plugins -maxdepth 3 -type f -name install.sh -path '*grok-build-harness*' | head -1)"66 ```67682. **Collect API keys from the user** (or read `HARNESS_HUB_KEY`,69 `HARNESS_NEW_KEY`, `HARNESS_CONTEXT7_KEY`). Two gateway keys70 (hub.karldigi.dev, new.karldigi.dev) and the context7 MCP key. If the user71 declines, install continues env-only — the generated config keeps72 `env_key` lines so `HUB_API_KEY` exports work.733. **Run the installer** with the keys and any skip flags the user wants:7475 ```bash76 bash "$INSTALL" --hub-key "$HUB_KEY" --new-key "$NEW_KEY" --context7-key "$CTX7_KEY" --verify77 ```7879 Optional flags: `--skip-codex`, `--skip-vault-sync`, `--skip-playwright-cli`80 (heavy or host-specific plugins); `--require-keys` (hard-fail when hub/new81 gateway keys are missing — use for unattended runs); `--restrictive`82 (render `permission_mode = "plan"` instead of `"always-approve"` for83 shared hosts); `--with-grokgod` / `--skip-grokgod` (force or skip grokgod84 `[plan_mode] implement_via_subagents = true` merge; auto-detected by default);85 `--strict` (fail verify if config has unexpected top-level keys);86 `--force-render` (rewrite an existing keyed config env-only87 when no keys are provided — the default is to skip the config render88 instead, to avoid silently downgrading a working keyed config); `--dry-run`89 to preview without writing; `--no-config` to skip config.toml. When keys90 are missing the installer always warns that the config will be env-only91 (model aliases won't resolve until `HARNESS_HUB_KEY` / `HARNESS_NEW_KEY`92 are exported).934. **Verify** (installer's `--verify` step): `grok plugin list --json` shows94 the 14 enabled plugins (13 companions + grok-build-harness itself), `grok inspect --json` reports agents discovered95 (asserts `grok-build-byok` with a path under `$GROK_HOME/agents/`; Grok 1.0.596 may label that `source.type=project` and 1.0.12 `user` — type is ignored), stamp file is inspected,97 config does not pair `[agent] name = grok-build-byok` with `agent_type = "codex"`,98 schema-checks `config.toml` across template-owned, docs-known, and runtime extras layers99 (validating consent extra while protecting PII; fails on unexpected tables with `--strict`),100 and verifies no unresolved key tokens in config.toml.1015. **Finish**: tell the user to start a new session so `~/.grok/AGENTS.md` and102 the agents load. The skillwiki activation file (`~/.grok/skillwiki.md` and103 the `AGENTS.md` marker block) is owned by the llm-wiki plugin's104 `install:activation` — the harness installer preserves any existing marker;105 no manual step needed.106107## What gets installed108109| Path (under `~/.grok/`) | Content |110|---|---|111| `agents/grok-build-byok.md`, `agents/scout.md` | Custom parent agent + disposable read-only scout (verbatim) |112| `agentrules.md` | Global subagent routing/workflow rules (verbatim) |113| `AGENTS.md` | Subagent contract in a `<!-- grok-build-harness:begin/end -->` block — spliced in: all other content (user sections, skillwiki marker) is preserved |114| `config.toml` | Rendered from the sanitized template: model aliases (sonnet/haiku → deepseek-v4-flash-max via hub), `[subagents.models]` pins, `[subagents.toggle] grok-build-byok = false`, `[agent] name`, plugin enable list, context7 MCP |115| `.grok-build-harness-stamp.json` | Harness install stamp (`grok-build-harness-stamp/v1`): plugin version, root, install timestamp, and grokgod detection |116117Existing files are backed up to118`~/.grok/backups/grok-build-harness-<timestamp>/` before overwrite; identical119files are skipped. Re-runs preserve host-set config keys the template does120not emit (`[plugins].disabled`, extra marketplace sources, extra tables),121and a re-run with no keys over a keyed config skips the render (use122`--force-render` to override).123124## Troubleshooting125126- **Harness rules not active** → confirm `~/.grok/AGENTS.md` + `agentrules.md`127 exist and start a new session.128- **Plugin skills missing** → `grok plugin list`; add the name to129 `[plugins].enabled` or press `Space` in the Plugins tab; reload with `r`.130- **Hooks/MCP servers inactive** → plugins were installed without trust;131 reinstall with `--trust` (`grok plugin uninstall <name> --confirm &&132 grok plugin install <name> --trust`).133- **Models don't resolve ("sonnet" unknown)** → the `[model.*]` aliases are134 missing or keys were not injected; re-run install.sh with keys, or export135 `HUB_API_KEY` / `NEW_API_KEY` (env_key fallback).136- **`grok --version` fails on Alpine/musl** → the grokgod/glibc binary cannot137 exec. Point `grok` at a musl build; do not rewrite the shim via this installer.138- **SSH session opened a grok TUI** → a TTY plus an unknown subcommand (e.g.139 `whoami`) is a chat turn. Use `install.sh` and `grok --version` / `inspect`.140- **Test without touching the host** →141142 ```bash143 GROK_HOME=/tmp/grok-home bash "$INSTALL" --dry-run144 ```145146 `GROK_HOME` relocates the whole grok tree; `grok inspect` against the scratch147 home validates the generated config safely.148149## References150151- Design and rationale: `docs/harness-design.md` in this plugin.152- Config semantics: `~/.grok/docs/user-guide/05-configuration.md`,153 `09-plugins.md`, `16-subagents.md`.