skills/cli-agents/codex-cli-invoke-once/SKILL.md
Programmatically invoke Codex via the `codex` CLI for headless, non-interactive runs using `codex exec`, machine-readable JSONL via `--json`, final-message capture via `-o/--output-last-message`, and multi-turn continuation via `codex exec resume`. Use when you need scriptable Codex automation for repo reviews, issue investigation, implementation planning, or structured one-shot outputs.
npx skillsauth add igamenovoer/magic-context codex-cli-invoke-onceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Users may provide Codex wrappers with any name. Many teams use names like codex-dev, codex-prod, or codex-openai, but do not assume a codex-* prefix.
.sh, .bat, or a normal executable, substitute it directly for codex.One-shot run with the last assistant message written to a file:
codex exec -o /tmp/codex-last.txt "Summarize this repo"
cat /tmp/codex-last.txt
Machine-readable JSONL events on stdout:
codex exec --json -o /tmp/codex-last.txt "Explain recursion"
Persist a session and resume it later:
log="$(mktemp)"
codex exec --json -o /tmp/codex-last.txt "Start a review of this repo" | tee "$log"
thread_id="$(jq -r 'select(.type=="thread.started").thread_id' "$log" | head -n1)"
codex exec resume "$thread_id" --json -o /tmp/codex-last-2.txt "Continue that review with a focus on tests"
Structured final output with a JSON Schema:
codex exec --output-schema /path/to/schema.json -o /tmp/result.json "Return the requested fields only"
--json so stdout emits a stream of JSONL events. Treat each line as a heartbeat and update a last-seen timestamp while the process is active.-o or the terminal JSONL event stream.codex exec and -o to capture the last assistant message.--json and parse JSONL from stdout.thread_id from thread.started and use codex exec resume.codex exec review over top-level codex review because exec review supports --json and -o.--ephemeral and do not expect resume to work afterward.thread_id or session id, use codex exec resume <id>.codex exec resume --last.--ephemeral, start a new session instead of attempting resume.thread.started event if you may need a follow-up turn later.codex exec does not use Claude-style -p or --output-format; pass the prompt as a positional argument and use --json for JSONL events.codex exec does not accept -a or --ask-for-approval. Use the flags listed in codex exec --help instead.codex exec supports --sandbox, --full-auto, --dangerously-bypass-approvals-and-sandbox, --ephemeral, --output-schema, --json, and -o.codex exec resume supports --json, -o, --last, and --ephemeral, but its option surface is smaller than plain exec.codex.type instead of hard-coding full schemas.Ensure the codex CLI is installed and authenticated in the current environment before automating it.
references/howto-control-codex-cli-programmatically.mddata-ai
Create readable Mermaid diagrams inside Markdown files. Use for flowcharts and sequence diagrams that must render cleanly in common Markdown renderers (e.g., GitHub) without horizontal scrolling. Covers fenced mermaid blocks, init/theme styling, label wrapping with <br/>, and sequenceDiagram layout rules (short IDs, wrapped labels, don’t break identifiers).
development
Manual invocation only; use only when the user explicitly requests `make-program-tutorial` by exact name, OR when the user asks to use a skill to create an SDK/API/library tutorial. Create a clear, reproducible, step-by-step tutorial for a specific API/SDK/library (or a set of functions/classes), with runnable examples, expected outputs, and basic troubleshooting.
testing
Use when the user wants to create a self-hosted, offline-installable Conda channel (mirror) containing a specific subset of packages using Pixi.
tools
Guides the agent to setup a new or existing Pixi environment for compiling C++ and CUDA code. It ensures the correct compilers, toolkits, and CMake configurations are in place for a robust user-space build.