AI & Agents

OpenClaw Coding Agent Tutorial: Automate Bug Fixes and PRs

OpenClaw's coding-agent skill delegates development tasks to background AI processes that fix bugs, review PRs, and refactor code without blocking your main agent session. This tutorial walks through enabling the skill, choosing a backend, spawning your first coding session, monitoring it with process commands, and reviewing the output PR safely.

Fast.io Editorial Team 11 min read
AI agent reviewing code changes in a workspace

What the OpenClaw Coding Agent Actually Does

Most coding assistant tutorials cover tools like Cursor or GitHub Copilot, where AI helps while you actively write code. OpenClaw's coding-agent skill works differently. It spawns a background process that takes independent action: reading issues, writing fixes, running tests, and opening pull requests. You keep working (or sleeping) while the agent codes.

The skill supports four coding backends: Codex (OpenAI), Claude Code (Anthropic), OpenCode, and Pi. Each backend runs as a separate process, and all of them follow the same safety model. Agents open PRs but never merge them. Every change goes through your normal review process before it hits the main branch.

This matters because it turns OpenClaw from a chat assistant into a background developer. You describe a task, the agent clones the repo into an isolated checkout, does the work, and sends you a notification when the PR is ready. The official coding-agent skill documentation on GitHub describes the use cases as "background feature builds, PR reviews, large refactors, and issue-to-PR loops."

The skill is not meant for quick edits or read-only lookups. Those are faster to do inline. The coding agent shines when the task takes minutes or hours and you want to do something else while it runs.

How to Enable the Coding-Agent Skill and Pick a Backend

The coding-agent skill ships in the official OpenClaw skills repository. You enable it through OpenClaw's skill configuration, which registers the skill so your agent can invoke it during sessions.

Enabling the skill

Add the coding-agent entry to your OpenClaw skill settings and mark it as enabled. The exact configuration path depends on your OpenClaw version, but the skill registry follows the same pattern as other OpenClaw skills. Once enabled, the agent can delegate development tasks to a background coding process.

Choosing your backend

The skill supports four backends, each with different strengths:

  • Codex (OpenAI): A CLI-based tool that operates within git repositories. Codex creates an isolated checkout before starting work, keeping your main branch untouched.
  • Claude Code (Anthropic): Runs in a non-interactive streaming mode, making it lighter weight. Good for tasks that do not require terminal interaction during execution.
  • OpenCode: Another CLI-based option that supports interactive terminal access. Install the OpenCode package before first use.
  • Pi: OpenClaw's native TypeScript runtime with access to tools, memory, and provider configuration. Pi offers the deepest integration with OpenClaw's own ecosystem.

If you specify a backend in your task request, OpenClaw uses that one. Otherwise, it selects based on your configuration and which CLI tools are installed locally. The AI Agent Factory crash course walks through backend selection in more detail.

One rule applies to all backends: every coding session runs in the background. There is no foreground blocking path. The agent starts the process, captures a session ID, and monitors from there.

AI agent configuration and setup interface

Spawn a Background Coding Session

Spawning a coding session follows a three-step pattern: write the task prompt, launch the backend, and capture the session ID.

Step 1: Write a clear task prompt

The official SKILL.md recommends writing your prompt to a temporary file rather than passing it inline. This avoids shell quoting issues, especially when prompts contain code references or multi-line instructions. Your prompt should describe the bug or task precisely (including the file path, expected behavior, and test expectations) and end with a notification block that tells the worker how to reach you when the job finishes.

Step 2: Launch the backend

Each backend has its own launch command. You point it at the temp file, and the backend reads the prompt, clones your repo into an isolated checkout, and begins working. The specific invocation depends on which backend you chose in the previous step. All four backends follow the same lifecycle: read the prompt, create an isolated workspace, do the work, and open a PR.

Step 3: Capture the session ID

When the process starts, you get a session ID back. This ID is your handle for monitoring, logging, and (if needed) killing the session. Report it to the user along with milestones as work progresses.

Workspace isolation is mandatory. The coding agent never works in your main project directory. It creates a separate checkout so that your working tree stays clean regardless of what the background agent does. The SKILL.md explicitly warns against using paths like ~/Projects/openclaw for agent work.

Fastio features

Persist your coding agent's output across sessions

50GB free workspace with semantic search, MCP tooling, and file locks for multi-agent coding workflows. No credit card required.

Monitor Progress and Manage Processes

Once a coding session is running, you have several process management commands to track what is happening.

list: Shows all active coding sessions with their IDs and status. Use this to see what is running and what has finished.

poll: Checks the current state of a specific session. Gives you a snapshot of where the agent is in its workflow without streaming the full log.

log: Streams or retrieves the full output log for a session. Useful for debugging when something goes wrong or when you want to see exactly what the agent did.

submit: Sends input to a running session. This lets you provide additional context or answer questions the agent encounters during execution.

write and paste: Send text input to the session's terminal. These are lower-level than submit and useful when the backend needs specific terminal input.

kill: Terminates a session immediately. Use this when a session is stuck, consuming too many resources, or working on the wrong task.

The monitoring approach is intentionally lightweight. You check on sessions when you want to, rather than being bombarded with status updates. The agent sends a single notification via openclaw message send when work completes. Between start and finish, you only get updates on significant milestones.

This design keeps the main agent free to handle other tasks. You can spawn multiple coding sessions across different repositories and check on each one independently.

Task monitoring interface showing active processes

Review the Generated PR Safely

The coding agent's safety model is simple: agents open PRs, but they never merge. Every change the agent makes flows through your existing code review process.

When a coding session finishes, you get a notification with a link to the PR. From there, the review process is identical to reviewing any human-authored PR. Read the diff, check the test results, leave comments, and merge when satisfied.

