comate
CLAUDE.md94 starsChanged 2 months agoApache-2.0View on GitHub
Comate is a desktop AI workspace that wraps Claude Code in a native Electron app. It uses a hybrid architecture: a React 18 + Vite frontend, an Express.js sidecar server, and an Electron desktop shell. Do not run npm run dev alongside npm run dev:electron — both start Vite and will conflict on port 5173.
In this repository5 other files it gives its agents.
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
13 rules. About 0 are common, 4 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 51
Import paths use .js extensions for compiled server files (e.g., ./routes/workspaces.js), even though source is TypeScript.
- Very specific: line 60
Use const arrow functions for handlers.
- Very specific: line 74
Use Zustand stores in src/client/stores/.
- Very specific: line 83
Use useTranslation('namespace') for all user-facing strings.
- Very specific: line 102
Keep services free of Express req/res concerns — pass plain data in and out.
- Distinctive: line 107
Prefer interfaces over classes.
- Very specific: line 117
Use diagLog() from src/server/utils/diag-logger.ts for server-side diagnostic logs.
- Distinctive: line 152
Treat server routes as API endpoints: validate input, handle errors, and avoid leaking stack traces to clients.
- Very specific: line 166
Run npm run lint before committing.
- Distinctive: line 167
Add or update tests for changed behavior.
- Very specific: line 168
Update CHANGELOG.md for user-facing changes (follow Keep a Changelog format).
- Distinctive: line 169
Follow Conventional Commits for commit messages.
- Very specific: line 179
i18n: Add keys to both en and zh-CN namespaces.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Comate — Claude Code Project Guide
Comate is a desktop AI workspace that wraps Claude Code in a native Electron app. It uses a hybrid architecture: a React 18 + Vite frontend, an Express.js sidecar server, and an Electron desktop shell.
Quick Commands
| Command | Purpose |
npm run dev:server | Start the Express backend with hot reload |
npm run dev:client | Start the Vite dev server (port 5173) |
npm run dev:electron | Start the Electron desktop app (Vite dev client + shell) |
npm run lint | Run ESLint on .ts/.tsx |
npm run typecheck | Type-check client, server, and Electron sources |
npm test | Run server, client, Electron, and build-script unit tests |
npm run check | Run the complete lint, type-check, and unit-test suite |
npm run test:client | Run jsdom-based component/hook tests |
npm run test:server | Run node:test server tests (excludes src/server/vendor/) |
npm run test:browser | Run Playwright browser tests |
npm run release | Build sidecar + CDP gate + Electron production bundle (electron-builder) |
Do not run
npm run devalongsidenpm run dev:electron— both start Vite and will conflict on port 5173.
Architecture
┌─────────────────┐ WebSocket / HTTP ┌──────────────────┐
│ Electron shell │ ←──────────────────────→ │ Express server │
│ (electron/) │ │ (src/server/) │
└────────┬────────┘ └────────┬─────────┘
│ │
│ Vite dev client / bundled UI │ sidecar Node process
↓ ↓
┌─────────────────┐ ┌──────────────────┐
│ React UI │ │ SQLite, Claude │
│ (src/client/) │ │ SDK, file I/O │
└─────────────────┘ └──────────────────┘- Frontend (
src/client/): React 18, Zustand stores, Tailwind CSS, Radix primitives,lucide-reacticons. - Backend (
src/server/): Express API routes, service layer, SQLite storage viabetter-sqlite3. - Desktop shell (
electron/): Electron main process + preload, sidecar Node binary lifecycle, native browser views (WebContentsView), tray, updater. - Plugins (
claude-code-plugin/): Built-in local plugin marketplace shipped with the app bundle. - WeCom CLI (
packages/wecom-cli/): Workspace-packaged oclif-style CLI for WeChat Work integration.
Project Conventions
TypeScript & Module Rules
- Target: ES2020, module: ESNext, moduleResolution: bundler.
- Strict mode is on, including
noUnusedLocalsandnoUnusedParameters. - Import paths use
.jsextensions for compiled server files (e.g.,./routes/workspaces.js), even though source is TypeScript. Vite handles client imports without extensions. - Path aliases:
@/→src/client/@server/→src/server/
Code Style
- ESLint with
@typescript-eslint/recommendedandreact-hooks/recommended. - React Refresh rule enabled; prefer named component exports unless constant-export patterns are needed.
- Use
constarrow functions for handlers; prefer functionalsetStateupdates when depending on previous state. - Tailwind classes are composed with
cn()fromsrc/client/components/ui/utils.ts.
File Naming
- Components: PascalCase (
ChatPanel.tsx,SessionListItem.tsx). - Stores/hooks/utils: camelCase (
workspace-store.ts,use-theme.ts). - Server routes/models/services: kebab-case (
workspace-commands.ts,sqlite-store.ts). - Tests: co-located as
<name>.test.tsor<name>.browser.test.tsx.
Client Patterns
State Management
- Use Zustand stores in
src/client/stores/. Keep store logic close to the feature domain (e.g.,chat-store.ts,workspace-store.ts). - Select only the slices a component needs to avoid unnecessary re-renders.
- Stores talk to the Express backend via
fetchto/api/*routes.
Components
- Reusable UI primitives live in
src/client/components/ui/. - Feature components live directly under
src/client/components/. - Tool-specific renderers live in
src/client/components/tool-renderers/. - Use
useTranslation('namespace')for all user-facing strings; namespaces are insrc/client/i18n/{en,zh-CN}/.
Theming
- Dark mode is class-based (
darkclass on root). Tailwind config uses CSS variables (--color-bg,--color-surface, etc.). - Theme utilities are in
src/client/hooks/use-theme.ts.
Server Patterns
Routes
- Routes are Express
Routerinstances insrc/server/routes/. - Return JSON shapes like
{ workspaces },{ workspace },{ error }for consistency. - Validate required fields inline; return
400for bad input,404when not found,500for unexpected errors.
Services
- Business logic and long-lived state live in
src/server/services/. - Services are generally imported as singletons (e.g.,
chatService,wecomBotService). - Keep services free of Express
req/resconcerns — pass plain data in and out.
Models
- TypeScript interfaces for domain entities live in
src/server/models/. - Prefer interfaces over classes; these are compile-time contracts only.
Storage
src/server/storage/sqlite-store.tsis the main workspace/session/session-message store.src/server/storage/data-dir.tsresolves app data paths.src/server/storage/json-store.tsprovides simple JSON file persistence.
Logging
- Use
diagLog()fromsrc/server/utils/diag-logger.tsfor server-side diagnostic logs. - Client logs can be posted to
POST /api/log. - The Electron shell writes a
main.logto the app-datalogs/folder (same folder as the Node logs) in both debug and release builds (seeelectron/logger.ts).
Testing
- jsdom tests: Component and hook tests under
src/client/{components,hooks}/**/*.test.tsx. - Browser tests:
*.browser.test.tsxfiles run with Playwright + Vitest browser mode. - Server/lib tests: Some server utilities and
src/client/libfiles usenode:testand are excluded from Vitest. Run them withnpm run test:server. - Server SQLite isolation (mandatory): Every server test must import
test-utils/test-envas its first statement — it redirects SQLite away from the productiondata.db(viaCOMATE_DATA_DIR) and is enforced by a lint rule plus a runtime guard. Never constructSqliteStore()against the default path in a test; usecreateIsolatedStore()ornew SqliteStore(':memory:'), and reset withstore.resetData()rather than reaching into the privatedb. Seedocs/solutions/conventions/use-isolated-test-database-for-comate.md. - Mock globals in
vitest.setup.ts:ResizeObserver,matchMedia,scrollIntoView.
Desktop / Electron Notes
- Electron packaging config is
electron-builder.config.ts(always pass--config; it is not auto-discovered). - Native resources are staged under
resources/and sidecar binaries underbuild/sidecar/(both build output ofscripts/build-sidecar.ts, gitignored). - The Express server is packaged as a sidecar Node process;
scripts/build-sidecar.tshandles this. - Renderer access to shell capabilities goes through the single
window.comatecontextBridge surface (src/client/lib/desktop-api.ts); the shell side lives inelectron/preload.ts.
WeCom Integration
- WeChat Work bot support is a first-class feature.
- Bot settings, isolation policies, and tool permissions live in workspace settings.
- Server-side WeCom services:
wecom-bot-service.ts,wecom-user-resolver.ts,wecom-queue-worker.ts. - CLI package:
packages/wecom-cli/. - Built-in skill:
claude-code-plugin/plugins/wecom/.
Claude SDK
- The app embeds
@anthropic-ai/claude-agent-sdkfor AI sessions. src/server/services/chat-service.tsorchestrates streaming chat sessions.- The app expects a Claude binary to be available in the bundled resources;
/api/health/claudereports availability.
Safety & Security
- Treat server routes as API endpoints: validate input, handle errors, and avoid leaking stack traces to clients.
- Workspace settings can store API keys and secrets; never log them.
- WeCom bot isolation and bash whitelisting exist to constrain untrusted bot users — respect those boundaries when adding features.
- File operations are scoped to the workspace's
folderPath; do not traverse outside it.
Dependency Notes
better-sqlite3requires native bindings; the prebuilt.noderesource ships in the app resources and must match the sidecar's Node ABI.@vscode/ripgreppowers the fast file picker.shikiis used for syntax highlighting.streamdownrenders streaming markdown.
When Modifying Code
- Run
npm run lintbefore committing. - Add or update tests for changed behavior.
- Update
CHANGELOG.mdfor user-facing changes (follow Keep a Changelog format). - Follow Conventional Commits for commit messages.
- For new features, consider creating a plan doc under
docs/plans/if the change is non-trivial. - Consult
docs/solutions/— documented solutions to past problems (bugs, best practices, conventions), organized by category with YAML frontmatter (module,tags,problem_type) — when implementing or debugging in documented areas;CONCEPTS.mdat the repo root defines shared domain vocabulary.
Common Pitfalls
- Port conflicts:
npm run devandnpm run dev:electronboth want Vite's port. Use only one. - Server
.jsimports: TypeScript source files import each other with.jsextensions so compiled ESM works. - Resource paths: Resources move in production; resolve them via
TAURI_RESOURCE_DIRconsumers orsrc/server/utils/path-config.tsrather than hardcoding paths. - Zustand subscriptions: Selecting whole stores causes re-renders; select only needed fields.
- i18n: Add keys to both
enandzh-CNnamespaces; usei18next.t('namespace:key', 'Fallback').
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

