Project management tool for developers and AI agents. One Go binary with an embedded SvelteKit web UI, SQLite (Postgres in cloud mode) storage, and a /pad agent skill. The marketing site is a separate repo at ../pad-web.
- Backend: Go.
cmd/pad/(Cobra CLI) -> REST APIinternal/server/->internal/store/(SQLite/Postgres). - Frontend: SvelteKit 2 + Svelte 5 in
web/, static build embedded in the binary (embed.go). - Data model: Workspaces -> Collections (typed, JSON schema) -> Items (structured
fields+ markdowncontent). Parent/child links give progress tracking. - Agent skill:
skills/pad/SKILL.md, embedded in the binary.
make build # web UI + Go binary (./pad)
make build-go # Go only (backend-only changes)
make web # web UI only
make install # build, install to ~/.local/bin/pad, restart server (UI on :7777)
make dev-web # Vite dev server with hot reload on :5173
make test # Go tests
make lint # Go lint
make test-pg # Go tests against a throwaway Postgres container (needs docker)
go test ./internal/store/ # one package
cd web && npm run test # vitest, run once
cd web && npm run check # svelte-check (runs svelte-kit sync first)
cd web && npm run build # verify frontend compiles + builds materializer bundleRun make install after changes so the running server picks them up.
cmd/pad/main.go, cmd_*.go, groups.go CLI (main.go is wiring only; add commands in cmd_<resource>.go)
internal/server/ HTTP handlers, SSE, middleware; routes in server.go setupRouter()
internal/store/ CRUD, migrations (internal/store/migrations/), FTS
internal/models/ Go types
internal/items/ field validation against schemas
internal/collections/ default definitions, templates, playbook library
internal/cli/ HTTP client + formatting
internal/mcp/ MCP catalog (stdio and /mcp)
internal/collab/ Yjs WebSocket relay; internal/materialize/ headless materializer
internal/events/ config/ diff/ webhooks/ email/ links/
web/src/routes/ SvelteKit pages
web/src/lib/ api/client.ts, types/index.ts, stores/ (runes), components/, collab/
skills/pad/SKILL.md agent skill
- Give each worktree its own
web/node_modules: runnpm ciinweb/. Never symlink the main checkout's copy: it holds a different dependency set, and SvelteKit's generated tsconfig lives inside it, so a symlinked type check silently checks the main tree. - If you find a worktree whose
web/node_modulesis a symlink, do NOT runnpm cior any make target that reaches it (web,build,install,serve,web-check,check):npm cideletes through the link and breaks every session sharing it.rm web/node_modules(removes the link only) first. - No
web/.svelte-kit: runnpx svelte-kit syncinweb/before vitest/vite, or vitest fails with "Tsconfig not found". - No
web/build:embed.goembedsall:web/build, somake test/make lintfail with "no matching files found". Runnpx vite buildinweb/. Do not usemake webin a worktree without its ownnode_modules(see above). - No
web/build-materializer: embedded too. Runnode scripts/build-materializer.mjsinweb/afternpx vite build(npm run builddoes both). It needs esbuild, so anode_modulesolder than the lockfile cannot build it. A placeholder file is not enough:internal/materializetests run the real bundle. - No
web/build-mcp-app:embed.goembedsall:web/build-mcp-app, sogo build/make testfail with "pattern all:web/build-mcp-app: no matching files found". Runnode scripts/build-mcp-app.mjsinweb/(npm run buildruns it after the materializer). A placeholder lets Go compile, but cannot validate the bundle: the bundle test skips on a placeholder. make test-pgis safe across worktrees (each gets its own compose project and Docker-assigned port) but NOT twice at once in one worktree: both resolve to the same project and the first to finish runsdown -vunder the other. The failure then looks likeconnection refusedagainst the code. It refuses to run (NO TESTS EXECUTED) when the database is unreachable. Reap a stack from a deleted worktree withdocker ps --filter name=padtest-thendocker compose -p <project> down -v; from inside a worktree,make test-pg-down.- Refreshing an installed binary: use
scripts/install-refresh.sh.make installrunsnpm ci, which rewritesweb/node_modulesand breaks any other process building from the same checkout. - Keep Go build caches off a tmpfs
/tmp(it is RAM-backed on many dev machines): use the environment'sGOCACHE(or Go's default) and never create a per-task Go cache directory; pointGOTMPDIRat a disk path.
- REST at
/api/v1/. Before adding or changing an endpoint, status/error code or request/response shape, readdocs/api.md. New endpoint notes go there, not in this file. - MCP (
pad mcp servestdio,/mcpHTTP): before changing a tool, action, parameter, annotation, result shape or server instructions, readdocs/mcp.md. - Any MCP catalog, annotation, schema or
instructions.mdchange moves the golden bytes. Regenerate:PAD_UPDATE_MCP_GOLDEN=1 go test ./cmd/pad/ -run TestMCPWireGolden, and decide from the diff whetherToolSurfaceVersion(internal/mcp/version.go) needs a bump. - When adding a
padcommand, decide whether it belongs on the MCP surface (docs/mcp.mdsays how). - CLI reference:
pad --helpandpad <group> --help. Items are referenced by issue ID (TASK-5); collection names accept singular forms.
terminal_optionsclose an item;abandoned_options(subset of terminal, else 400) close it without delivering. Completed-work views count terminal minus abandoned. A field declaring none falls back tomodels.NegativeTerminals, so a custom abandon word counts as shipped until declared.item move/item copy: values with no home in the target schema are dropped and reported (dropped_fields). Cross-workspace copy drops relation fields andgithub_pr(referent_not_portable).implementation_notes,decision_log,github_pr,conventionare system metadata, never settable via--field. A move that changes open/done/abandoned state is refused unless the done field is named.- Playbooks live in the
playbookscollection withinvocation_slugandarguments.pad bootstrapreturns metadata only, no bodies. Templates and theonboardplaybook seed frominternal/collections/andSeedCollectionsFromTemplate; an empty template name intentionally skips the seed. - Auth: with no users the instance is open until
pad auth setup; afterwards every API call needs auth. Credentials in~/.pad/credentials.json(0600). Local lockout recovery (pad auth reset-password) uses the loopback-only/auth/local-resetendpoint and is disabled in cloud mode. - Workspace invitations are always PENDING until the invitee accepts; there is no direct add.
- New endpoint: handler in
internal/server/handlers_*.go; route inserver.gosetupRouter(); store method; CLI client method ininternal/cli/client.go; TS type inweb/src/lib/types/index.ts; API method inweb/src/lib/api/client.ts;make install. - New CLI command: constructor in the matching
cmd/pad/cmd_<resource>.go(create one if none fits); wire incmd/pad/groups.go;make install. - Schedules (recurring and deadline reminders) ride
pad remind, also reachable aspad item remind:--start/--everycreate one, andshow,done,skip,snooze,move,renegotiate,agenda,edit,rmare its subcommands. There is nopad cal. - Schema change: add a file under
internal/store/migrations/, updateinternal/models/and store methods; migrations run on server start.
- WebSocket
/api/v1/collab/{itemID}. The server is a dumb relay: it persists raw Yjs updates without parsing them (internal/store/yjs_updates.go). Client provider:web/src/lib/collab/wsProvider.svelte.ts. - Bump
@tiptap/core,@tiptap/extension-collaborationand@tiptap/y-tiptaptogether, exact-pinned to the same version (no^). Mixed versions silently change the persisted Y.Doc shape and peers diverge. - A change to the ProseMirror node spec must bump
web/src/lib/collab/schemaVersion.ts::SCHEMA_VERSIONandinternal/collab/manager.go::DefaultSchemaVersiontogether. On mismatch the server returns 400 and prunes the item's op-log. Unflushed edits are set aside (item_yjs_updates_set_aside,content_state: superseded_set_aside), not restored. - The schema version is FROZEN:
internal/collab/schema_version_guard_test.gofails on any bump (and when the constants disagree); lifting the freeze is a deliberate, reviewed change. - UI/CSS/behaviour changes that do not alter the persisted document shape do not bump the version.
- pad-web (getpad.dev, docs, blog) is a separate PRIVATE repo at
../pad-web; only pad is public, so public good-first-issues point at pad code. Check "absent in pad-web" against a fresh origin/main. - Text naming the legal entity (publisher, legal pages, licenses, store and package metadata) reads "Perpetual Software LLC". The brand "Pad" and org slug
PerpetualSoftwarestay.
- Plan every surface (CLI, API, web, TS type); a data feed for one web view gets API + TS types + web client only, no CLI or MCP action.
- Pad is a substrate: product behavior never depends on convention compliance, and no workspace's tool names or rituals compile into product code.
- Verify a server-produced value (enum,
kind, errorcode) at the server source (store writer, migration CHECK, DTO, docs/api.md), cited file:line. Fixtures are not a source.
- Pre-push on the exact head: gofmt,
make lint, the repo guard tests,go test -timeout=45mon the touched packages (the 10m default is too short for internal/server),-raceon the touched packages that use concurrency (git grep -lE '\bgo func\b|^\s*go [a-zA-Z_.]+\(|sync\.(Mutex|RWMutex|WaitGroup|Once|Map|Cond)\b|"sync/atomic"|\bchan\b' -- '*.go' ':!*_test.go' ':!*/testdata/*'), with CI's flags (-race -gcflags=modernc.org/...=-d=checkptr=0 -timeout=45m -count=1). In internal/server and internal/store,-runan anchored list of the tests exercising the diff, never a name substring, and report the count; run the whole package only for a diff that changes concurrency across it (CI races every package on pushes to main and release-, never on a PR), and ifweb/changed,npm run checkplus vitest on the changed specs. CI's Go and Web jobs run the full suites on every push, and its Go (PostgreSQL) job runs the packages listed inscripts/ci-pg-packages.txton a PR as two legs (storeforinternal/storeandrestfor the remaining listed packages; thefullsuite on main and release-), so a local full./...ormake test-pgis for debugging a CI red.make checkalready runsgo test ./...: never chain it withmake test. Exit status is the verdict. - Never mark ready or merge someone else's draft PR; leave it to its author.
- External-contributor PRs: read the full diff before approving any Actions run (workflows, action pins against upstream,
pull_request_target, permissions, secrets). Never enable auto-approval for outside contributors; the manual gate is the security boundary.
- A schema change needs
internal/store/migrations/NNNANDinternal/store/pgmigrations/MMM, numbered independently; SQLite alone hides the miss. - No apostrophe in a
--comment in store SQL (breaks Postgres rebinding). Take a row's strongest lock first (FOR SHARE then FOR NO KEY UPDATE deadlocks).testServeris SQLite even undermake test-pg. - No response may be reachable only for rows that exist: byte-identical 404s, gates before lookups. Workspace-global MCP reads filter with
TokenAllowedWorkspaceSet(the OAuth allow-list covers only{slug}routes). - A new refusal message must map to the same code on MCP stdio (
internal/mcp/errors.go) as on HTTP. - Change the pad-cloud
internalsubnet andPAD_TRUSTED_PROXIEStogether, or rate limits and audit IPs collapse onto the router.
- Never
http.DefaultClient,http.Getor a nil-Transport client against httptest servers (Close()poisons the shared transport); usesrv.Client()orisolatedTestClient(). - One Playwright run per worktree. Never aim it at :7777; boot a throwaway instance (own HOME,
PAD_DATA_DIR, port).
- An
$effectthat reads and writes the same$stateself-invalidates; prod silently wedges all effects. Edge trackers are plainlet; wrap effect-called loaders inuntrack.
- Any
go.modchange movesnix/package.nixvendorHash; commit thegot:hash from the PR's Nix job. Nevernpm audit fix; bump the direct dep or add anoverridesfloor. - Cut releases with a bare
git tag vX.Y.Z, never annotated.
- Self-host config, including the email env vars (
PAD_MAILEROO_API_KEY,PAD_EMAIL_FROM,PAD_EMAIL_FROM_NAME): docs/deployment.md. - When collab content is refused on save, recover with
pad item set-aside(docs/api.md). Never force-overwrite, because that loses data.