What works well for automated PRs

  • Well-scoped bugs with clear reproduction steps: the agent reads the issue, finds the offending code, writes a fix, and runs the test suite
  • Style and standards enforcement: consistent formatting changes across many files
  • Dependency updates that do not involve breaking changes
  • Documentation generation from code comments or changelogs
  • Test coverage gaps where the fix is mechanical

Where human judgment is still critical

  • Architectural decisions that affect data models or public APIs
  • Security-sensitive code paths (authentication, authorization, encryption)
  • Performance-critical sections that need profiling, not just correctness
  • Database migrations that touch production schemas
  • Any change where "it works" is not sufficient and "it works well" matters

The Blink blog recommends adding an "escalation triggers" section to your OpenClaw configuration. Define directories or labels that the agent should never touch autonomously, like /src/auth/ or /src/payments/. When the agent encounters these boundaries, it escalates to a human instead of attempting a fix.

Storing PR artifacts with Fast.io

As your coding agent generates PRs across multiple repositories, the artifacts pile up: diffs, test reports, code review summaries, benchmark results. Local storage works for a single developer, but breaks down when agents collaborate or hand off work to a team.

Fast.io workspaces give agents persistent storage that survives session restarts. Enable Intelligence Mode on a workspace and uploaded artifacts become semantically searchable. Ask "which PRs touched the auth module last week" and get cited answers from your agent's own output history.

The free agent plan includes 50GB storage and 5,000 credits per month, no credit card required. Agents connect through the MCP server via Streamable HTTP at /mcp, giving them tools for file upload, workspace management, and AI-powered search. When it is time to hand off a project, ownership transfer lets an agent build the workspace and pass control to a human reviewer.

For teams running multiple OpenClaw coding agents, Fast.io's file locks prevent conflicts when two agents try to update the same artifact simultaneously. Webhooks notify downstream systems when new artifacts arrive, so your CI pipeline can pick up test reports automatically.

Other options like S3 or Google Drive work for raw file storage, but they lack the semantic search and agent-native MCP tooling that make artifact management practical at scale.

Best Practices for Issue-to-PR Automation

Here is how a typical coding agent workflow looks in practice, from issue to merged PR.

The issue-to-PR loop

  1. A bug is filed on GitHub with a descriptive title and reproduction steps
  2. You tell your OpenClaw agent to fix it, specifying the repository and backend
  3. The agent clones the repo into an isolated checkout
  4. It reads the issue, searches relevant code, and writes a fix
  5. It runs the test suite. If tests fail, it adjusts and retries
  6. Once tests pass, it opens a PR and sends you a notification
  7. You review and merge

For straightforward bugs (null checks, off-by-one errors, missing imports), the Blink blog reports that agents typically produce passing PRs within 5 to 15 minutes.

Running multiple agents in parallel

Nothing stops you from spawning coding sessions across different repositories at the same time. Each session gets its own isolated checkout and session ID. Use list to see everything running, and log on a specific session when you need details.

Writing better prompts for coding agents

The quality of the PR depends heavily on the prompt. Be specific about what to fix, where the relevant code lives, and what "done" looks like. "Fix the auth bug" is vague. "The JWT validation in src/auth/validate.ts throws a null pointer when the token payload is missing the 'sub' field. Add a guard check and a test case that reproduces the issue" gives the agent enough context to work independently.

When to skip the coding agent

The SKILL.md is clear that simple edits and read-only lookups should not go through the coding agent. If you can describe the change in one sentence and it touches one file, do it inline. The coding agent's strength is tasks that take minutes or hours, not seconds.

Scheduling with HEARTBEAT.md

OpenClaw's HEARTBEAT.md file enables scheduled automation. You can configure the agent to check for new issues labeled ai-fix every 30 minutes and automatically spawn coding sessions for each one. This turns the coding agent into a continuous background service rather than something you trigger manually.

Frequently Asked Questions

How do I use OpenClaw as a coding agent?

Enable the coding-agent skill in your OpenClaw configuration by setting skills.entries.coding-agent.enabled. Choose a backend (Codex, Claude Code, OpenCode, or Pi), write your task prompt to a temp file with a notification block, and launch the session with background:true. The agent works in an isolated checkout and opens a PR when finished.

Can OpenClaw fix bugs automatically?

Yes. The coding agent reads issue descriptions, searches relevant code, writes fixes, and runs your test suite. If tests fail, it adjusts and retries. When tests pass, it opens a PR for your review. It handles well-scoped bugs reliably, though architectural decisions and security-sensitive code still need human judgment.

What coding backends does OpenClaw support?

The coding-agent skill supports four backends: Codex (OpenAI), Claude Code (Anthropic), OpenCode, and Pi (OpenClaw's native TypeScript runtime). Codex, OpenCode, and Pi require PTY terminal access. Claude Code runs in non-interactive mode with the --print flag.

Is OpenClaw coding agent safe for production code?

The safety model requires that agents open PRs but never merge them. Every change goes through your existing review process. You can also define escalation triggers that block the agent from touching sensitive directories like authentication or payment code. Workspace isolation ensures the agent never modifies your working tree directly.

How do I monitor a running OpenClaw coding session?

Use the process management commands: list shows all active sessions, poll checks a specific session's status, log retrieves the full output, and kill terminates a stuck session. The agent sends a completion notification via openclaw message send when work finishes.

Can I run multiple OpenClaw coding agents at once?

Yes. Each coding session gets its own isolated checkout and session ID. You can spawn sessions across different repositories or even the same repository on different branches. Use the list command to track all active sessions and log to inspect individual ones.

Related Resources

Fastio features

Persist your coding agent's output across sessions

50GB free workspace with semantic search, MCP tooling, and file locks for multi-agent coding workflows. No credit card required.