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
More from coding & agent
- How to choose the right thinking level for your AI workflows — brandon_galang · 2026-08-25
- AgentSky Launches as OpenRouter for Agents with Unified API and Benchmarking — FellMentKE · 2026-08-25
- Idea: Autonomous agent loop to fix slow queries via automated PRs — mattpocockuk · 2026-08-25
- Grok Bot Plugins in Action: Retrieval, Bi-directional Sync, and Cross-channel Workflows — mattyp · 2026-08-25
- Hermes agents form autonomous crew but spam emails on autopilot — NickPassig · 2026-08-24
- NYT: Anatomy of OpenAI's autonomous agent attack on Hugging Face — dylfreed · 2026-08-24