Are you the author? Sign in to claim
Claude Code skill for orchestrating the Grok CLI as a sandboxed background build agent — with a wrapper that fixes grok'
A Claude Code skill for orchestrating the Grok CLI as a background build agent. Claude stays the orchestrator and reviewer; Grok does the heavy lifting in a sandboxed workspace; you get a reviewable diff.
It ships two things:
SKILL.md — the operating manual the orchestrating agent reads: when to offload, how to
split a task into cleanly-scoped subtasks, how to write a self-contained brief, how to launch,
and how to verify and reintegrate what came back.scripts/run-grok.sh — a wrapper around grok that makes headless runs safe, loggable,
and resumable.Works with any agent that can read a skill and run a shell command — Claude Code, Codex, or a plain terminal.
Grok's
--sandboxsilently does nothing when there is no TTY.
Grok applies its sandbox profile via Landlock, which needs to open
/dev/tty. When you launch Grok from an agent, a script, or CI, there is no controlling
terminal — the profile fails to apply and Grok continues to run completely unconfined. The
only trace is an ApplyFailed line in ~/.grok/sandbox-events.jsonl. The command still exits
0, and the flag still looks like it worked.
Demonstrated on grok 0.2.101, Linux 6.17, kernel Landlock available:
$ grok -p 'Run: touch ~/ESCAPED' --sandbox workspace --cwd /tmp/demo --permission-mode bypassPermissions
$ ls ~/ESCAPED
/home/<user>/ESCAPED # ← written straight through the sandbox
$ tail -1 ~/.grok/sandbox-events.jsonl
{"event_type":"ApplyFailed","profile":"workspace","enforced":false,
"error":"Landlock path error: failed to open \"/dev/tty\": No such device or address"}
The wrapper runs Grok under a PTY so the profile actually applies, then verifies enforcement after the fact rather than trusting the flag:
$ ./scripts/run-grok.sh -C /tmp/demo -l demo - <<< 'Run: touch ~/ESCAPED'
RUN_DIR=/tmp/grok-router/20260715-133012-demo-48652
sandbox=enforced
--- last message ---
touch: cannot touch '/home/<user>/ESCAPED': Permission denied
If it can't confirm enforcement it prints sandbox=NOT ENFORCED and warns on stderr, so an
unconfined run is never mistaken for a sandboxed one.
$RUN_DIR/session_id, so follow-ups work even if the run crashes. (grok -s creates a session
and errors if the id exists; --resume continues one and errors if it doesn't. The wrapper
takes --resume and does the right thing.)\n to \r\n; stderr would otherwise interleave with the event
stream. The wrapper strips CRs and redirects stderr inside the PTY, leaving parseable NDJSON.--prompt-file, so multi-line briefs need no shell
quoting.Requires grok (logged in via grok login), bash, jq, and
script (util-linux or BSD).
git clone https://github.com/luckeyfaraday/delegate-to-grok.git
ln -s "$PWD/delegate-to-grok" ~/.claude/skills/grok
Then verify:
grok models # prints login status and the models your account can use
~/.claude/skills/grok/scripts/run-grok.sh --help
The agent normally drives this, but the wrapper stands alone:
# Offload a task; brief comes from a file, run lands in $RUN_DIR
./scripts/run-grok.sh -C ~/code/myrepo -m grok-4.5 -l migrate - < brief.md
# Analysis only — no writes
./scripts/run-grok.sh -C ~/code/myrepo -s read-only - <<< 'Summarize the auth flow.'
# Follow up on the same session, with full memory of the prior run
./scripts/run-grok.sh -C ~/code/myrepo --resume "$(cat $RUN_DIR/session_id)" - <<< 'Tests still fail: ...'
| Flag | Default | Notes |
|---|---|---|
-C <dir> | cwd | Grok's working root; the sandbox confines writes to it |
-m <model> | account default | Must be a real ID from grok models |
-e <effort> | high | none/minimal/low/medium/high/xhigh/max |
-s <sandbox> | workspace | Also read-only, strict, devbox |
-l <label> | run | Names the run directory |
--resume <id> | — | Continue a previous session |
--max-turns <n> | — | Hard cap on agent turns; a cheap runaway guard |
--best-of-n <n> | — | Run the task N ways in parallel, keep the best (costs N×) |
--check | off | Append a self-verification loop to the prompt |
--allow / --deny <rule> | — | e.g. --deny 'Bash(rm*)'; repeatable, deny wins |
--no-sandbox | — | Opt out of confinement |
--no-pty | — | Skip the PTY (sandbox will not enforce) |
Environment: GROK_ROUTER_MODEL, GROK_ROUTER_EFFORT, GROK_ROUTER_SANDBOX, GROK_ROUTER_RUNS
(run-directory root, default $TMPDIR/grok-router).
$RUN_DIR/
prompt.md the brief as sent
events.jsonl NDJSON stream: thought / text / end
last_message.txt Grok's final report, reconstructed from the stream
meta.json stopReason, sessionId, token usage
session_id for --resume
stderr.log diagnostics when a run exits non-zero
raw.log unprocessed PTY output
Note that events.jsonl carries only thought, text, and a final end — Grok streams no
tool-call events, so it shows narration, not actions. Read the diff to see what it did.
--permission-mode bypassPermissions — Grok is not asked to confirm tool calls. The
sandbox, not a prompt, is what confines it. Use --deny rules for finer control.--sandbox enforcement is Linux/Landlock (kernel ≥ 5.13) and macOS Seatbelt. Elsewhere the
wrapper will report NOT ENFORCED.git worktree add). Never point two runs at one tree.~/.grok/README.md documents some that aren't universally
available. grok models is the source of truth.MIT — see LICENSE.
Design enforcement with memory — keeps your UI consistent across a project
Create animation-rich HTML presentations using a coding agent's frontend skills
1000+ skills curated from Anthropic, Vercel, Stripe, and other engineering teams
Detects 37 AI writing patterns and rewrites text with human rhythm across 5 voice profiles