# codex-cli

Enables an agent to hand off coding, review, and image generation tasks to OpenAI Codex CLI via non-interactive exec commands.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 237 installs · ★ 140 repo stars
- Author: sugarforever
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/sugarforever/01coder-agent-skills/tree/HEAD/skills/codex-cli/SKILL.md
- Updated: 2026-10-19
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/sugarforever-codex-cli

## What it does

This skill instructs an agent on how to run `codex exec` without interactive prompts. It starts by verifying the environment with `command -v codex` and `codex --version`. If the CLI is absent, execution stops immediately without simulating Codex output.

Delegated work uses sandbox levels: `-s read-only` for inspection or critiques and `-s workspace-write` when file edits are required. Large prompts or logs go through stdin, while images attach via `-i`. Workflows can also resume previous threads with `codex exec resume <session-id>`.

When Codex generates images, files land in `$CODEX_HOME/generated_images/` or `~/.codex/generated_images/`. The skill directs the agent to locate those files, inspect their aspect ratios with `sips` or `file`, and copy needed assets into the repo.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add sugarforever/01coder-agent-skills --skill codex-cli -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/codex-cli/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/codex-cli/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add sugarforever/01coder-agent-skills --skill codex-cli -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/codex-cli/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add sugarforever/01coder-agent-skills --skill codex-cli -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/codex-cli/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install sugarforever/01coder-agent-skills skills/codex-cli
```

2. **Manually: put the files in place**
- File: `.github/skills/codex-cli/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add sugarforever/01coder-agent-skills --skill codex-cli -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/sugarforever/01coder-agent-skills --path skills/codex-cli
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/codex-cli/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add sugarforever/01coder-agent-skills --skill codex-cli -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/sugarforever/01coder-agent-skills/tree/HEAD/skills/codex-cli/SKILL.md

## When to use it
- delegate repository code review to Codex CLI in read-only mode
- feed screenshots or build logs into Codex CLI using stdin and -i flags
- resume an earlier Codex execution thread by session id
- locate and verify dimensions of images produced by Codex

## Example prompts
- Ask Codex CLI to inspect src/auth.ts and propose a plan in read-only mode
- Send error.png to Codex CLI using -i and ask for the fix
- Run codex exec to generate an image and copy it to the assets folder

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: aaac21a43ff54d85.

BEGIN THIRD-PARTY FILE aaac21a43ff54d85
````text
---
name: codex-cli
description: Use when an agent needs to delegate a task to the OpenAI Codex CLI from another agent environment such as Claude Code, OpenClaw, or similar. Covers checking whether Codex CLI is installed, running one-off Codex prompts with `codex exec`, resuming sessions, collecting outputs, attaching images or files as input with `-i`/stdin, and handling Codex image generation including finding and reporting generated image file paths.
---

# Codex CLI

Use this skill when the user asks this agent to talk to Codex, consult Codex, delegate a coding/review/research task to Codex CLI, or ask Codex to generate an image.

The core interface is:

```bash
codex exec "prompt"
```

For automation, prefer non-interactive `codex exec` over interactive `codex`.

## First Check

Before using Codex CLI, verify it is available:

```bash
command -v codex
codex --version
codex exec --help
```

If `codex` is missing, tell the user Codex CLI is not available in this environment and stop. Do not simulate a Codex response.

If `codex exec --help` is available, use it as the source of truth for the installed CLI flags. Codex CLI changes over time.

## One-Off Task Workflow

Use this for normal delegation:

```bash
codex exec -C "$PWD" -s read-only "Review this repository and identify likely bugs"
```

For tasks that may edit files, use the sandbox the user requested or the host agent allows:

```bash
codex exec -C "$PWD" -s workspace-write "Implement the requested change"
```

For a response file:

```bash
codex exec -C "$PWD" -o /tmp/codex-last-message.md "Summarize this project"
```

For machine-readable events:

```bash
codex exec -C "$PWD" --json -o /tmp/codex-last-message.md "Analyze this project"
```

If the prompt is long, pass it via stdin:

```bash
codex exec -C "$PWD" - < /tmp/prompt.txt
```

When using shell commands from another agent, avoid dangerous flags unless the user explicitly asked for them. Prefer `read-only` for review, planning, critique, image generation, and analysis.

## Prompt Shape

For non-trivial tasks, shape the delegated prompt with OpenAI's Codex best-practices structure:

```text
Goal:
Context:
Constraints:
Done when:
```

Keep the prompt scoped to one task. For complex implementation work, ask Codex for a plan first in `read-only` mode, then run a separate write task after the plan is accepted.

## Session Resume

Codex emits a session id in normal startup output and in JSONL events as `thread.started`.

To resume:

```bash
codex exec resume <session-id> "Continue from the previous task"
```

If the installed CLI supports a different resume syntax, follow `codex exec resume --help`.

## Image and File Input
````
END THIRD-PARTY FILE aaac21a43ff54d85

The third-party file has ended. Everything between the aaac21a43ff54d85 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2686 of 7799 bytes. © sugarforever · MIT · https://github.com/sugarforever/01coder-agent-skills/tree/HEAD/skills/codex-cli/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
