Teaching OpenClaw New Facts and Preferences

Clawpedia · For Humans

Train your OpenClaw agent to remember custom facts, preferences, and behavioral rules.

Overview

OpenClaw learns from every interaction, but sometimes you want to teach it something specific — a fact it should always remember, a preference for how it behaves, or specialized knowledge it wouldn't have otherwise. This guide shows how to explicitly teach your agent and shape its behavior.

Methods of Teaching

MethodBest ForPersistence
ConversationalQuick facts, correctionsLong-term memory
Memory CLIBulk additions, structured dataLong-term memory
System promptCore behavior, personalityPermanent (config)
Custom instructions fileDetailed rules, domain knowledgePermanent (file)

Conversational Teaching

Skill promptsTask-specific expertisePer-skill

The most natural way — just tell your agent:

Teaching Facts


User: "Remember that my car is a Tesla Model 3"
Agent: "Got it! I've noted that your car is a Tesla Model 3."

User: "My office address is Friedrichstraße 123, Berlin"
Agent: "Saved. Your office is at Friedrichstraße 123, Berlin."

User: "Sarah's birthday is September 22"
Agent: "Noted — Sarah's birthday is September 22. Want me to remind you?"

Teaching Preferences


User: "I prefer short, bullet-point answers"
Agent: "Understood. I'll keep my responses concise with bullet points."

User: "Always show code examples in TypeScript, not JavaScript"
Agent: "Got it — TypeScript examples from now on."

User: "When I ask about restaurants, prioritize vegetarian options"
Agent: "Noted. I'll focus on vegetarian options when suggesting restaurants."

Making Corrections


User: "Actually, I moved to Munich last month"
Agent: "Updated! I've changed your location from Berlin to Munich.
        I'll adjust weather, events, and recommendations accordingly."

User: "I said TypeScript, not Python"
Agent: "Sorry about that! I've updated my preference to always use
        TypeScript for code examples."

Verifying What Was Learned


User: "What do you know about me?"
Agent: "Here's what I remember:
        
        📋 Personal:
        - Name: Alice
        - Location: Munich (moved from Berlin)
        - Car: Tesla Model 3
        
        💼 Work:
        - Company: Acme Corp
        - Role: Senior Developer
        - Manager: Sarah
        
        ⚙️ Preferences:
        - Short, bullet-point responses
        - TypeScript for code
        - Metric units
        - Vegetarian restaurants
        
        Want me to correct or add anything?"

Teaching via CLI

For structured or bulk additions:


# Add individual facts
openclaw memory add "Team meeting is every Tuesday at 10 AM"
openclaw memory add "Project codebase uses React and TypeScript"
openclaw memory add "Preferred editor: VS Code"

# Add with type classification
openclaw memory add --type preference "Always explain the 'why' behind recommendations"
openclaw memory add --type fact "Company fiscal year ends in March"
openclaw memory add --type contact "Dr. Smith, dentist, +49 30 555 1234"

# Add with tags
openclaw memory add "Sprint velocity is ~35 story points" --tags work,agile

Bulk Import

Teach many facts at once from a file:


[
  {
    "type": "fact",
    "content": "Team uses Jira for project management",
    "tags": ["work", "tools"]
  },
  {
    "type": "preference",
    "content": "Prefers Markdown tables over plain text for comparisons",
    "confidence": 0.95
  },
  {
    "type": "contact",
    "content": "Alex Chen, CTO, alex@company.com",
    "tags": ["work", "leadership"]
  }
]

openclaw memory import facts.json

Teaching via System Prompt

For permanent behavioral rules that should always apply:


# config.yaml
agent:
  system_prompt: |
    You are Alice's personal assistant.
    
    Core rules:
    - Be concise. Max 3 sentences unless asked for detail.
    - Use bullet points for lists.
    - Code examples in TypeScript only.
    - Use metric units.
    - Time in 24-hour format.
    
    Domain knowledge:
    - Alice works at Acme Corp as a Senior Developer.
    - The tech stack is React, TypeScript, Node.js, PostgreSQL.
    - Deployment is on AWS (ECS + RDS).
    
    Communication:
    - Casual but professional tone.
    - No emojis in technical discussions.
    - Emojis OK in casual conversations.

Teaching via Custom Instructions File

For extensive domain knowledge, use a dedicated file:


# Create a custom instructions file
mkdir -p ~/.openclaw/instructions/
cat > ~/.openclaw/instructions/work-context.md << 'EOF'
# Work Context

## Team
- Alice (me): Senior Developer, frontend lead
- Sarah: Project Manager
- John: Backend Developer
- Lisa: UX Designer

## Project: Phoenix
- Rewrite of the legacy billing system
- Tech stack: React 18, TypeScript, tRPC, PostgreSQL
- Sprint length: 2 weeks
- Stand-up: Tuesday and Thursday at 10 AM

## Coding Standards
- Use functional components with hooks
- State management: Zustand
- Testing: Vitest + Testing Library
- PRs require 2 approvals

## Deployment
- Staging: auto-deploy on merge to `develop`
- Production: manual approval on `main`
- CI/CD: GitHub Actions
EOF

Reference it in config:


agent:
  instructions_files:
    - ~/.openclaw/instructions/work-context.md

Teaching Specialized Knowledge

Internal APIs


User: "Remember our API conventions:
        - All endpoints start with /api/v2/
        - Authentication via Bearer token
        - Pagination uses cursor-based pagination
        - Error format: {error: {code: string, message: string}}
        - Rate limit: 100 requests per minute"

Agent: "Saved. I'll follow these conventions when helping with API work."

Project-Specific Terminology


User: "In our project, 'Phoenix' refers to the billing rewrite,
        'Hydra' is the auth service, and 'Cerberus' is the
        API gateway. Remember these codenames."

Agent: "Got it! Project codenames saved:
        - Phoenix = billing rewrite
        - Hydra = auth service
        - Cerberus = API gateway"

Teaching Strategies

Progressive Teaching

Start with basics, add detail over time:


Week 1: "I work at a software company"
Week 2: "My team builds a billing system"
Week 3: "We use React and TypeScript"
Week 4: "Our deployment pipeline uses GitHub Actions"

The agent builds a richer understanding progressively.

Feedback Loop

Correct and refine continuously:


Agent: "Here's a Python implementation..."
User: "I told you, always use TypeScript"
Agent: "Sorry! Here's the TypeScript version...
        (I've reinforced this preference)"

Negative Teaching

Tell the agent what NOT to do:


User: "Never suggest using var in JavaScript — always const or let"
User: "Don't recommend MongoDB for our use case — we're committed to PostgreSQL"
User: "Stop adding disclaimers to every response"

Verifying and Managing Teachings


# View everything the agent knows
openclaw memory list --type long-term

# Search for specific teachings
openclaw memory search "TypeScript"

# View by category
openclaw memory list --category preferences
openclaw memory list --category facts

# Delete incorrect teachings
openclaw memory delete --search "old project" --confirm

# Export all teachings
openclaw memory export --type long-term --format readable

Troubleshooting

Agent Doesn't Remember What I Taught

Agent Follows Old Instructions

System Prompt Changes Don't Take Effect

System prompt changes require a restart:


openclaw restart

Next Steps

Related Articles