Wrapping Codex/Claude Code as inference engines: a subprocess pattern in practice

0xToc · reddit · 2026-08-24

The author shares how to integrate Codex and Claude Code into your own apps: spawn a subprocess and run inference via codex exec or claude -p.

Core invocation: pipe the prompt into codex exec --ignore-user-config --skip-git-repo-check -s read-only --ephemeral --color never -o /tmp/aicmd-command.txt - (the trailing - reads the prompt from stdin). Codex writes its answer to the temp file; the app reads it, verifies it's a single command, and places it at the user's terminal prompt. Claude Code and Antigravity follow the same pattern: launch the CLI, give it a constrained task, parse the response, keep the final action under user control — and reuse the user's existing login/subscription for auth so the wrapper never becomes another chat app.

Limitations called out: users must be authenticated on the CLIs; agent cold-start latency is significant; extra context like skills, MCP, and global AGENTS.md gets pulled in; output can be hard to parse; ToS are murky; and claude -p will use the API instead of your plan if an API key is set — so unset it.

The reference implementation aicmd is open source, supporting Codex, Claude Code, Antigravity, local Ollama/llama.cpp, and direct APIs: github.com/zazencodes/aicmd

Original post →

More from coding & agent

coding & agent channel →