Guide for using OpenClaw as your AI coding assistant.
- First Steps
- Changing Models
- Understanding OpenClaw
- Basic Usage
- Git Repository Access
- Skills and Capabilities
- Workspace Configuration
- Best Practices
- Examples
After completing authentication, you should see the OpenClaw Control UI:
- Open your browser to:
https://<vm-ip>:18789 - The chat interface will be displayed
- Start a conversation to test connectivity
Test that OpenClaw can respond:
You: Hello! Can you tell me what you can do?
OpenClaw should respond with its capabilities. If you get an error about "No API key found":
If deployed with Ansible: API keys should be auto-configured. Check they're set in ansible/inventory/group_vars/all.yml and re-run the playbook.
If deployed manually: Configure API keys:
ssh ubuntu@<vm-ip>
cd /opt/openclaw
docker compose exec openclaw-gateway openclaw configure --section model
# Follow the prompts to add your Anthropic and OpenAI API keysOther issues:
- Check logs for errors:
ssh ubuntu@<vm-ip> "docker logs openclaw-openclaw-gateway-1 --tail 50" - Verify API keys in .env: See COMMON_COMMANDS.md
OpenClaw supports multiple AI models with different capabilities and costs. You can change models via CLI or config file.
| Model | Cost (Input/Output per 1M tokens) | Best For | Speed |
|---|---|---|---|
anthropic/claude-sonnet-4-6 |
$3 / $15 | Recommended: Balanced coding tasks | Fast |
anthropic/claude-haiku-3 |
$0.80 / $4 | Budget: Simple tasks, refactoring | Fastest |
anthropic/claude-opus-4-6 |
$15 / $75 | Premium: Complex architecture, debugging | Slower |
gpt-4o |
$2.50 / $10 | OpenAI alternative | Fast |
gpt-4o-mini |
$0.15 / $0.60 | Cheapest: Simple tasks | Fastest |
Change the default model for all new conversations:
ssh ubuntu@<vm-ip>
cd /opt/openclaw
docker compose exec openclaw-gateway openclaw config set agents.defaults.model.primary "anthropic/claude-haiku-3"
docker compose restart openclaw-gatewayExample - Switch to cheaper Haiku model:
ssh ubuntu@192.168.30.118
cd /opt/openclaw
docker compose exec openclaw-gateway openclaw config set agents.defaults.model.primary "anthropic/claude-haiku-3"
docker compose restart openclaw-gatewayExample - Switch to premium Opus model:
ssh ubuntu@192.168.30.118
cd /opt/openclaw
docker compose exec openclaw-gateway openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-6"
docker compose restart openclaw-gatewayFor more control, edit the config file:
ssh ubuntu@<vm-ip>
nano ~/.openclaw/openclaw.jsonChange the agents.defaults.model.primary value:
{
"agents": {
"defaults": {
"model": {
"primary": "anthropic/claude-haiku-3"
}
}
}
}Then restart:
cd /opt/openclaw
docker compose restart openclaw-gatewayTo set the default model across redeployments, update your Ansible config:
Edit: ansible/inventory/group_vars/all.yml
openclaw_default_model: "anthropic/claude-haiku-3" # or your preferred modelDeploy:
cd ansible
ansible-playbook -i inventory/hosts playbooks/site.ymlCheck which model is configured:
ssh ubuntu@<vm-ip> "cat ~/.openclaw/openclaw.json | grep -A 3 'model'"Or check the gateway logs when it starts:
ssh ubuntu@<vm-ip> "docker logs openclaw-openclaw-gateway-1 2>&1 | grep 'agent model'"You should see: [gateway] agent model: anthropic/claude-haiku-3
To minimize costs:
- Use Haiku for simple tasks - Refactoring, formatting, simple bug fixes
- Use Sonnet for coding (default) - Good balance of capability and cost
- Use Opus sparingly - Complex architecture decisions, difficult debugging
- Keep conversations focused - Start new chats for different topics
- Monitor usage - Check your API provider's dashboard regularly
- Anthropic: https://console.anthropic.com/settings/usage
- OpenAI: https://platform.openai.com/usage
Cost comparison for typical coding session:
- Haiku: ~$0.50-2 per day (budget option)
- Sonnet: ~$2-8 per day (recommended)
- Opus: ~$10-50 per day (premium)
OpenClaw is an AI assistant that can:
- Write and modify code across multiple languages
- Execute commands on its host system (with approval)
- Browse files in its workspace
- Use tools like git, npm, pip, docker, etc.
- Access the web to fetch documentation
- Run code and see the results
- Work with git repositories to push/pull changes
┌─────────────────────┐
│ Your Browser │
│ (Control UI) │
└──────────┬──────────┘
│
│ WebSocket
▼
┌─────────────────────┐
│ Gateway │
│ (Manages sessions) │
└──────────┬──────────┘
│
│ API Calls
▼
┌─────────────────────┐
│ AI Provider │
│ (Claude/OpenAI) │
└─────────────────────┘
│
│ Tools/Skills
▼
┌─────────────────────┐
│ Workspace │
│ (~/.openclaw/ │
│ workspace/) │
└─────────────────────┘
Simply type your request in the chat interface. Be specific about what you want:
Good:
Create a Python script that reads a CSV file and calculates the average of the
'price' column, then saves the result to a new file called 'average.txt'
Less Good:
Write a Python script
OpenClaw maintains context in conversations:
You: Create a Node.js Express server with a health check endpoint
OpenClaw: [creates server.js]
You: Now add user authentication with JWT
OpenClaw: [modifies server.js to add auth]
You: Write tests for the authentication
OpenClaw: [creates test file]
OpenClaw can execute commands with your approval:
You: Install the requests library for Python
OpenClaw: I'll run: pip install requests
[Asks for approval]
Approval Modes:
- Interactive: Approve each command (default, safest)
- Auto-approve: Automatically approve trusted commands (configure in settings)
Tell OpenClaw to clone repositories directly:
You: Clone the repository https://github.com/username/project.git into the workspace
OpenClaw will:
- Clone the repository
- Navigate into it
- Be ready to work on the code
Mount a local git repository into OpenClaw's workspace:
# SSH into the VM
ssh ubuntu@<vm-ip>
# Clone your repository into the workspace
cd ~/.openclaw/workspace/
git clone https://github.com/username/project.gitNow in OpenClaw:
You: What files are in the project directory?
For private repositories, configure git credentials on the VM:
ssh ubuntu@<vm-ip>
# Configure git user
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
# Option 1: SSH keys (recommended)
ssh-keygen -t ed25519 -C "your.email@example.com"
cat ~/.ssh/id_ed25519.pub # Add this to GitHub/GitLab
# Configure SSH for GitHub
cat >> ~/.ssh/config << 'EOF'
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
EOF
chmod 600 ~/.ssh/config ~/.ssh/id_ed25519
# Test the connection
ssh -T git@github.com # Should show successful authentication
# Option 2: Personal Access Token
git config --global credential.helper store
# Then clone a repo, enter token when promptedNote for Ansible deployments: The Ansible playbook automatically mounts your ~/.ssh directory and ~/.gitconfig into the OpenClaw container. Once you configure SSH keys on the VM, OpenClaw will immediately have access to them without any additional setup.
Once a repository is accessible, you can ask OpenClaw to:
You: List all files in the project
You: Show me the main function in app.py
You: Create a new branch called 'feature/new-endpoint'
You: Add a new API endpoint to handle user registration
You: Run the tests to make sure everything works
You: Commit these changes with message "Add user registration endpoint"
You: Push the changes to the remote repository
Complete workflow for making changes:
You:
1. Clone https://github.com/username/myproject.git
2. Create a new branch called feature/add-logging
3. Add logging to all functions in utils.py
4. Run the tests
5. If tests pass, commit and push
OpenClaw: [Executes each step with approvals]
OpenClaw comes with various skills enabled by default:
- Read, write, create, delete files
- Search files with grep/ripgrep
- Navigate directories
- View file contents
- Node.js/npm: Install packages, run scripts
- Python/pip: Install packages, run scripts
- Docker: Build, run containers
- Git: All git operations
- Create new files
- Modify existing code
- Refactor functions
- Add comments/documentation
- Fetch URLs to read documentation
- Download files
- Access APIs
- Run shell commands (with approval)
- Check system information
- Monitor processes
ssh ubuntu@<vm-ip> "cd /opt/openclaw && docker compose exec openclaw-gateway openclaw skills list"By default, OpenClaw uses: /home/ubuntu/.openclaw/workspace/
This is mounted into the container at: /home/node/.openclaw/workspace/
Create a structure for different projects:
ssh ubuntu@<vm-ip>
cd ~/.openclaw/workspace/
# Create project directories
mkdir -p projects/web-apps
mkdir -p projects/scripts
mkdir -p projects/experimentsThen in OpenClaw:
You: Navigate to projects/web-apps and list the contents
Everything in the workspace persists across container restarts. Your code and files are safe.
Copy files from your local machine to the workspace:
# From your local machine
scp ./myfile.py ubuntu@<vm-ip>:~/.openclaw/workspace/Good:
Create a REST API in Python using Flask with these endpoints:
- GET /users - list all users
- POST /users - create a new user
- GET /users/{id} - get user by ID
Include error handling and return JSON responses
Less Good:
Make an API
When OpenClaw wants to run commands, review them:
- Read the command carefully
- Understand what it will do
- Approve if safe, reject if unsure
Always work in branches when modifying repositories:
You: Create a new branch for this work
You: Run the tests to verify the changes work correctly
The more context you provide, the better results:
You: This is a Django project using PostgreSQL. I need to add a new model
for tracking user sessions. The model should include user_id, session_token,
created_at, and expires_at fields.
Don't expect perfection on first try:
You: The function works but it's slow for large datasets. Can you optimize it?
You: Explain what this function does and why you chose this approach
You: Create a new Python project called "data-processor" with the following structure:
- src/ directory for source code
- tests/ directory for tests
- requirements.txt with pandas and requests
- README.md with project description
- .gitignore for Python projects
- A main.py file with a basic CLI interface using argparse
You: I have a bug in the process_data function in src/processor.py. When I pass
an empty list, it crashes. Can you:
1. Review the function
2. Identify the issue
3. Fix it
4. Add error handling
5. Write a test case for this scenario
You: Add a caching layer to the API using Redis:
1. Install the redis-py library
2. Create a cache.py module with get/set functions
3. Modify the /users endpoint to check cache first
4. Set cache expiry to 5 minutes
5. Update the README with Redis setup instructions
You: The api/routes.py file is getting too large (over 500 lines). Refactor it by:
1. Separating routes into logical modules (users.py, auth.py, posts.py)
2. Keep the common setup in routes.py
3. Update imports in app.py
4. Ensure all tests still pass
You: Add comprehensive docstrings to all functions in utils/ directory following
the Google Python Style Guide. Include:
- Function description
- Args with types
- Returns with type
- Raises (if applicable)
- Example usage
You: Set up GitHub Actions for this project:
1. Create .github/workflows/test.yml
2. Run tests on push and PR
3. Test on Python 3.9, 3.10, and 3.11
4. Check code formatting with black
5. Run linting with pylint
6. Badge in README showing build status
You: Refactor the authentication system by:
1. Creating a new auth/ directory
2. Moving auth-related functions from utils.py
3. Creating separate modules for jwt_handler.py, validators.py, and models.py
4. Updating all imports across the project
5. Adding type hints to all functions
You: Create a .env.example file with all required environment variables for
this project, and update config.py to load them using python-dotenv
You: Create an Alembic migration to add an 'email_verified' boolean field
to the users table, defaulting to False
You: What can you help me with?
You: How do I [specific task]?
You: Show me examples of [specific feature]
- OpenClaw CLI:
ssh ubuntu@<vm-ip> "cd /opt/openclaw && docker compose exec openclaw-gateway openclaw --help" - Common Commands: COMMON_COMMANDS.md
- SSL Setup: SSL_SETUP.md
If OpenClaw isn't responding:
- Check the connection: Is the WebSocket connected? (Look for status indicator in UI)
- Check API keys: Are they configured correctly?
- Check logs:
ssh ubuntu@<vm-ip> "docker logs openclaw-openclaw-gateway-1 --tail 50" - Check rate limits: Have you hit API rate limits? (Check provider dashboard)
- Restart if needed:
ssh ubuntu@<vm-ip> "cd /opt/openclaw && docker compose restart"
Now that you're familiar with OpenClaw:
- Clone your first project and try modifying some code
- Create a new project from scratch with OpenClaw's help
- Set up git credentials for seamless repository access
- Explore different models to find the best cost/performance balance
- Experiment with different prompting styles to get better results
Happy coding with OpenClaw! 🦞