Build autonomous AI agents with OpenClaw. Create personalities, manage memory, coordinate with other agents, and integrate with knowledge systems.
An OpenClaw agent is:
Create SOUL.md in your workspace:
# SOUL.md - Who I Am
## Core Identity
- Name: My Agent Name
- Role: What you do
- Vibe: How you communicate
## Core Truths
1. Be genuinely helpful, not performatively helpful
2. Have opinions and preferences
3. Be resourceful before asking for help
4. Earn trust through competence
## Boundaries
- Don't exfiltrate private data
- Ask before taking external actions (emails, posts, etc.)
- Be careful with destructive commands
- Never bypass safeguards
## What You're Good At
- List your strengths
- What problems you solve
- Your specialization
Your agent has three memory layers:
| Layer | File | Purpose | Retention |
|---|---|---|---|
| Session | Current context | Current conversation | This turn only |
| Daily | memory/YYYY-MM-DD.md | Raw logs, what happened today | Searchable, 30+ days |
| Long-term | MEMORY.md | Curated wisdom, decisions, patterns | Forever (human-maintained) |
# Daily memory: memory/2026-03-21.md
## Session 1 (14:00)
- Built RAG system for team
- Learned: FAISS + SQLite works well for small teams
- Decision: Use shared vector store, not per-agent
## Session 2 (16:00)
- Deployed to production
- Next: Monitor performance, scale if needed
---
# Long-term memory: MEMORY.md
## Team Infrastructure
- RAG System running on dedicated inference server
- Vector store: FAISS + SQLite (no distributed DB needed yet)
- Agents: Kernel (systematic), Shannon (exploratory)
- Status: Production ✅
## Key Learnings
- Shared index with per-agent profiles > per-agent indexes
- FAISS fast enough for <1M chunks
- SQLite metadata: keep it denormalized for speed
Bundle capabilities as skills:
# ~/.openclaw/skills/my-skill/SKILL.md
# My Skill
Use this skill for:
## Installation
## Usage
## Commands
- skill-command [args] — what it does
See clawhub.com for community skills (GitHub auth, email, weather, etc.).
// Query the RAG system
const rag = require('./rag-client');
const context = await rag.retrieve({
query: "How do I set up authentication?",
agent_id: "systematic",
k: 5
});
// Use context in your response
const answer = `Based on our knowledge base:\n${
context.chunks.map(c => `- ${c.text}`).join('\n')
}`;
// Use local models instead of cloud APIs
const ollama = require('ollama');
const response = await ollama.generate({
model: "qwen2.5:7b",
prompt: "Explain Fiber protocol",
stream: false
});
console.log(response.response);
Spawn other agents to handle tasks:
// Spawn a research agent
const research = await sessions.spawn({
task: "Research CKB light client architecture",
agentId: "researcher",
model: "anthropic/claude-sonnet-4-5"
});
// Get result
const findings = await research.wait();
console.log(findings);
// Or run in background
const bg = sessions.spawn({
task: "Background job",
mode: "session" // persistent session
});
// Main continues immediately
# HEARTBEAT.md - What you do automatically
## Health Check (every hour)
- Verify all services running
- Alert if any down
## Daily Backup (1x/day at 4pm)
- Commit to git
- Rsync to secondary location
## Weekly Summary (Sundays at 9am)
- Summarize what happened
- Plan for next week
# Listen for messages and respond
- If mentioned in group chat → participate
- If task added to queue → pick it up
- If error occurs → investigate and fix
1. Read research/queue.md for tasks
2. Find next PENDING task (HIGH > MEDIUM > LOW)
3. Fetch seed URLs, verify reachable
4. Call Gemini 2.5 Flash with ground truth
5. Write findings to research/findings/
6. Ingest to RAG system (auto-sync)
7. Auto-generate follow-up tasks
8. Update heartbeat-state.json
9. Loop (next task)
Cost: ~$0.03-0.05 per task (Gemini 2.5 Flash)
Yield: 5-10 new knowledge chunks per task
# Run locally first
openclaw agent run --config openclaw.json --local
# Test with safe API key (limited quota)
export API_KEY=test-key-with-limit
# Verify memory system
ls memory/
cat MEMORY.md
# Check logs
tail -100 ~/.openclaw/logs/agent.log
# Then deploy to production
openclaw agent deploy --production