# Agent CLI Reference: 5-Tool Comparison

A side-by-side reference for Claude Code, Pi Coding Agent, OpenCode, Hermes Agent, and OpenClaw.

---

## 1. Claude Code (Anthropic)

**Role**: Primary generalist coding agent. Best all-around tool.  
**License**: Proprietary (free tier + Pro subscription)  
**Runtime**: Node.js  
**Config**: `CLAUDE.md` in project root

### Key Capabilities

| Feature | How To | Course Reference |
|---------|--------|-----------------|
| Multi-agent teams | `claude --teammate-mode tmux` | M4 — teammate-mode spawns agents in split panes |
| Headless execution | `claude -p "prompt" --print` | M5 CI/CD pipeline |
| Constrained tools | `--allowedTools "Read Write Edit"` | M3 security (L4 whitelist pattern) |
| Hooks system | `.claude/hooks/*.py` | M3 hook architecture (13 lifecycle events) |
| Subdirectory rules | `frontend/CLAUDE.md`, `backend/CLAUDE.md` | M2 skills deep dive |
| Stop hook self-improve | PostToolUse → headless claude session | M3, also ClaudeFAST pattern |

### Boilerplate Setup

```bash
# Project initialization
claude --init

# Launch with teammate mode
claude --teammate-mode tmux

# Headless CI mode
claude -p "Implement the feature described in spec.md" --allowedTools "Read Write Edit Bash" --print

# With custom hooks directory
claude --hooks .claude/hooks/
```

### Hook Lifecycle (13 events)

| Phase | Events |
|-------|--------|
| Session | Setup, SessionStart, SessionEnd |
| Main Loop | UserPromptSubmit, PreToolUse, PermissionRequest, PostToolUse, PostToolUseFailure, Stop, Notification |
| Subagents | SubagentStart, SubagentStop |
| Maintenance | PreCompact |

---

## 2. Pi Coding Agent (pi.dev)

**Role**: Customizable agent harness. Full control over every aspect.  
**License**: Open source (MIT)  
**Runtime**: Node.js (TypeScript SDK)  
**Config**: `.pi/settings.json`, `.pi/agents/*.md`

### Key Capabilities

| Feature | How To | Course Reference |
|---------|--------|-----------------|
| Extensions | `pi -e extensions/<name>.ts` | M3 — damage-control, tilldone |
| RPC mode | `pi --mode rpc` | M5 — programmatic control (26+ commands) |
| Agent teams | `agent-team` extension + `teams.yaml` | M4 dispatcher pattern |
| Agent chains | `agent-chain` extension + `agent-chain.yaml` | M4 pipeline pattern ($INPUT/$ORIGINAL) |
| P2P communication | `coms` (Unix sockets) / `coms-net` (HTTP/SSE) | M4 flat P2P pattern |
| Mental models | `.pi/multi-team/expertise/*.yaml` | M4 agent memory, self-improve commands |
| Damage control | `damage-control.ts` + `damage-control-rules.yaml` | M3 three access levels |
| Skills system | `.pi/skills/*/SKILL.md` | M2 composable skills |

### Boilerplate Setup

```bash
# Launch with extensions
pi -e extensions/damage-control.ts -e extensions/tilldone.ts -e extensions/minimal.ts

# Launch with multiple extensions (stackable)
pi -e extensions/purpose-gate.ts -e extensions/tool-counter.ts

# RPC mode (programmatic control from any language)
pi --mode rpc

# Pi-to-Pi peer communication (same machine)
just local-coms --name planner --purpose "Plans the work"
just local-coms --name coder --purpose "Writes the code"

# Pi-to-Pi networked (across machines)
just coms-net-server    # hub
just coms --name dev    # client 1
just coms2 --name prod  # client 2
```

### Extension Catalog (16 total)

| Category | Extensions |
|----------|------------|
| **UI** | pure-focus, minimal, theme-cycler, session-replay |
| **Monitoring** | tool-counter, tool-counter-widget |
| **Task** | tilldone, purpose-gate |
| **Multi-Agent** | subagent-widget, agent-team, agent-chain |
| **Safety** | damage-control, damage-control-continue |
| **P2P** | coms, coms-net |
| **Cross-Tool** | cross-agent, system-select |
| **Meta** | pi-pi |

### Pi Agent Rust Port (Jeff Emanuel, 1,024★)

A Rust reimplementation of the Pi agent with zero unsafe code.

| Feature | Pi (TypeScript) | Pi Agent Rust |
|---------|----------------|---------------|
| Extensions | Full (16+) | Compatible |
| RPC mode | Yes | Yes |
| Performance | Baseline | ~2x faster |
| Binary size | ~35MB | ~8MB |
| Memory safety | Node.js GC | Zero unsafe Rust |

### The 4 Dimensions of Control (Pi's strength)

| Dimension | Pi's Advantage |
|-----------|----------------|
| **Context** | Full control over what the agent sees via extensions |
| **Model** | Any provider, any model — pluggable |
| **Prompt** | Skills, system prompts, agent .md files — fully customizable |
| **Tools** | Extensions can add, remove, or override any tool |

---

## 3. OpenCode (opencode.ai)

**Role**: Open-source Claude Code alternative. MIT license.  
**License**: MIT (open source)  
**Runtime**: Node.js (npm global package)  
**Config**: Shares `~/.grok/config.toml` with Claude Code

### Key Capabilities

