This file provides guidance to Claude Code when working with the OpenClaw package inside the Basic Memory monorepo.
@basicmemory/openclaw-basic-memory is a TypeScript OpenClaw plugin that integrates Basic Memory with the OpenClaw agent framework. It lives under integrations/openclaw/ in the monorepo, manages a persistent MCP stdio session to a bm mcp process, exposes 14 agent tools (including workspace/project management and cross-project operations), composited memory search/get providers, slash commands, CLI commands, and optional auto-capture of conversations.
# Install dependencies (uses Bun)
bun install
# Run all unit tests (Bun native test runner)
bun test
# Run a single test file
bun test tools/search-notes.test.ts
# Integration tests (requires basic-memory CLI installed)
bun run test:int
# Type checking (no emit)
bun run check-types
# Lint (Biome)
bun run lint
# Lint + auto-fix
bun run lint:fix
# All quality checks (fetch skills + type-check + lint + build + tests)
just check
# Release readiness (check + npm pack dry-run)
just release-checkThe default export is an OpenClaw plugin object (id: "openclaw-basic-memory", kind: "memory"). The register(api) function:
- Parses config via
parseConfig()fromconfig.ts - Creates a
BmClientinstance (the MCP stdio client) - Registers all tools, providers, hooks, commands, and the service lifecycle
- The service
start()launches the MCP process (bm mcp --transport stdio), ensures the project exists, and sets the workspace directory - The service
stop()tears down the MCP connection
Central orchestration layer that:
- Spawns and manages a persistent
bm mcp --transport stdiochild process via@modelcontextprotocol/sdk - Validates the
REQUIRED_TOOLSlist at connect time - Implements reconnection with bounded retries (500ms, 1s, 2s exponential backoff)
- Distinguishes recoverable errors (broken pipe, transport closed) from fatal errors
- All tool calls require
output_format: "json"and extractstructuredContent.result - Public methods:
search,readNote,writeNote,editNote,deleteNote,moveNote,buildContext,recentActivity,indexConversation,ensureProject,listProjects,listWorkspaces,schemaValidate,schemaInfer,schemaDiff - All content methods accept an optional
projectparameter for cross-project operations listProjectsaccepts an optionalworkspaceparameter for workspace-scoped listing
Each tool file exports a function that calls api.registerTool() with a TypeBox schema and handler. Tools delegate to BmClient methods and return OpenClaw-standard responses ({ content: [{type: "text", text}], details? }).
search-notes.ts,read-note.ts,write-note.ts,edit-note.ts,delete-note.ts,move-note.ts,build-context.ts,list-memory-projects.ts,list-workspaces.ts,schema-validate.ts,schema-infer.ts,schema-diff.ts— thin wrappers aroundBmClient; all content tools accept an optionalprojectparam for cross-project operationsmemory-provider.ts— compositedmemory_search+memory_getproviders.memory_searchqueries 3 sources in parallel: MEMORY.md (grep), BM knowledge graph (FTS + vector), and active task notes (YAML frontmatter scan)
commands/slash.ts—/rememberand/recallslash commandscommands/cli.ts—openclaw basic-memory <subcommand>CLI registrationhooks/capture.ts— auto-capture hook onagent_endevents, writes timestamped daily conversation notes
Flexible config with defaults, snake_case aliases (memory_dir/memory_file), tilde/relative/absolute path resolution, and unknown-key validation. Cloud routing is configured through bm cloud and per-project BM settings, not plugin config.
- TypeBox schemas (
@sinclair/typebox) for all tool parameter validation - Bun-native test runner with
describe/it/expectandjest.fn()mocking - ES modules (
"type": "module"in package.json) - Biome for linting and formatting (configured in
biome.json) - Build output —
bun run buildemitsdist/forruntimeExtensions; TypeScript source also stays in the package for source-compatible hosts - Strict TypeScript with
noEmit(type-checking only)
- Unit tests live alongside source files (
*.test.ts) and mockBmClient/OpenClawPluginApi - Integration tests in
integration/launch a realbm mcpprocess against a temp project scripts/bm-local.shruns BM from the monorepo root viauv run --project ...when available, then falls back tobmon PATH
- Package CI (root
.github/workflows/consolidated-packages.yml): validates skills, typechecks, lints, builds, tests, and runsnpm pack --dry-run. - Release (root
.github/workflows/release.yml): runs from Basic Memory tags and publishes this npm package after the Python release job. Version bumps are handled by the rootjust release/just betarecipes.
- Runtime:
@modelcontextprotocol/sdk(MCP client/transport),@sinclair/typebox(schema validation) - Peer:
openclaw(>=2026.5.2) - Dev:
typescript,@biomejs/biome,@types/node - External: Basic Memory CLI (
bm) must be installed separately (Python, installed viauv)
Runtime agent guidance lives in the tool descriptions under tools/ and the bundled skills/.
Longer tool-usage notes for humans are in docs/agent-guide.md.