This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
pnpm build # Compile TypeScript to dist/
pnpm dev # Watch mode for development
pnpm typecheck # Type check without emitting
pnpm lint # Run oxlint
pnpm test # Run tests
pnpm test:watch # Run tests in watch mode
make install # Build and link globally
make clean # Remove dist/ and node_modules/Dual-mode CLI/MCP tool for searching Apple Messages:
src/
├── index.ts # Entry point - routes to CLI or MCP mode based on --mcp flag
├── cli.ts # Commander-based CLI (search, index, stats commands)
├── mcp.ts # MCP server exposing tools via @modelcontextprotocol/sdk
├── indexer.ts # Builds search indexes from ~/Library/Messages/chat.db
├── searcher.ts # Queries indexes with fuzzy matching via MiniSearch
├── formatter.ts # Terminal output formatting with chalk
└── types.ts # Shared types and Apple date conversion utilities
Data flow:
indexer.tsreads Apple'schat.dbSQLite database and AddressBook for contact resolution- Creates two indexes in
~/.messages/: FTS5 SQLite for exact search, MiniSearch JSON for fuzzy matching searcher.tsqueries MiniSearch for fuzzy results, then fetches context from SQLite
Key dependencies:
better-sqlite3: Read Apple Messages DB and create FTS5 indexminisearch: Fuzzy search with typo tolerancenode-typedstream: Extract text from NSAttributedString blobs (messages with null text field)@modelcontextprotocol/sdk: MCP server for Claude Code integration
This repo is also a Claude Code plugin with skills and slash commands:
.claude-plugin/
├── plugin.json # Plugin manifest
└── marketplace.json # Marketplace definition (name: cardmagic)
skills/messages/SKILL.md # Auto-invoked skill for message queries
commands/
├── search.md # /messages:search slash command
└── browse.md # /messages:browse slash command
When asked to "bump version to X" or "tag vX.Y.Z":
- Update
package.jsonversion field to the new version - Commit:
git add package.json && git commit -m "chore: bump version to X.Y.Z" - Tag:
git tag vX.Y.Z - Push:
git push && git push origin vX.Y.Z
GitHub Actions will automatically publish to npm on version tags.
First-time setup:
- Create GitHub environment
npmat repo settings - Publish manually once:
npm login && npm publish --access public - Add trusted publisher on npmjs.com/package/@cardmagic/messages/access