| Feature | How To | Course Reference |
|---------|--------|-----------------|
| Headless commands | `opencode run "prompt"` | M5 CI/CD alternative to Claude Code CLI |
| Model selection | `opencode --model opencode-go/deepseek-v4-flash` | M6 cascade routing |
| Proxy support | Routes through `localhost:18901/v1` | M6 cost optimization |
| Shared config | Uses same `~/.grok/config.toml` | M5 production stack — dual tool setup |
| Go models | 12 Go-optimized models available | M6 economics (Go models are cheaper per token) |

### Available Go Models (through proxy)

| Model ID | Cost Tier | Best For |
|----------|-----------|----------|
| `opencode-go/deepseek-v4-flash` | Budget | General agentic tasks ($10/mo flat) |
| `opencode-go/deepseek-v4-pro` | Mid | Complex reasoning |
| `opencode-go/kimi-k2.6` | Mid | Long context |
| `opencode-go/qwen3.6-plus` | Budget | Structured tasks |
| `opencode-go/minimax-m2.7` | Budget | Fast responses |

### Boilerplate Setup

```bash
# Headless task execution
opencode run "Refactor the auth module to use JWT tokens"

# With specific model
opencode --model opencode-go/deepseek-v4-flash run "Write unit tests for the API"

# With custom config
opencode --config ~/.grok/config.toml run "Deploy to staging"

# List available models
opencode models
```

### When to Use OpenCode Instead of Claude Code

| Scenario | Choose |
|----------|--------|
| Need open-source license | OpenCode |
| Budget-constrained | OpenCode (Go models at $10/mo flat) |
| CI/CD pipelines | OpenCode `run` command |
| Primary development | Claude Code (better tool calling) |
| Need hooks system | Claude Code (13 events vs OpenCode's limited hooks) |
| Heterogeneous stack | Both (OpenCode as backup/alternative model) |

---

## 4. Hermes Agent (Some Engineering Inc.)

**Role**: TypeScript-native, MCP-first agent for structured workflows.  
**License**: Open source  
**Runtime**: Node.js (TypeScript)  
**Design philosophy**: MCP-native architecture, structured output first

### Key Capabilities

| Feature | How To | Course Reference |
|---------|--------|-----------------|
| MCP-native tools | Built-in MCP client | M2 Beyond MCP channels |
| Structured output | TypeScript types enforced | M2 context management |
| Tool-use workflows | Designed for function-calling chains | M2 agent loop variants |
| OpenClaw ecosystem | Integrates with OpenClaw agents | M4 multi-agent orchestration |

### Boilerplate Setup

```bash
# Run with MCP server
hermes --mcp-servers ./mcp-config.json

# Execute workflow
hermes run workflow.ts

# With custom tools
hermes --tools-dir ./tools/
```

### When to Use Hermes

- Building TypeScript-native agent pipelines
- MCP-first architecture (tools as MCP servers)
- Tight integration with OpenClaw ecosystem
- Structured output enforcement (TypeScript types)

---

## 5. OpenClaw

**Role**: Always-on agent employee. Heartbeat-driven, autonomous execution.  
**License**: Open source  
**Runtime**: Node.js daemon  
**Design philosophy**: "If it can receive a heartbeat, it's hired."

### Key Capabilities

| Feature | How To | Course Reference |
|---------|--------|-----------------|
| Heartbeat model | Wakes on schedule, works, sleeps | M7 always-on agents |
| One-shot execution | `claw do "task"` | M5 production task dispatch |
| Device-key pairing | Auth via device key + invite | M5 deployment modes |
| Paperclip-native | Primary agent for Paperclip orchestration | M7 framework comparison |
| tmux integration | Can run inside tmux sessions | M5 production stack |

### Boilerplate Setup

```bash
# Start as daemon (always-on employee)
claw start --daemon

# One-shot task
claw do "Review the latest PR and leave comments"

# Schedule recurring task
claw schedule --cron "0 6 * * 1" --task "Generate weekly report"

# Check status
claw status

# Stop daemon
claw stop
```

### Heartbeat Execution Model

```
Timer fires → Check for queued work → Wake agent → Execute → Report results → Sleep
```

No continuous running. The agent wakes, works, and goes back to sleep. This is the most cost-effective model for scheduled/recurring work.

---

## Comparison Matrix

| Feature | Claude Code | Pi Agent | OpenCode | Hermes | OpenClaw |
|---------|:-----------:|:--------:|:--------:|:------:|:--------:|
| **License** | Proprietary | MIT | MIT | Open | Open |
| **Cost** | Pro sub | Free | Free | Free | Free |
| **Hooks** | 13 events | Extension events | Limited | MCP events | None |
| **Multi-agent** | teammate-mode | Extensions | No | Chains | Heartbeats |
| **P2P coms** | No | coms/coms-net | No | No | No |
| **Headless mode** | `--print` | RPC mode | `run` | Yes | daemon |
| **MCP support** | Built-in | Via extensions | Via proxy | Native | Via Paperclip |
| **Best for** | Generalist coding | Custom harness | OSS alternative | TS pipelines | Always-on tasks |
| **Course module** | M3, M4, M5 | M3, M4, M5 | M5, M6 | M5 | M5, M7 |

---

## Quick Selection Guide

```
What are you building?
├── A feature? → Claude Code
├── A custom workflow? → Pi Agent
├── An open-source project? → OpenCode
├── A TypeScript pipeline? → Hermes
└── A recurring task? → OpenClaw

Need multiple?
├── Production system → All 5 (see REFERENCE-STACK.md)
├── Budget constrained → OpenCode + Go models
├── Maximum control → Pi Agent + extensions
└── Enterprise rollout → Claude Code + Agent Manager
```
