From 7635ae1ffb6c2e854971ef13daa086bceaeef675 Mon Sep 17 00:00:00 2001 From: Hayden Strickland Date: Sat, 18 Jul 2026 11:03:35 -0500 Subject: [PATCH] grok-implementer: fix two headless-lane footguns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Preflight: retry 'grok models' once before STATUS: unavailable — the CLI prints 'You are not authenticated' when the ~6h access token has lapsed even though the same invocation silently refreshes it, so a single failed check is usually a false negative. 2. Invocation: add scoped --allow 'Bash(*)'. The Grok CLI merges the caller's global ~/.claude/settings.json permission rules into its resolver; terminal exec defaults to 'ask', which headlessly cancels silently (exit 0, no diff). --always-approve stays forbidden. Co-Authored-By: Claude Fable 5 --- agents/grok-implementer.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/agents/grok-implementer.md b/agents/grok-implementer.md index e8fa784..ec163ad 100644 --- a/agents/grok-implementer.md +++ b/agents/grok-implementer.md @@ -17,7 +17,11 @@ First action, always: command -v grok && grok --version && grok models 2>&1 | head -2 ``` -`grok models` prints the login state and default model. If grok is not installed or not authenticated, **stop immediately** and return: +`grok models` prints the login state and default model. + +**"You are not authenticated" is usually a false negative — retry once before giving up.** grok.com access tokens are short-lived (~6h); when one has lapsed, `grok models` prints "You are not authenticated" even though that same invocation silently refreshes the token in the background, so an immediate second call succeeds. If the first check reports not authenticated, run `grok models 2>&1 | head -2` once more. Only two consecutive "not authenticated" results mean a real logout. + +If grok is not installed, or both auth checks fail, **stop immediately** and return: ``` GROK REPORT @@ -55,6 +59,7 @@ T=$(command -v gtimeout || command -v timeout || true) ${T:+$T 600} grok --prompt-file "$SPEC" \ -m grok-4.5 \ --permission-mode acceptEdits \ + --allow 'Bash(*)' \ --output-format plain \ --cwd "$(pwd)" \ > /tmp/grok-final-$$.txt 2>&1 @@ -67,14 +72,15 @@ Flag discipline (non-negotiable): |---|---| | `--prompt-file "$SPEC"` | Headless single-task run from a file. No quoting hazards, no truncated specs. | | `-m grok-4.5` | The lane's producer is Grok 4.5, pinned explicitly — never rely on the CLI default. | -| `--permission-mode acceptEdits` | Grok edits files without prompting, but does not get blanket command approval. Never `--always-approve` — you re-run verification yourself. | +| `--permission-mode acceptEdits` | Grok edits files without prompting. Never `--always-approve` — you re-run verification yourself. | +| `--allow 'Bash(*)'` | Required for headless runs. The Grok CLI merges the caller's global `~/.claude/settings.json` permission rules into its own resolver, and under that merge terminal-command execution defaults to "ask" — which with no human present silently cancels the turn (exit 0, no diff, no error) instead of failing loudly. The scoped allow approves shell execution only; it is not blanket auto-approval. | | `--cwd "$(pwd)"` | Deterministic working root. | | `--output-format plain` | Final message to stdout, captured for the report. | | `${T:+$T 600}` | Ten-minute wall clock when `timeout`/`gtimeout` exists. On timeout, report `STATUS: timeout` with whatever landed. | `-m grok-4.5` is the current top Grok tier — if the caller's spec names a different grok model, use that instead; the slug is a documented default, not a constant. -3. **Verify independently.** Read the diff (`git diff` / `git status`), run the spec's verification command yourself, and read grok's final message from `"$FINAL"`. Grok's claim of success is not evidence; your re-run is. (`acceptEdits` may have blocked grok from running the verification itself — your re-run covers that by design.) +3. **Verify independently.** Read the diff (`git diff` / `git status`), run the spec's verification command yourself, and read grok's final message from `"$FINAL"`. Grok's claim of success is not evidence; your re-run is. ## What you return