Agent skill
session-codex
Use when delegating a task to Codex CLI with session persistence across turns.
Install this agent skill to your Project
npx add-skill https://github.com/vre/flow-state/tree/main/session-codex
SKILL.md
Codex Session
Direct (review, analysis, quick edits — no git)
First run:
codex exec --json --full-auto "prompt"
Following runs:
codex exec resume --json --full-auto ${THREAD_ID} "follow-up prompt"
Worktree (implementation — sandboxed with git)
Claude prepares worktree with .git rename to bypass Codex's hardcoded .git denylist:
git worktree add .worktrees/${NAME} -b ${NAME} main- Copy
.env*files, runuv syncwhere needed - Rename git directory and create pointer:
mv .worktrees/${NAME}/.git .worktrees/${NAME}/.git-codex-sandbox-workaround
printf 'gitdir: .git-codex-sandbox-workaround\n' > .worktrees/${NAME}/.git
Prepend to every prompt: "IMPORTANT: Git data is at .git-codex-sandbox-workaround. Prefix ALL git commands with GIT_DIR=.git-codex-sandbox-workaround."
First run:
codex exec --json -s workspace-write -c 'approval_policy="never"' -C .worktrees/${NAME} "${PROMPT}"
Following runs (resume does not support -s/-C, use -c for config overrides):
codex exec resume --json -c 'sandbox_permissions=["disk-full-read-access","disk-write-access"]' -c 'approval_policy="never"' ${THREAD_ID} "${PROMPT}"
Response parsing
Parse first JSONL line: {"type":"thread.started","thread_id":"<id>"} → set ${THREAD_ID}.
Response: lines where item.type == "agent_message" → item.text.
If Codex returns error or empty output: show stderr, STOP. Use Bash timeout >= 300000 for long-running tasks.
Security
workspace-write sandbox is kernel-enforced (Seatbelt/Landlock): writes restricted to CWD + subdirs, network blocked. The .git rename bypasses the hardcoded denylist while keeping filesystem isolation. This is safer than danger-full-access which has no restrictions at all.
Didn't find tool you were looking for?