Codex agent

From diegosouzapw/awesome-omni-skill · View interactive version

Codex agent is an AI agent skill from the GitHub repository diegosouzapw/awesome-omni-skill. Invoke OpenAI Codex CLI for coding and complex tasks. ALWAYS use the codex_agent_direct TOOL — NEVER exec codex directly. Direct codex exec opens an interactive TUI that hangs and gets killed. The tool handles non-interactive execution correctly.

How to use this skill

Skill file

Codex Agent — Direct Tool

CRITICAL: NEVER run exec codex ... directly. Running codex without the tool opens an interactive TUI that hangs and gets killed with signal 9. Always use the codex_agent_direct tool below.

Use your own model first. Only delegate to Codex when the user explicitly asks, or the task is large/multi-file.

Primary Method: `codex_agent_direct` Tool

The codex_agent_direct tool invokes Codex CLI non-interactively (codex exec) with structured JSON output. This is the preferred method for all Codex interactions.

codex_agent_direct(
  prompt: "Your detailed task description",
  workspace: "/path/to/project",    // optional, passed as --cd
  model: "gpt-4.1-mini",            // optional, default "gpt-4.1-mini"
  mode: "agent" | "plan" | "ask"    // optional, default "agent"
)

Modes

When to Use

Model Selection

| Model | Use when |

|---|---|

| gpt-4.1-mini | Default — fast, capable, cost-effective |

| gpt-4.1 | Complex reasoning, large codebases |

| gpt-5.3-codex | Maximum capability (requires ChatGPT Pro/Plus auth) |

Output

The tool returns structured JSON:

There Is No Fallback — Handle Errors Directly

DO NOT exec codex under any circumstances. Running codex or exec codex ... opens an interactive TUI that hangs forever and gets killed with signal 9. There is no safe direct exec fallback.

When the tool returns `ok: false` or an error:

  1. Read the error or output field — it contains the failure reason (e.g. "not a trusted directory", "model not found")
  2. Report it to the user directly — e.g. "Codex failed: [reason]. You may need to run codex interactively first to trust this directory."
  3. Do NOT retry with exec, sessions_spawn, process polling, or any other approach
  4. Do NOT start a background process and poll it

When the tool returns empty output:

Report to the user: "Codex returned no output. The workspace may not be a trusted git repo, or Codex may need re-authentication."

When output is raw JSONL:

The tool parses JSONL and returns clean text. If you still see raw {"type":...} JSON in the output, just summarize what you can see and tell the user the response format was unexpected.

Common errors and what to tell the user:

| Error | Tell user |

|---|---|

| Not inside a trusted directory | Run codex interactively in the workspace first to trust it, or pass --skip-git-repo-check |

| model not supported | Your ChatGPT account uses gpt-5.3-codex — omit --model to use config default |

| stream disconnected | Codex authentication may have expired — run codex interactively to re-login |

| signal 9 / process killed | The codex TUI was opened instead of non-interactive exec — this means exec was called directly, which is forbidden |

Prerequisites

Project Config

The project includes .codex/config.toml with sensible defaults:

Override per-run with --model or --approval flags.

Do NOT

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.