What is OpenClaw?#
OpenClaw is an open-source autonomous AI coding agent created by Nous Research. It runs in your terminal, has persistent memory, can browse the web, write code, manage files, and continuously improve itself. Think of it as a self-improving AI developer that lives on your server.
This guide will walk you through setting up OpenClaw on a Linux server (Ubuntu 24.04) from scratch.
Prerequisites#
Before starting, make sure you have:
- A Linux server (Ubuntu 22.04+ / 24.04 recommended)
- Root or sudo access
- Node.js 18+ and npm
- Git
- A terminal (SSH into your server)
Step 1: Install Node.js and npm#
OpenClaw runs on Node.js. If you don’t have it installed yet:
# Install Node.js 20.x (LTS)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# Verify installation
node --version
npm --versionStep 2: Install OpenClaw#
OpenClaw is distributed as an npm package. Install it globally:
npm install -g openclawVerify the installation:
openclaw --versionStep 3: Set Up Your Provider Key#
OpenClaw needs access to an LLM provider. The easiest is to use an OpenAI-compatible API key.
# Set your API key as an environment variable
export OPENAI_API_KEY="sk-your-api-key-here"
# Or use a different provider
export ANTHROPIC_API_KEY="sk-ant-your-key-here"To make the key persistent, add it to your ~/.bashrc:
echo 'export OPENAI_API_KEY="sk-your-api-key-here"' >> ~/.bashrc
source ~/.bashrcStep 4: Initialize Your OpenClaw Workspace#
Create a workspace directory and initialize OpenClaw:
# Create a workspace
mkdir -p ~/my-openclaw-workspace
cd ~/my-openclaw-workspace
# Initialize OpenClaw
openclaw initThis creates the workspace structure including:
AGENTS.md— defines your agent’s personality and behaviorSOUL.md— the agent’s core identityTOOLS.md— tool configurationmemory/— persistent memory directoryskills/— plugin skills directory
Step 5: Configure Your Agent#
Edit AGENTS.md to customize your agent’s behavior:
nano ~/my-openclaw-workspace/AGENTS.mdKey sections to configure:
- Identity: Who the agent is (name, purpose)
- Behavior: How it interacts (proactive, passive, etc.)
- Safety: Guardrails and restricted actions
- Memory: How it stores and retrieves information
Step 6: Start OpenClaw#
Launch OpenClaw in interactive mode:
openclawYou should see the agent’s prompt, ready for your first command. Try asking it something simple:
“Hello! What can you do?”
Step 7: Run OpenClaw as a Service (Optional)#
For production use, run OpenClaw as a systemd service:
sudo nano /etc/systemd/system/openclaw.serviceAdd the following:
[Unit]
Description=OpenClaw Autonomous AI Agent
After=network.target
[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/my-openclaw-workspace
ExecStart=/usr/bin/openclaw
Restart=on-failure
RestartSec=10
Environment=OPENAI_API_KEY=sk-your-api-key-here
[Install]
WantedBy=multi-user.targetEnable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable openclaw
sudo systemctl start openclaw
sudo systemctl status openclawStep 8: Connect OpenClaw to External Tools#
OpenClaw can integrate with:
- GitHub: Clone repos, create PRs, review code
- Slack/Discord/Telegram: Chat with the agent from messaging apps
- Browser: Give it web browsing capabilities
- Terminal: Full shell access for system administration
Configure these in TOOLS.md:
nano ~/my-openclaw-workspace/TOOLS.mdStep 9: Troubleshooting#
“Command not found” after install#
Make sure npm global bin is in your PATH:
export PATH="$PATH:$(npm config get prefix)/bin"
echo 'export PATH="$PATH:$(npm config get prefix)/bin"' >> ~/.bashrcConnection errors#
Check your API key is set correctly:
echo $OPENAI_API_KEYPermission denied#
Ensure your workspace directory is writable:
chmod -R 755 ~/my-openclaw-workspaceNext Steps#
Now that OpenClaw is running, explore:
- Install skills:
openclaw skill add <skill-name> - Persistent memory: The agent remembers across sessions
- Web search: Let it research topics for you
- Code generation: Ask it to write full applications
- Self-improvement: OpenClaw can modify its own config
Conclusion#
You now have a fully functional autonomous AI agent running on your server. OpenClaw is a powerful tool that can automate coding tasks, manage your infrastructure, and continuously learn from interactions.
The key to getting the most out of OpenClaw is:
- Write good AGENTS.md — the better your agent definition, the better the results
- Use memory effectively — the agent learns over time if you let it
- Install relevant skills — extend its capabilities with plugins
- Give it autonomy — the more you trust it, the more it can do
Happy coding with your new AI agent! 🚀