Skip to main content
ByteRover integrates with OpenClaw to provide persistent, structured memory for your AI agents. An automated setup script configures three features:
  • Automatic Memory Flush — Curates insights to ByteRover when the context window fills up
  • Daily Knowledge Mining — Schedules a cron job to extract and store patterns from session notes
  • ByteRover Context Plugin — Injects relevant memory context into every prompt via a hook-based plugin

Prerequisites

Before running the script, ensure the following are installed and available in your PATH:
RequirementHow to install
Node.jsnodejs.org
OpenClaw CLI (openclaw)docs.openclaw.ai/install
Clawhub (clawhub)Via OpenClaw’s skill system — install from the OpenClaw gateway console UI
ByteRover CLI (brv)docs
The script verifies each prerequisite and stops with a clear error message if anything is missing. If the byterover Clawhub skill is not installed, the script will attempt to install it automatically.

Quick Start

Run the script with a single command:
curl -fsSL https://byterover.dev/openclaw-setup.sh | sh
The script is interactive — it will prompt you to enable or disable each feature individually.

What the Script Does

Phase 1: Pre-flight Checks

The script verifies all prerequisites are met:
  1. Node.js is installed
  2. Clawhub is installed
  3. ByteRover skill is available in Clawhub (auto-installs via clawhub install --force byterover if missing)
  4. ByteRover CLI (brv) is installed
  5. OpenClaw CLI (openclaw) is installed
  6. Config file (~/.openclaw/openclaw.json) exists and is valid JSON
After checks pass, the script creates a timestamped backup of your config file (e.g., openclaw.json.bak.20260226120000). If the script encounters an error at any point, the backup is automatically restored.

Phase 2: Feature Configuration

You are prompted to enable or disable each feature. Declining a previously enabled feature will cleanly remove its configuration.

Feature 1: Automatic Memory Flush

Prompt: Enable Automatic Memory Flush? (y/N) When enabled, this patches openclaw.json to automatically curate insights to ByteRover when the agent’s context window approaches compaction. The agent will:
  1. Review the session for architectural decisions, bug fixes, or new patterns
  2. Run brv curate "<summary>" to save valuable knowledge to the context tree
  3. Write personal session notes to memory/YYYY-MM-DD.md
Config changes (added to openclaw.json):
{
  "agents": {
    "defaults": {
      "compaction": {
        "reserveTokensFloor": 50000,
        "memoryFlush": {
          "enabled": true,
          "softThresholdTokens": 4000,
          "systemPrompt": "Session nearing compaction. Store durable memories now.",
          "prompt": "Review the session for any architectural decisions, bug fixes, or new patterns. If found, run 'brv curate \"<summary of change>\"' to update the context tree. Also write personal notes to memory/YYYY-MM-DD.md. Reply NO_REPLY if nothing to store."
        }
      }
    }
  }
}
Learn more about compaction behavior in the OpenClaw memory flush documentation.

Feature 2: Daily Knowledge Mining

Prompt: Enable Daily Knowledge Mining? (y/N) When enabled, schedules a daily cron job via openclaw cron add that runs at 9:00 AM every day. The cron job:
  1. Reads the latest file in memory/ (e.g., memory/2026-02-26.md)
  2. Extracts architectural decisions, reusable patterns, or critical bug fixes
  3. Runs brv curate "<summary>" to save findings to the context tree
PropertyValue
NameByteRover Knowledge Miner
Schedule0 9 * * * (daily at 9 AM)
Sessionisolated
AnnouncementsEnabled
If a cron job with the same name already exists, the script skips creation.
Learn more about cron automation in the OpenClaw cron jobs documentation.

Feature 3: ByteRover Context Plugin

Prompt: Install ByteRover Context Plugin? (y/N) When enabled, installs a custom OpenClaw plugin that automatically enriches every prompt with relevant context from your ByteRover knowledge base. The plugin:
  1. Intercepts the before_prompt_build event
  2. Extracts the user’s query from the prompt
  3. Runs brv query "<user query>" to retrieve relevant context
  4. Prepends the results as a ## ByteRover Context (Auto-Enriched) section
