Coding Agent Skill (OpenClaw)

Source: Coding Agent Skill (OpenClaw)

Raw file: raw/docs/openclaw-coding-agent.md
Origin: skills/coding-agent/SKILL.md in the openclaw repo

Purpose

The coding-agent skill teaches OpenClaw how to delegate coding tasks to external CLI agents — Codex, Claude Code, Pi, or OpenCode — using bash commands (foreground or background). It is the orchestration layer, not the coding layer: OpenClaw spawns and monitors agents, not patches files itself.

Use cases

Not for: simple one-liner edits, read-only code exploration, ACP-runtime chat threads (use sessions_spawn with runtime:"acp" instead), or any work inside ~/.openclaw.

Key mechanics

Execution modes by agent

Agent Mode Command pattern
Codex pty:true bash pty:true workdir:X command:"codex exec --full-auto 'task'"
Pi pty:true bash pty:true workdir:X command:"pi 'task'"
OpenCode pty:true bash pty:true workdir:X command:"opencode run 'task'"
Claude Code no PTY bash workdir:X command:"claude --permission-mode bypassPermissions --print 'task'"

Claude Code uses --print --permission-mode bypassPermissions instead of PTY because --dangerously-skip-permissions with PTY exits after the confirmation dialog.

Bash tool parameters

command, pty (bool), workdir, background (returns sessionId), timeout, elevated.

Process tool actions (for background sessions)

list, poll, log (with offset/limit), write (raw stdin), submit (data + newline), send-keys, paste, kill.

Core pattern: workdir + background + pty

bash pty:true workdir:~/project background:true command:"codex exec --full-auto 'Build snake game'"
# → sessionId returned
process action:log sessionId:XXX   # monitor
process action:poll sessionId:XXX  # check completion
process action:submit sessionId:XXX data:"yes"  # answer prompts

workdir scopes the agent so it doesn't wander into unrelated files.

Codex flags

Flag Effect
exec "prompt" One-shot, exits when done
--full-auto Sandboxed, auto-approves writes in workspace
--yolo No sandbox, no approvals (fastest, most dangerous)

Codex requires a git repo — use mktemp -d && git init for scratch work.

PR review workflow

Clone to temp or use git worktree; never review in the live openclaw project folder:

git worktree add /tmp/pr-130 pr-130-branch
bash pty:true workdir:/tmp/pr-130 command:"codex review --base main"

For batch reviews, launch one agent per PR in parallel (background:true), then post results via gh pr comment.

Parallel issue fixing

git worktree add -b fix/issue-78 /tmp/issue-78 main
bash pty:true workdir:/tmp/issue-78 background:true command:"pnpm install && codex --yolo 'Fix #78...'"
# repeat per issue; monitor with process:list / process:log

Auto-notify on completion

Append to the agent's prompt:

When completely finished, run:
openclaw system event --text "Done: [summary]" --mode now

This triggers an immediate Heartbeat wake instead of waiting up to 30 minutes.

Rules

  1. Use the right execution mode per agent (see table above).
  2. Respect tool choice — if user asks for Codex, use Codex; don't silently hand-code the patch.
  3. Be patient; don't kill sessions just because they seem slow.
  4. Monitor via process:log, not by interfering.
  5. --full-auto for building; no special flags for reviewing.
  6. Parallel agents are fine for batch work.
  7. Never start agents inside $OPENCLAW_STATE_DIR (~/.openclaw).
  8. Never checkout branches in ~/Projects/openclaw/.

Progress update discipline