Prerequisites
Node.js ≥ 18
node --version.Bun ≥ 1.0
Git
Building from source
Clone the repository
Install dependencies
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
Make changes
src/.Build and sync
Test manually
Check logs
Iterate
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
- Build and sync changes
- Test in a real Claude Code session
- Inspect the database to verify data correctness
- 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 port37777.
Queue management
Viewer UI development
The web viewer is a React application built into a self-containedviewer.html bundle.
Source location: src/ui/viewer/
Adding a new card type
Create the component
Register in Feed.tsx
Update types if needed
src/ui/viewer/types.ts.Rebuild and test
Adding new features
Adding a new hook
Create the hook implementation
Register in hooks.json
Rebuild
Modifying the database schema
Add a migration
Update types
Update database methods
Test with a database backup
Debugging
Enable debug logging
Inspect the database
Trace observations by session
Code style
TypeScript guidelines
TypeScript guidelines
- Use strict mode
- Define interfaces for all data structures
- Use
async/awaitfor asynchronous code - Handle errors explicitly with try/catch
- Add JSDoc comments for public APIs
Formatting
Formatting
- 2-space indentation
- Single quotes for strings
- Trailing commas in objects and arrays
- Follow the existing code style in the file you’re editing
Example: well-typed function
Example: well-typed function
Bug reports
Generate a bug report with system diagnostics:Contributing
Workflow
Fork and branch
Make changes
src/. Follow the code style guidelines above.Test
npm test and verify your feature manually in a Claude Code session.Update documentation
docs/public/ if your change affects user-facing behavior.Commit and push
Open a pull request
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
Bump the version
package.jsonplugin/.claude-plugin/plugin.jsonCLAUDE.mdheaderREADME.mdversion badge
Build and sync
Commit and tag
Publish to npm
release script runs tests, builds all components, and publishes to the npm registry.CHANGELOG.md manually.