Start a Codex or Grok agent from Bash as a head. Use before running `codex exec`, `codex` or `grok` yourself outside the lane workflow, and whenever a sandbox, a linked worktree or its gitdir blocks a commit, fetch or merge.
Install
npx skillscat add overnightworks/marketplace/providers Install via the SkillsCat registry.
Starting Codex and Grok from a head
This skill owns the command lines, sandbox modes and output capture for the CLI
versions below. The lane workflow's own Codex gate is not covered here. Never
read auth files. $WT is the agent's worktree, $BRIEF its brief, $OUT its
output file; $BRIEF and $OUT are absolute paths, because Grok resolves a
relative --prompt-file against --cwd.
Every $BRIEF a head writes for Codex or Grok opens with the delegated line
the global contract gives (docs/contract/CONTRACT.md, "Head or helper"), so the
agent does not take itself for a head and run the session-start routine.
Version check and smoke check
Proven with codex-cli 0.163.0 and grok 1.0.60; read the installed versions withcodex --version and grok --version. On any other version, run the smoke
check before relying on a command; do not guess. Create the scratch repo with
its linked worktree outside /tmp and the profile's default-writable paths, for
example under ~/.cache; under /tmp a write to <commondir>/hooks succeeds
and the check misleads. A writer setup must commit and merge an already-fetchedorigin/<trunk>, must fail to write <commondir>/config and<commondir>/hooks, and must fail git ls-remote <network remote> HEAD. Test a
write (: >> <commondir>/config), not a touch of the existing file: under
Grok touch exits 0 on a sound writer. A local bare origin proves only gitdir
and refs writes, not network. A reviewer's smoke check is only that a write
to a tracked file in the worktree fails; it needs no commit, merge or network test.
Codex reviewer (read-only)
Model and effort come from the head contract's section "Model routing"
(docs/contract/HEAD.md) if installed (the row for the work, the Codex column;
the effort the cell gives); otherwise use the operator's stated model and effort, or
ask. Never guess. $MODEL and $EFFORT below are those values.
codex exec -s read-only -C "$WT" -m "$MODEL" -c model_reasoning_effort="$EFFORT" \
-o "$OUT" - < "$BRIEF"The prompt comes on stdin from $BRIEF; the answer lands in $OUT. Run it in
the foreground, or detached with its exit status written to a marker file ascodexReview in plugins/atelier/lane/review.js does. A reviewer never gets
the writer's permission profile.
A read-only reviewer runs no tests: uv cannot write its cache lock on the
read-only filesystem, and a .venv fallback can stall. Its brief says "do not
run tests"; its verdict is a reading review that the builder's targeted run and
CI complete.
The sandbox has no network and cannot write, /tmp included: $BRIEF carries
the item body, the diff range and the verification evidence (commands, exit
codes, proving lines, CI state) inline, and says that a command the sandbox
cannot run is reported as not verified, never as a blocking finding.
Codex writer in a linked worktree
Since Codex 0.158, a linked worktree's gitdir is read-only under-s workspace-write, even inside writable_roots. Use a permission profile that
names the gitdir explicitly instead:
GITDIR=$(git -C "$WT" rev-parse --absolute-git-dir)
COMMONDIR=$(git -C "$WT" rev-parse --path-format=absolute --git-common-dir)
codex exec -C "$WT" \
-c 'default_permissions="lane"' \
-c 'permissions.lane.extends=":workspace"' \
-c "permissions.lane.filesystem={\"$GITDIR\"=\"write\",\"$COMMONDIR/objects\"=\"write\",\"$COMMONDIR/refs\"=\"write\",\"$COMMONDIR/logs\"=\"write\"}" \
...The writer's tail has no -s (the profile is the sandbox), then-m "$MODEL", -c model_reasoning_effort="$EFFORT", -o "$OUT" and the prompt
on stdin, as in the reviewer line.
- The filesystem table must be one inline-TOML value: a dotted
-ckey splits on
the dots inside.gitpaths and fails with "must be absolute". - The writer sandbox has no network:
git ls-remote https://...fails with
"Could not resolve host", sogit fetchandgit pushagainst a network
remote fail. The head fetches outside the sandbox before starting the writer
and pushes after it; the writer merges the already-presentorigin/<trunk>
(a plaingit merge origin/<trunk>). - Commit and merge work. Writes to
<commondir>/config,<commondir>/hooksand
new files in the common-dir root fail. git branch -Dandgit pack-refsfail (they need<commondir>/packed-refs.lock); branch cleanup stays with the head.
Grok read-only run
This run supplies facts or execution evidence to an eligible reviewer; it does not issue a review or gate verdict.
grok --cwd "$WT" --sandbox read-only --always-approve -m grok-4.6 --effort "$EFFORT" \
--output-format json --max-turns 40 --prompt-file "$BRIEF" > "$OUT" 2> "$OUT.err"
jq -r .text "$OUT"- Always pass
--effort:~/.grok/config.tomldefaults toxhighandpermission_mode = "always-approve".grok --helplists no valid values for--effort(alias--reasoning-effort), so the values are unverified: take the
level fromdocs/contract/HEAD.md's "Model routing" table if installed, defaulthigh. --sandboxtakes a profile name (grok --helpshows a free-form<PROFILE>);read-onlyandworkspaceare unverified as built-ins beyond the smoke check
above, so run that check before relying on either.--json-schema '<schema>'works and implies json output.- A helper does not print
Contract loaded.; a.textthat carries the line
is reported to the head. Inspect the reported evidence, not just the first
line.
Grok writer in a linked worktree
The built-in --sandbox workspace cannot commit: it denies index.lock in<commondir>/worktrees/<name>. Use a custom profile in <wt>/.grok/sandbox.toml
(untracked; a builder must not commit it):
[profiles.worktree-writer]
extends = "workspace"
restrict_network = true
read_write = ["<commondir>/objects", "<commondir>/refs", "<commondir>/logs", "<commondir>/worktrees/<name>"]<name> is the basename of $GITDIR, not of the worktree directory.
Run with --sandbox worktree-writer, the read-only command's other flags and a higher--max-turns. Append, git add and git commit work; writing<commondir>/hooks fails. Like the Codex writer, the Grok writer has no network
(restrict_network = true): git ls-remote https://... fails with "Could not
resolve host". The head fetches before starting the writer and pushes after it;
the writer merges the already-present origin/<trunk>.
Waiting, capturing, judging
- Judge completion by the process exit status (or an exit-status marker file
written after the command, ascodexReviewdoes), never by the output file
existing. - Codex: capture the answer with
-o <out>. Grok:jq -r .text "$OUT". - A Grok failure exits 1 with a JSON error on stdout (stderr repeats it).
- Judge the exit status first, then the answer; a zero exit with an empty answer
is a failed step.
Named risks
- Both writer setups make
<commondir>/refswritable, so a builder can move any
local branch, includingmainandrefs/aco/state. Run landing and claim
checks outside the sandbox. - Grok's
workspaceandread-onlyprofiles can write~/.grok, and the custom
profile file sits in the worktree, so a sandboxed Grok can edit the profile its
next run reads. --always-approvemakes the sandbox Grok's only control.
Unproven
--permission-mode defaultoverriding the config in headless mode (it appeared
not to).--effort highon grok-4.6 (the default this skill gives).~/.grok/sandbox.tomlas the profile home.acocommands from inside either sandbox.