Skip to main content

Prerequisites

Node.js ≥ 18

Required to build and run the project. Check with node --version.

Bun ≥ 1.0

Manages the worker service and runs tests. Auto-installed if missing.

Git

Required to clone and contribute to the repository.

Building from source

1

Clone the repository

2

Install dependencies

3

Build all components

What the build produces

The build uses esbuild to compile TypeScript into several output formats:

Build commands

build-and-sync is the standard development command — it builds, syncs to the marketplace install location, and restarts the worker in one step.

Source layout


Development workflow

1

Make changes

Edit TypeScript source files in src/.
2

Build and sync

This builds, copies to the installed plugin, and restarts the worker.
3

Test manually

Start a Claude Code session to test the feature end-to-end, or run hooks directly (see Manual hook testing below).
4

Check logs

5

Iterate

Repeat until the feature works as expected.

Running tests

Claude Mem uses Bun’s built-in test runner. Tests are organized by component.

Test commands

Testing philosophy

Claude Mem prioritizes manual and integration testing over traditional unit tests, because:
  • Hook behavior depends on Claude Code’s runtime environment
  • SDK interactions require real API calls
  • Integration issues that unit tests miss are common at system boundaries
The preferred testing approach is:
  1. Build and sync changes
  2. Test in a real Claude Code session
  3. Inspect the database to verify data correctness
  4. Monitor worker logs

Manual hook testing

Run hooks directly with test input to verify behavior without starting a full Claude Code session:

Health checks

Data verification


Worker management commands

The worker service runs as a background Bun process on port 37777.

Queue management


Viewer UI development

The web viewer is a React application built into a self-contained viewer.html bundle. Source location: src/ui/viewer/
Hot reload is not supported. Every change requires a full rebuild and worker restart before you can see updates in the browser.
Viewer update workflow:

Adding a new card type

1

Create the component

2

Register in Feed.tsx

3

Update types if needed

Add your data shape to src/ui/viewer/types.ts.
4

Rebuild and test


Adding new features

Adding a new hook

1

Create the hook implementation

As of v4.3.1, hooks are self-contained files. The shebang line is added automatically by esbuild during the build.
2

Register in hooks.json

3

Rebuild

Modifying the database schema

1

Add a migration

2

Update types

3

Update database methods

4

Test with a database backup


Debugging

Enable debug logging

Inspect the database

Trace observations by session


Code style

  • Use strict mode
  • Define interfaces for all data structures
  • Use async/await for asynchronous code
  • Handle errors explicitly with try/catch
  • Add JSDoc comments for public APIs
  • 2-space indentation
  • Single quotes for strings
  • Trailing commas in objects and arrays
  • Follow the existing code style in the file you’re editing

Bug reports

Generate a bug report with system diagnostics:
This collects worker status, recent logs, database statistics, and environment information to include when filing a GitHub issue.

Contributing

Workflow

1

Fork and branch

2

Make changes

Edit source files in src/. Follow the code style guidelines above.
3

Test

Run npm test and verify your feature manually in a Claude Code session.
4

Update documentation

Update relevant MDX files in docs/public/ if your change affects user-facing behavior.
5

Commit and push

6

Open a pull request

Open a PR against main. Include a clear description of what changed and why.

Pull request checklist

  • Clear title describing what the PR does
  • Description explaining why the change is needed
  • Tests for new functionality
  • Documentation updated where applicable
  • Entry added to CHANGELOG.md
  • TypeScript compiles without errors (npx tsc --noEmit)

Releasing

1

Bump the version

Update the version in:
  • package.json
  • plugin/.claude-plugin/plugin.json
  • CLAUDE.md header
  • README.md version badge
2

Build and sync

3

Commit and tag

4

Publish to npm

The release script runs tests, builds all components, and publishes to the npm registry.
The changelog is generated automatically — do not edit CHANGELOG.md manually.