Setting Up Claude Code with OpenClaw: Step-by-Step Guide
Learn how to integrate Claude Code with OpenClaw for a powerful multi-agent coding workflow. Setup, configuration, and real-world usage patterns included.
Why Claude Code + OpenClaw?
OpenClaw is a gateway for AI agents that gives you a persistent workspace, tool access, and multi-agent orchestration. When paired with Claude Code as a coding agent, you get a powerful development environment where Claude Code can work autonomously on complex tasks while OpenClaw manages context, tools, and delivery.
What This Integration Enables
- Background coding tasks — Claude Code runs while you continue working - Persistent workspace — OpenClaw maintains project context across sessions - Tool orchestration — Claude Code gets file system, search, and automation access - Multi-agent workflows — Claude Code + other agents working in parallel - Scheduled tasks — Code review, build, and deployment on schedule
Installation
Step 1: Install OpenClaw
# Install OpenClaw via npm
npm install -g openclaw# Start the gateway
openclaw gateway start
# Check status
openclaw status
Step 2: Install Claude Code
npm install -g @anthropic-ai/claude-code# Verify installation
claude --version
Step 3: Set Your API Keys
Configure both tools with your API keys:
# Claude Code needs an Anthropic API key
export ANTHROPIC_API_KEY="sk-ant-xxxxxxxx"# OpenClaw can use various providers
# Set the model provider in your config
Add these to your shell profile (~/.zshrc or ~/.bashrc) for persistence:
echo 'export ANTHROPIC_API_KEY="sk-ant-xxxxxxxx"' >> ~/.zshrc
source ~/.zshrc
Configuration
Configure OpenClaw for Claude Code
Create or edit ~/.openclaw/config.yaml:
# OpenClaw configuration for Claude Code
gateway:
port: 3001
heartbeatInterval: 30agents:
claudeCode:
command: claude
args: ["--permission-mode", "bypassPermissions", "--print"]
model: claude-sonnet-4-20250514
timeout: 300
Create a Skills Configuration
OpenClaw uses "skills" to give agents specialized abilities. Create a skill for Claude Code:
mkdir -p ~/.openclaw/skills/coding-agent
Create ~/.openclaw/skills/coding-agent/SKILL.md:
---
name: coding-agent
description: Run Claude Code for autonomous coding tasks
---# Coding Agent Skill
Use Claude Code for:
- Code generation and refactoring
- Bug fixing and debugging
- Test writing
- Code review
- Documentation generation
Usage Patterns
Pattern 1: One-Shot Coding Tasks
Run Claude Code through OpenClaw for specific tasks:
# OpenClaw spawns Claude Code as a sub-agent
openclaw run \
--agent claudeCode \
--task "Add a dark mode toggle to the React app.
Update the components, styles, and add local storage persistence."
Claude Code will analyze the project, implement the changes, and report back.
Pattern 2: Scheduled Code Review
Set up automatic daily code review:
# In OpenClaw cron configuration
schedule:
- time: "09:00"
agent: claudeCode
task: "Review all PRs opened yesterday in the current repo.
Check for: security issues, code style violations,
missing tests, and performance concerns."
Pattern 3: Multi-Agent Workflow
Combine Claude Code with other agents for complex workflows:
# Build pipeline with multiple agents
workflow:
steps:
- agent: claudeCode
task: "Write unit tests for all new API endpoints"
- agent: claudeCode
task: "Review the tests for completeness and edge cases"
- agent: claudeCode
task: "Fix any failing tests and optimize test coverage"
Pattern 4: Project Scaffolding
Use Claude Code through OpenClaw to set up new projects:
openclaw run \
--agent claudeCode \
--task "Create a new Next.js project with TypeScript,
Tailwind CSS, Prisma ORM, and authentication.
Initialize the project structure and install dependencies."
Real-World Example: Bug Fix Workflow
Here's how a real bug fix flows through the system:
1. Developer: "Fix the login redirect bug"
2. OpenClaw sends the task to Claude Code
3. Claude Code:
- Reads the auth components
- Identifies the redirect logic issue
- Fixes the redirect URL construction
- Adds a test for the edge case
- Commits the changes
4. OpenClaw reports completion with:
- Files changed
- What the bug was
- How it was fixed
- Test results
Monitor Progress in Real-Time
# Check active agent sessions
openclaw status# View recent agent output
openclaw logs --agent claudeCode --lines 20
Performance Tips
1. Set Cost Limits
Claude Code API costs can add up. Configure limits:
# Claude Code cost controls
claude config set maxCost 20
claude config set costThreshold 15# Warn when spending exceeds threshold
claude config set costNotification true
2. Optimize Context Windows
For large projects, limit context to relevant areas:
# Focus Claude Code on specific directories
claude --context src/pages/ src/components/# Or use .claudeignore to exclude files
echo "node_modules/\n.next/\ndist/" >> .claudeignore
3. Use MCP Servers
Extend Claude Code's capabilities through MCP servers managed by OpenClaw:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-filesystem"],
"env": {
"ALLOWED_PATHS": "/home/you/projects"
}
},
"github": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-github"],
"env": {
"GITHUB_TOKEN": "ghp_xxxx"
}
}
}
}
Troubleshooting
Claude Code Not Responding
# Check if Claude Code works independently
claude --print "Hello, are you working?"# Check OpenClaw gateway status
openclaw gateway status
# Restart if needed
openclaw gateway restart
Permission Issues
# Ensure Claude Code has project access
ls -la /path/to/your/project# Claude Code might need read/write permissions on the project directory
chmod -R 755 /path/to/your/project
Timeout Errors
# Increase timeout in OpenClaw config
# config.yaml
agents:
claudeCode:
timeout: 600 # 10 minutes instead of 5
Is This Setup Right for You?
| You should use this setup if... | You're better off with just Claude Code if... | |--------------------------------|----------------------------------------------| | Managing multiple projects | Working on a single project | | Need scheduled/recurring tasks | Prefer interactive coding sessions | | Want multi-agent orchestration | Don't need complex automation | | Need persistent agent workspace | Run ad-hoc tasks only |
Summary
Claude Code + OpenClaw gives you an autonomous coding agent that runs on your terms — whether that's one-shot tasks, scheduled maintenance, or complex multi-agent workflows.
The setup takes about 15 minutes and scales from solo development to team-scale automation.
---
New to Claude Code? Start with our installation guide. Want to learn more about MCP? Check out our MCP beginner's guide.
Related Articles
How to Install and Use Agent Skills with Claude Code
Learn how to extend Claude Code with agent skills. Install, create, and manage skills from ClawHub to supercharge your AI coding agent.
10 Productivity Hacks for Claude Code: Work Smarter, Not Harder
10 proven productivity techniques for Claude Code that save you hours each day. From prompt templates to keyboard shortcuts to workflow optimizations.
Claude Code Hooks Automation Guide: Automate Every Step of Your Workflow
Complete guide to Claude Code hooks — automate testing, linting, deployments, and notifications. With real-world hook recipes for pre-command, post-command, and pipeline integration.