Run Codex CLI, Claude Code, or other coding agents via background process
Run coding agents (Codex, Claude Code, OpenCode, Pi) for programmatic code generation.
Coding agents are interactive terminal apps that need a pseudo-terminal:
# Always use pty:true when running coding agents
bash pty:true command:"codex exec 'Your prompt'"
# Quick chat (Codex needs a git repo)
SCRATCH=$(mktemp -d) && cd $SCRATCH && git init && codex exec "Your prompt"
# In a real project
bash pty:true workdir:~/project command:"codex exec 'Add error handling'"
# One-shot execution
bash pty:true workdir:~/project command:"codex exec --full-auto 'Build a dark mode toggle'"
# Background for longer work
bash pty:true workdir:~/project background:true command:"codex --yolo 'Refactor auth module'"
Flags:
exec "prompt" - One-shot execution--full-auto - Sandboxed but auto-approves--yolo - No sandbox, no approvals (fastest)bash pty:true workdir:~/project command:"claude 'Your task'"
bash pty:true workdir:~/project command:"opencode run 'Your task'"
# Install: npm install -g @mariozechner/pi-coding-agent
bash pty:true workdir:~/project command:"pi 'Your task'"
bash pty:true command:"pi -p 'Summarize src/'"
# Create worktrees
git worktree add -b fix/issue-78 /tmp/issue-78 main
git worktree add -b fix/issue-99 /tmp/issue-99 main
# Launch agents
bash pty:true workdir:/tmp/issue-78 background:true command:"codex --yolo 'Fix issue #78'"
bash pty:true workdir:/tmp/issue-99 background:true command:"codex --yolo 'Fix issue #99'"
# Monitor
process action:list
process action:log sessionId:XXX
# Cleanup
git worktree remove /tmp/issue-78
pty:trueprocess:log--full-auto for building, vanilla for reviewing