skills/memories-dev/SKILL.md
Developer guide for contributing to and extending the memories.sh codebase. Use when: (1) Understanding the memories.sh architecture and lifecycle model, (2) Adding new CLI commands or MCP tools, (3) Modifying the memory storage layer (SQLite/libSQL), (4) Working on the web dashboard (Next.js/Supabase), (5) Adding new generation targets for AI tools, (6) Extending cloud sync, session compaction, or embeddings functionality, (7) Debugging build, test, or deployment issues in the monorepo.
npx skillsauth add webrenew/memories memories-devInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Developer guide for contributing to the memories.sh monorepo.
memories/
├── packages/
│ ├── cli/ # @memories.sh/cli (npm package)
│ │ ├── src/
│ │ │ ├── commands/ # CLI commands (Commander.js)
│ │ │ ├── lib/ # Core: db, memory, auth, embeddings, git
│ │ │ └── mcp/ # MCP server (stdio + HTTP)
│ │ ├── tsup.config.ts # Build config
│ │ └── package.json
│ └── web/ # Next.js marketing + dashboard
│ ├── src/app/ # App Router pages + API routes
│ ├── src/components/ # UI components (shadcn/ui)
│ ├── src/lib/ # Auth, Stripe, Supabase, Turso
│ └── content/docs/ # Fumadocs documentation
├── supabase/ # Database migrations
├── skills/ # Distributable skills (this directory)
└── pnpm-workspace.yaml
db.ts (SQLite/libSQL, migrations, FTS5)
↓
memory.ts (CRUD, context, lifecycle sessions, compaction, consolidation, streaming)
↑ ↑ ↑
openclaw-memory.ts reminders.ts embeddings.ts (Xenova/Transformers, cosine similarity)
↑ ↑
git.ts openclaw.ts command bridge
↓
Commands ← auth.ts, turso.ts, config.ts, setup.ts
↓
MCP Server (stdio + StreamableHTTP transports)
↳ registerCoreTools (core + lifecycle + consolidation + reminders)
↳ registerStreamingTools (SSE chunk pipelines)
| File | Purpose |
|------|---------|
| db.ts | SQLite via libSQL. Schema migrations, FTS5 triggers, getDb() singleton |
| memory.ts | Memory operations: add/search/list/forget/update, getContext, sessions, compaction checkpoints, consolidation, streaming |
| openclaw-memory.ts | OpenClaw file-mode contract (memory.md, daily logs, snapshots), workspace path resolution, read/write helpers |
| embeddings.ts | Local embeddings via Xenova/Transformers. generateEmbedding(), cosine similarity |
| git.ts | getProjectId() — derives project ID from git remote URL |
| auth.ts | Cloud auth token storage, device code flow helpers |
| turso.ts | Turso embedded replica sync (cloud ↔ local) |
| config.ts | YAML config read/write (~/.config/memories/) |
| setup.ts | Tool detection (Cursor, Claude, Windsurf, VS Code), MCP config setup |
| templates.ts | Built-in memory templates (decision, error-fix, api-endpoint, etc.) |
| ui.ts | Terminal styling: chalk, figlet, gradient, boxen |
SQLite with FTS5 full-text search:
startMemorySession() creates memory_sessions row and can preload OpenClaw bootstrap context when file mode is enabled.checkpointMemorySession() records meaningful events in memory_session_events.writeAheadCompactionCheckpoint() writes a checkpoint before destructive context compaction and logs memory_compaction_events.createMemorySessionSnapshot() stores raw markdown snapshots in DB and optionally mirrors to OpenClaw snapshot files.consolidateMemories() merges duplicates/supersedes stale entries and records memory_consolidation_runs.packages/cli/src/commands/mycommand.ts:import { Command } from "commander";
export const myCommand = new Command("mycommand")
.description("What it does")
.argument("<required>", "Description")
.option("-f, --flag <value>", "Description", "default")
.action(async (required, opts) => {
// Use lib functions from ../lib/
// Use ui.ts for styled output
});
packages/cli/src/index.ts:import { myCommand } from "./commands/mycommand.js";
program.addCommand(myCommand);
packages/cli/src/commands/mycommand.test.ts.Edit packages/cli/src/mcp/tools.ts (and streaming-tools.ts for chunked ingestion):
server.tool(
"tool_name",
"Description of what the tool does",
{
param: z.string().describe("Parameter description"),
},
async ({ param }) => {
// Implementation
return {
content: [{ type: "text", text: "Result" }],
};
}
);
Parameters use Zod schemas. Return { isError: true } for errors.
Notes:
registerCoreTools() for standard/lifecycle tools.packages/cli/src/lib/templates.tspackages/cli/src/lib/setup.tspackages/web/content/docs/integrations/pnpm build # Build all packages
pnpm typecheck # TypeScript checks
pnpm test # Run all tests (vitest)
# CLI-specific
cd packages/cli
pnpm dev # Watch mode (tsup)
pnpm test # CLI tests only
# Web-specific
cd packages/web
pnpm dev # Next.js dev server
pnpm build # Production build
| Layer | Technology | |-------|-----------| | CLI framework | Commander.js | | Database | libSQL (SQLite-compatible) | | Full-text search | FTS5 | | Embeddings | Xenova/Transformers (local) | | MCP SDK | @modelcontextprotocol/sdk | | Build | tsup (CLI), Next.js (web) | | Web framework | Next.js 15 (App Router) | | Auth | Supabase Auth | | Cloud sync | Turso embedded replicas | | Payments | Stripe | | Docs | Fumadocs | | UI | shadcn/ui, Tailwind CSS v4 | | Testing | Vitest |
tools
OpenClaw integration workflows for memories.sh. Use when: (1) Setting up OpenClaw with memories.sh (`openclaw onboard`, `memories init`), (2) Syncing OpenClaw workspace contracts (`~/.openclaw/workspace/AGENTS.md`, `SOUL.md`, `TOOLS.md`, `IDENTITY.md`, `USER.md`, `HEARTBEAT.md`, `BOOTSTRAP.md`, memory files, and skills), (3) Running lifecycle memory file workflows via `memories openclaw memory bootstrap|flush|snapshot|sync`, (4) Scheduling reminder prompts for OpenClaw refresh via `memories reminders`, (5) Troubleshooting OpenClaw workspace drift, missing skills, or path/config mismatches, (6) Updating OpenClaw runbooks or `llms.txt` guidance.
tools
Build against the memories.sh SDK packages in application code. Use when working with `@memories.sh/core` or `@memories.sh/ai-sdk`, including: (1) Initializing `MemoriesClient`, (2) Reading, writing, searching, or editing memories from backend code, route handlers, workers, or scripts, (3) Integrating memories with the Vercel AI SDK via `memoriesMiddleware`, `memoriesTools`, `preloadContext`, or `createMemoriesOnFinish`, (4) Choosing and applying `tenantId` / `userId` / `projectId` scoping, (5) Managing SDK skill files or management APIs, or (6) Debugging memories SDK usage in TypeScript or JavaScript applications. Use `memories-cli` for CLI workflows, `memories-mcp` for MCP setup, and `memories-dev` for monorepo internals.
tools
MCP server integration for memories.sh — the persistent memory layer for AI agents. Use when: (1) Configuring the memories.sh MCP server for any client (Claude Code, Cursor, Windsurf, VS Code, v0, Claude Desktop, OpenCode, Factory), (2) Using MCP tools to store, search, retrieve memories, run lifecycle session workflows, or manage reminders, (3) Understanding get_context vs search_memories vs list_memories, (4) Working with streaming memory tools for SSE content, (5) Troubleshooting MCP connection issues, (6) Choosing between cloud MCP (HTTP) and local MCP (stdio) transports.
tools
CLI reference and workflows for memories.sh — the persistent memory layer for AI agents. Use when: (1) Running memories CLI commands to add, search, edit, or manage memories, (2) Managing lifecycle workflows (session/checkpoint/compaction/consolidation/OpenClaw memory files), (3) Setting up memories.sh in a new project (memories init), (4) Generating AI tool config files (CLAUDE.md, .cursor/rules, etc.), (5) Importing existing rules from AI tools (memories ingest), (6) Managing cloud sync, embeddings, git hooks, or reminders, (7) Troubleshooting with memories doctor, (8) Working with memory templates, links, history, tags, or reminder schedules.