Skip to main content

OpenClaw Setup Guide: Step-by-Step from Zero to Running

·671 words·4 mins· ·

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 --version

Step 2: Install OpenClaw
#

OpenClaw is distributed as an npm package. Install it globally:

npm install -g openclaw

Verify the installation:

openclaw --version

Step 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 ~/.bashrc

Step 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 init

This creates the workspace structure including:

  • AGENTS.md — defines your agent’s personality and behavior
  • SOUL.md — the agent’s core identity
  • TOOLS.md — tool configuration
  • memory/ — persistent memory directory
  • skills/ — plugin skills directory

Step 5: Configure Your Agent
#

Edit AGENTS.md to customize your agent’s behavior:

nano ~/my-openclaw-workspace/AGENTS.md

Key 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:

openclaw

You 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.service

Add 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.target

Enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable openclaw
sudo systemctl start openclaw
sudo systemctl status openclaw

Step 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.md

Step 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"' >> ~/.bashrc

Connection errors
#

Check your API key is set correctly:

echo $OPENAI_API_KEY

Permission denied
#

Ensure your workspace directory is writable:

chmod -R 755 ~/my-openclaw-workspace

Next 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:

  1. Write good AGENTS.md — the better your agent definition, the better the results
  2. Use memory effectively — the agent learns over time if you let it
  3. Install relevant skills — extend its capabilities with plugins
  4. Give it autonomy — the more you trust it, the more it can do

Happy coding with your new AI agent! 🚀