Install & Configure
Getting OpenClaw Running
Configuration Is Your First Line of Defense
Before your agent runs a single command, its behavior is shaped by configuration files. A misconfigured agent is more dangerous than no agent at all — it can delete files, leak secrets, or burn through API credits.
OpenClaw's configuration lives in two files: agent-config.yaml for general settings and safety-rules.json for permission boundaries.
Agent Configuration Anatomy
The config/agent-config.yaml file controls the agent's identity and behavior:
| Setting | Purpose | Safety Impact |
|---|---|---|
| `agent_name` | Human-readable identifier | Appears in audit logs — helps distinguish agents |
| `model` | Which LLM to use | Affects cost, speed, capability, and data privacy |
| `max_tokens_per_request` | Token limit per API call | Prevents runaway costs on single requests |
| `working_directory` | Where the agent operates | Limits the blast radius of mistakes |
| `dry_run` | Simulate actions without executing | Essential for testing new configurations |
Model Selection Tradeoffs
Choosing a model is a multi-dimensional decision:
| Factor | Local Model | Cloud API |
|---|---|---|
| Privacy | Data never leaves your machine | Data sent to provider |
| Cost | One-time hardware cost | Per-token charges |
| Speed | Depends on your GPU | Usually faster |
| Capability | Limited by model size | Access to frontier models |
| Offline | Works without internet | Requires connectivity |
For personal automation, a local model is often the safest default. For complex reasoning tasks, cloud APIs with strong permission controls are worth the tradeoff.
Working Directory Restrictions
The most important safety decision is where your agent can operate. Think of it as the blast radius:
/ or ~) — agent can access anything, including SSH keys, credentials, and system files~/agent-workspace) — agent is safe but can't automate real tasksYour safety-rules.json defines this with allow-lists:
allowed_read_dirs — where the agent can read filesallowed_write_dirs — where the agent can create or modify filesblocked_paths — absolute deny-list that overrides allows (e.g., ~/.ssh, ~/.env)API Key Management
Never hardcode API keys in configuration files. Instead:
export OPENCLAW_API_KEY=sk-... in your shell profile.env file in the project root (add to .gitignore immediately)If your agent config file ends up in a git repo with an API key, you've just published it to the world.
Dry-Run Mode
Always test new configurations in dry-run mode first. In dry-run:
Think of dry-run as a flight simulator. You practice the full procedure without any risk.
First Run Checklist
Before starting your agent for the first time:
agent-config.yamlsafety-rules.json — are the allowed directories correct?dry_run: true in the configdry_run: falseKey Takeaways
This is chapter 2 of Open Source AI Agents (OpenClaw).
Get the full hands-on course — free during early access. Build the complete system. Your projects become your portfolio.
View course details