---
name: ai-coding-agents
description: "Delegate coding to external AI CLI agents (Claude Code, Codex, OpenCode). Shared orchestration patterns, tool selection, PTY handling."
version: 1.0.0
author: Hermes Agent
license: MIT
platforms: [linux, macos, windows]
metadata:
  hermes:
    tags: [Coding-Agent, Claude, Codex, OpenAI, OpenCode, Autonomous, PTY, Delegation]
    related_skills: [hermes-agent]
---

# AI Coding Agents — Orchestration Guide

Delegate coding tasks to external autonomous coding agent CLIs via the Hermes terminal. All three tools follow the same orchestration patterns; pick based on what's installed and the user's preference.

## Tool Selection

| Tool | Provider | Install | Best For |
|------|----------|---------|----------|
| **Claude Code** | Anthropic | `npm install -g @anthropic-ai/claude-code` | Complex multi-file refactoring, deep reasoning, MCP integration |
| **Codex** | OpenAI | `npm install -g @openai/codex` | Fast feature implementation, batch issue fixing |
| **OpenCode** | Multi-provider | `npm i -g opencode-ai@latest` | Provider-agnostic work, cost optimization |

## Shared Orchestration Patterns

### One-Shot (Preferred for most tasks)

All three tools support non-interactive one-shot execution — the cleanest integration:

```bash
# Claude Code
claude -p 'Add error handling to all API calls in src/' --allowedTools 'Read,Edit' --max-turns 10

# Codex
codex exec 'Add dark mode toggle to settings'

# OpenCode
opencode run 'Add retry logic to API calls and update tests'
```

### Interactive / Background (Multi-turn sessions)

For iterative work, run in background with PTY:

```bash
# All tools require pty=true for interactive mode
terminal(command="<tool> ...", workdir="~/project", background=true, pty=true)
# Monitor with process(action="poll"|"log")
# Send input with process(action="submit", data="...")
```

### PR Review

```bash
# Claude Code
claude -p 'Review this PR thoroughly' --from-pr 42 --max-turns 10

# Codex
codex exec 'Review PR #42. git diff origin/main...origin/pr/42'

# OpenCode
opencode pr 42
```

### Parallel Tasks

All three support running multiple instances in separate workdirs/worktrees:

```bash
terminal(command="<tool> 'Fix issue #78'", workdir="/tmp/issue-78", background=true, pty=true)
terminal(command="<tool> 'Fix issue #99'", workdir="/tmp/issue-99", background=true, pty=true)
```

## Critical Rules

1. **Always use `workdir`** — scope the agent to the right project
2. **Set turn limits** for one-shot mode (prevents runaway loops)
3. **Use `pty=true`** for interactive sessions — all three are TUI apps
4. **Monitor progress** with `process(action="poll"|"log")` — don't kill slow sessions
5. **Git repo required** — all three need a git directory. Use `mktemp -d && git init` for scratch work
6. **Clean up** background sessions when done

## Tool-Specific References

Detailed CLI flags, session management, and advanced features for each tool:

- `references/claude-code.md` — Claude Code: print mode deep dive, tmux orchestration, hooks, MCP, subagents, settings hierarchy
- `references/codex.md` — Codex: exec flags, full-auto vs yolo, worktree patterns, auth (OAuth vs API key)
- `references/opencode.md` — OpenCode: run vs interactive TUI, session resumption, provider selection, PR review
