home / skills / bear2u / my-skills / codex

codex skill

/skills/codex

This skill helps you run Codex CLI tasks or analyze code with Codex, selecting model and sandbox settings for safe, automated edits.

npx playbooks add skill bear2u/my-skills --skill codex

Review the files below or copy the command above to add this skill to your agents.

Files (1)
skill.md
2.6 KB
---
name: codex
description: Use when the user asks to run Codex CLI (codex exec, codex resume) or references OpenAI Codex for code analysis, refactoring, or automated editing
---

# Codex Skill Guide

## Running a Task
1. Ask the user (via `AskUserQuestion`) which model to run: `gpt-5` or `gpt-5-codex`.
2. Ask the user (via `AskUserQuestion`) which reasoning effort to use: `low`, `medium`, or `high`.
3. Select the sandbox mode required for the task; default to `--sandbox read-only` unless edits or network access are necessary.
4. Assemble the command with the appropriate options:
   - `-m, --model <MODEL>`
   - `--config model_reasoning_effort="<low|medium|high>"`
   - `--sandbox <read-only|workspace-write|danger-full-access>`
   - `--full-auto`
   - `-C, --cd <DIR>`
   - `--skip-git-repo-check`
5. When continuing a previous session, use `codex exec resume --last` via stdin. **IMPORTANT**: When resuming, you CANNOT specify model, reasoning effort, or other flags—the session retains all settings from the original run. Resume syntax: `echo "your prompt here" | codex exec resume --last`
6. Run the command, capture stdout/stderr, and summarize the outcome for the user.

### Quick Reference
| Use case | Sandbox mode | Key flags |
| --- | --- | --- |
| Read-only review or analysis | `read-only` | `--sandbox read-only` |
| Apply local edits | `workspace-write` | `--sandbox workspace-write --full-auto` |
| Permit network or broad access | `danger-full-access` | `--sandbox danger-full-access --full-auto` |
| Resume recent session | Inherited from original | `echo "prompt" \| codex exec resume --last` (no flags allowed) |
| Run from another directory | Match task needs | `-C <DIR>` plus other flags |

## Following Up
- After every `codex` command, immediately use `AskUserQuestion` to confirm next steps, collect clarifications, or decide whether to resume with `codex exec resume --last`.
- When resuming, pipe the new prompt via stdin: `echo "new prompt" | codex exec resume --last`. The resumed session automatically uses the same model, reasoning effort, and sandbox mode from the original session.
- Restate the chosen model, reasoning effort, and sandbox mode when proposing follow-up actions.

## Error Handling
- Stop and report failures whenever `codex --version` or a `codex exec` command exits non-zero; request direction before retrying.
- Before you use high-impact flags (`--full-auto`, `--sandbox danger-full-access`, `--skip-git-repo-check`) ask the user for permission using AskUserQuestion unless it was already given.
- When output includes warnings or partial results, summarize them and ask how to adjust using `AskUserQuestion`.

Overview

This skill runs and manages OpenAI Codex CLI tasks (codex exec, codex resume) for code analysis, refactoring, and automated edits. It guides model and reasoning selection, chooses an appropriate sandbox mode, assembles the correct command flags, and summarizes command output. It enforces safety checks and prompts before high-impact actions.

How this skill works

I ask which Codex model to use (gpt-5 or gpt-5-codex) and which reasoning effort (low, medium, high). I select a sandbox mode (read-only, workspace-write, danger-full-access) and build the codex command with the required flags, then run it and capture stdout/stderr. For resumed sessions I pipe the prompt into codex exec resume --last and avoid changing flags, since resumed sessions keep original settings. After each run I summarize results and ask the next-step question.

When to use it

  • Requesting automated code analysis or linting across codebase
  • Asking for automated edits, refactors, or patch generation
  • Resuming a previous Codex session with additional instructions
  • Running potentially high-impact tasks that require explicit sandbox or permission choices
  • Needing a controlled environment to prevent network or filesystem changes

Best practices

  • Always confirm model (gpt-5 vs gpt-5-codex) and reasoning effort before running commands
  • Default to --sandbox read-only for reviews; escalate only with explicit permission
  • Never change flags when resuming: use echo "prompt" | codex exec resume --last
  • Ask user permission before using --full-auto, --sandbox danger-full-access, or --skip-git-repo-check
  • If a command exits non-zero, stop, report the error, and ask for directions before retrying

Example use cases

  • Read-only code review: run codex exec with --sandbox read-only and summarize findings
  • Apply local edits: use --sandbox workspace-write and --full-auto to let Codex write patches
  • Resume a previous interactive session: echo "next steps" | codex exec resume --last
  • High-trust automated tasks: request explicit permission, then run with --sandbox danger-full-access and --full-auto
  • Run from a different directory: include -C <DIR> and match sandbox and model flags

FAQ

Can I change model or flags when resuming a session?

No. Resumed sessions inherit all settings from the original run. Use echo "prompt" | codex exec resume --last and do not supply flags.

What sandbox should I use for safe code review?

Use --sandbox read-only for safe reviews that do not modify files or run network operations.

When should I request permission before running a command?

Ask before using --full-auto, --sandbox danger-full-access, or --skip-git-repo-check because these enable high-impact changes.