maket
CLAUDE.md19 starsChanged 2 months agoMITView on GitHub
Visual design tool for Claude — compose HTML/CSS documents with live preview, manage assets, apply brand chartes, export PDF, send via Gmail. MCP server exposed over Streamable HTTP at POST /mcp. Node >=22. The server must be running before Claude Code connects (MCP is HTTP-based). The human usually runs it themselves; don't spawn a second dev server. These aren't style preferences — they're the invariants the codebase depends on. Breaking any of them reliably breaks boot, tests, or the refactor…
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
We split this CLAUDE.md into the rules it gives an agent
7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Every service, tool pack, and HTTP route is a factory registered in bootstrap.ts.
- Very specific: line 28
If you catch yourself adding a runtime field to a persistence type (the old Document._pending shape), that's a new service.
- Very specific: line 48
Always use text(t, { isError?, next?
- Very specific: line 51
Zustand = single source of truth: No Context, no prop-drilled server state.
- Very specific: line 73
One feature = one branch = one issue: Never stack unrelated work on an existing feat/* branch.
- Distinctive: line 74
No push or PR without explicit user go-ahead.
- Very specific: line 84
Stale
tsconfig.tsbuildinfo: after cross-package refactors causes TS6310 or phantom errors.
≈ “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
Maket
Visual design tool for Claude — compose HTML/CSS documents with live preview, manage assets, apply brand chartes, export PDF, send via Gmail. MCP server exposed over Streamable HTTP at POST /mcp.
Quickstart
npm run dev # server --watch + Vite HMR (the one you want 95 % of the time)
npm run dev:watch # server --watch + vite build --watch → public/ (prod-like preview on :24843)
npm run quality # lint + typecheck + test — same gate as pre-commit
npm run lint:fix # biome check --writeNode >=22. The server must be running before Claude Code connects (MCP is HTTP-based). The human usually runs it themselves; don't spawn a second dev server.
Coding principles
These aren't style preferences — they're the invariants the codebase depends on. Breaking any of them reliably breaks boot, tests, or the refactor safety net.
Dependency injection via Awilix — no exceptions
- Every service, tool pack, and HTTP route is a factory registered in
bootstrap.ts. Consumers resolve by destructured param name. No module-level singletons, nonew, no direct imports of concrete implementations. - Interface first — declare
export interface Foo { … }abovecreateFoo. Consumers type against the interface; the factory implements it. - Factories over classes everywhere — no
classkeyword in domain code (DocumentStoreis the lone exception — a legitimate DB wrapper). Private state lives in factory closures. - PROXY destructure trap — every destructured name on
depstriggers a container lookup. Put optional test overrides on a separateoptsarg (seeLayoutService,PdfService). - Container self-reference —
bootstrap.tsregisterscontainer: asValue(container)so factories that need the container itself (createMcpRouter→mountTools) resolve it via DI.
Separation of concerns is hard-enforced
- If you catch yourself adding a runtime field to a persistence type (the old
Document._pendingshape), that's a new service. Persistence models hold persistent state; transient state gets its own home.packages/server/src/services/pending.tsis the template — factory + interface + private closures + bus-driven side effects. - No deprecation shims — when moving state, remove the old field in the same diff and migrate every call site. "No baby-step migrations."
Bus emits, listeners propagate
- Services mutate state and emit on the
bus. Side effects (WS broadcast, toasts) live inpackages/server/index.tslisteners. A service never callswsRegistry.broadcastdirectly. wsRegistry.broadcast(msg)accepts typedWsServerMessageobjects — JSON.stringify happens inside. Don't pre-stringify.
Complete migrations, four-point checklist on tool renames
Renaming an MCP tool touches four places:
- The tool file (incl.
declaresTools) ACTIVITY_ICONSinpackages/server/src/routes/mcp.routes.tsmanifest.json.tools[]- Skill + doc references under
plugin/claude/**
Boot asserts (1) ↔ (3) and fails fast on drift. (2) and (4) aren't asserted — verify manually.
Cross-cutting invariants apply at every entry point
Gating logic like lockGuard must run in MCP tools, ws-handler cases, AND bulk UI flows. One missed entry = full bypass. Same for escaping user strings inside <style> (escapeCssValue + stripStyleClose, see ThumbnailService).
Tool output
Always use text(t, { isError?, next? }) from packages/server/src/tools/_helpers.ts. Never build the MCP content envelope inline. Use the next: string[] option on business-flow hinges so the agent sees what call to make next.
Client mirrors server state over WS
- Zustand = single source of truth. No Context, no prop-drilled server state. Selectors +
useShallowfor derived shapes. - WS for mutations, HTTP only for binaries (assets,
.maketbundles). Handlers write the store directly viauseStore.getState(). - Pending queue is the optimistic layer —
addPendingenqueues,ack_messagessettles. Don't pre-apply edits to the store. - Toasts are server-authored —
spawnBubblefires only from theactivityWS handler. - Edit mode is server-authoritative — any
statemessage exits it; don't try to preserve selection across reloads. - No
window.prompt/window.confirm—InlineNameEditorfor names,HoldToDeleteor reversibleflagged-deletefor destructive. - Popovers inside
SidePanelportal todocument.body(panel'soverflow-hiddenclips). Use--z-popover/--z-modaltokens. verbatimModuleSyntax: true—import typefor types.
Tests
- Co-located:
foo.ts+foo.test.ts. DB tests usecreateSQLiteStore(":memory:")— never touch the filesystem. - Coverage thresholds in
vitest.config.ts(core 90 %, services 80 %).
Gmail is draft-only, read is opt-in
- Maket never calls
users.messages.sendnorusers.drafts.send. The user reviews in Gmail and sends themselves. No exception. gmail.composeis always requested.gmail.readonlyis requested only when the caller passeswith_read=trueatconnect. Guardsearch/readbehindgmailClient.grants().read; on miss, returntext(…, { next: ["maket_gmail action=connect with_read=true"] }).- The OAuth app is unverified and stays that way — we don't pay CASA for an open-source tool. Users see Google's "Advanced → proceed" screen once; that's the deal.
- On successful draft creation, write
doc.meta.emailDraftUrl+emailDraftRole: "body"|"attachment"on the body doc AND mirror both onto every attached doc, so each artefact carries a one-click review pointer back into Gmail.
Git flow & changelog
- Feature branches only;
maintakes release commits directly (chore(release): vX.Y.Z). - One feature = one branch = one issue. Never stack unrelated work on an existing
feat/*branch. Each new task: open a GitHub issue, branch fromorigin/main(skip local main to avoid divergence surprises), commit, let the PR close the issue. - No push or PR without explicit user go-ahead.
- Conventional Commits.
npm run changelog:draftgroups commits since the last tag into an[Unreleased]draft — paste intoCHANGELOG.md, cut the noise. CHANGELOG.mdfollows Keep a Changelog 1.1.0 + a non-standardInternalbucket for CI/tests/cleanup.- Internal-only branches merge without a version bump. Release = runtime change: roll
[Unreleased]→[X.Y.Z], runnpm run version:bump X.Y.Z(rewrites root + every workspacepackage.json), tagvX.Y.Z. - Version alignment is enforced. Root
package.json+ everypackages/*/package.jsonmust share the sameversion.npm run version:checkruns insidequalityand fails the gate on drift. Never bump a single file by hand — alwaysversion:bump.
Dev flow gotchas
- Pre-commit hooks — lefthook runs biome + typecheck + vitest. All three must pass before a commit lands.
npm run lintexits 0 with warnings — only errors fail the gate. Don't chase warnings. Usenpx biome check --max-diagnostics=0when output is truncated.- Stale
tsconfig.tsbuildinfoafter cross-package refactors causes TS6310 or phantom errors. Reset:rm packages/*/tsconfig.tsbuildinfo && npx tsc -b. - Biome drift after big refactors — run
npx biome check --write packages/<x>/beforenpm run quality. - Client rebuild —
npm run devuses Vite HMR on :5173;dev:watchwrites topublic/for the :24842/24843 server preview. If you don't see your client change, you're on the wrong script. - Dev data lives in
.maket/— npm scripts setMAKET_DATA_DIR="$PWD/.maket"(gitignored). Clear stale servers withlsof -ti:24843 | xargs kill. - Tailwind v4
@importordering —@import url(...)MUST precede@import "tailwindcss"inindex.css. PostCSS rejects otherwise. - macOS sed has no
\b— for bulk identifier renames, rely on unique substring substitution.
Source-of-truth references
CLAUDE.md intentionally doesn't describe every subsystem — the code is the reference.
- Services + DI wiring →
packages/server/src/bootstrap.ts - MCP tool surface →
manifest.json(names) +packages/server/src/tools/*.ts(behaviour) - WS wire contract →
packages/shared/src/ws.ts(WsClientMessage / WsServerMessage unions) - HTTP routes →
packages/server/src/routes/*.ts+routes/index.tsmount order - Shared invariants (formats, canvas dims, pending message shape) →
packages/shared/src/ - Charte compliance + layout rules →
packages/server/src/lib/charte-check.ts,services/layout.ts .maketbundle format →packages/server/src/lib/maket-format.ts- Pending queue →
packages/server/src/services/pending.ts - Environment + paths →
packages/server/src/services/config.ts - Claude Code plugin (skills + commands) →
plugin/claude/ - Downstream workspace scaffolding →
make bootstrap DIR=... PORT=...(seeMakefile)
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.