Files created:
FileLocationDescription
index.ts~/.openclaw/extensions/byterover/Plugin implementation (TypeScript)
openclaw.plugin.json~/.openclaw/extensions/byterover/Plugin manifest
Config changes (added to openclaw.json):
{
  "plugins": {
    "entries": {
      "byterover": { "enabled": true }
    }
  }
}

Phase 3: Workspace Protocol Updates

The script scans your openclaw.json for configured agent workspaces and appends ByteRover protocol sections to:
  • AGENTS.md — Adds a ## Knowledge Protocol (ByteRover) section with instructions for agents to use brv query and brv curate
  • TOOLS.md — Adds a ## ByteRover (Memory) section with command reference for brv query, brv curate, brv pull, and brv push
These updates are idempotent — if the sections already exist, they are skipped.

How It Works

OpenClaw agents use multiple workspaces — one per agent:
~/.openclaw/workspace/                  # Main agent workspace
~/.openclaw/workspace-/        # Sub-agent workspace
The script scans openclaw.json for configured workspaces and updates their protocol files (AGENTS.md, TOOLS.md) with ByteRover usage instructions. The .brv/ context tree directory is created automatically on first use — when an agent runs brv curate or brv query in a workspace:
~/.openclaw/workspace/.brv/
~/.openclaw/workspace/.brv/context-tree/
All ByteRover operations execute against the .brv directory in the current workspace.
To manually run ByteRover commands (brv pull, brv push, brv curate, brv query), first cd into the appropriate workspace directory so the CLI finds the correct .brv context tree.

Uninstalling / Disabling Features

Re-run the script and decline each feature when prompted. The script will cleanly remove:
  • Memory Flush — Removes compaction.memoryFlush and compaction.reserveTokensFloor from openclaw.json
  • Daily Knowledge Mining — Removes the ByteRover Knowledge Miner cron job via openclaw cron remove
  • Context Plugin — Removes plugin files from ~/.openclaw/extensions/byterover/ and disables the plugin entry in openclaw.json
# Re-run and decline features to disable them
curl -fsSL https://byterover.dev/openclaw-setup.sh | sh

Troubleshooting

Cause: OpenClaw has not been initialized.Solution: Install and run OpenClaw first: https://docs.openclaw.ai/install
Cause: Your ~/.openclaw/openclaw.json is corrupted.Solution: Restore from a backup. The script automatically reverts to the backup if an error occurs during patching. To restore manually:
# List available backups
ls ~/.openclaw/openclaw.json.bak.*

# Restore the most recent backup
cp ~/.openclaw/openclaw.json.bak.<timestamp> ~/.openclaw/openclaw.json
Cause: The brv command is not in your PATH.Solution: Install the ByteRover CLI docs
Cause: The clawhub command is not installed.Solution: Clawhub is part of the OpenClaw ecosystem. Refer to the Clawhub installation guide or install it from the OpenClaw gateway console UI.
Cause: The OpenClaw CLI does not support cron commands or the command failed.Solution: Ensure the OpenClaw CLI supports cron commands:
openclaw cron list
If the command is not recognized, update OpenClaw to the latest version.
Cause: Plugin files are missing, brv is not in PATH, or the plugin is not enabled.Solution:
  1. Verify plugin files exist:
    ls ~/.openclaw/extensions/byterover/
    
  2. Check that brv is in your PATH:
    which brv
    
  3. Check the plugin is enabled in config:
    cat ~/.openclaw/openclaw.json | grep -A2 byterover
    

File Reference

PathDescription
~/.openclaw/openclaw.jsonOpenClaw configuration (patched by script)
~/.openclaw/openclaw.json.bak.*Timestamped config backups
~/.openclaw/{workspace}/.brv/ByteRover context tree storage
~/.openclaw/extensions/byterover/index.tsContext plugin source
~/.openclaw/extensions/byterover/openclaw.plugin.jsonPlugin manifest

Next Steps