promptrc
AGENTS.md2 starsChanged 6 months agoMITView on GitHub
Package manager is pnpm 12 (exact version pinned in package.json packageManager; pnpm switches to it automatically). Node version is pinned in .node-version. pnpm-workspace.yaml sets minimumReleaseAge: 1440, so nothing younger than a day is installed — when upgrading, pick versions at least a day old rather than adding exclusions. To rebuild the lockfile, delete pnpm-lock.yaml and run pnpm install. Run a single test file: pnpm test <path> (e.g. pnpm test tests/features/prompt-library/persistence/remote/remote-prompt-library-persistence.server.test.ts). Filter by name with -t "<pattern>". Apply D1 migrations locally:…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,196 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository8 other files it gives its agents.
- .agents/skills/vercel-composition-patterns/AGENTS.mdAGENTS.md
- clerk-custom-uiSkill
- clerk-setupSkill
- clerkSkill
- clerk-tanstack-patternsSkill
- frontend-designSkill
- shadcnSkill
- vercel-composition-patternsSkill
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 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.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
Run a single test file: pnpm test <path> (e.g.
- Distinctive: line 37
Implication: don't add mode checks in components/hooks.
- Very specific: line 44
Every handler calls requireUserId() (Clerk auth()) and scopes queries by ext_user_id.
- Very specific: line 74
Messages: use echo() from src/lib/echo.ts — it prints in the command-line row like vim's message area.
- Very specific: line 122
Only VITE_* vars reach the client bundle.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.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
AGENTS.md
This file provides guidance to AI Agents when working with code in this repository.
Commands
Package manager is pnpm 12 (exact version pinned in package.json packageManager; pnpm switches to it automatically). Node version is pinned in .node-version. pnpm-workspace.yaml sets minimumReleaseAge: 1440, so nothing younger than a day is installed — when upgrading, pick versions at least a day old rather than adding exclusions. To rebuild the lockfile, delete pnpm-lock.yaml and run pnpm install.
pnpm dev— Vite dev server on port 8080pnpm build— production build into.output/pnpm preview— preview the production build locallypnpm test— run Vitest (see "Testing" below for project split)pnpm lint— Oxlint with type-aware rules (oxlint --type-aware, powered byoxlint-tsgolint); config in.oxlintrc.jsonpnpm format/pnpm format:check— Oxfmt (Prettier-compatible output, with built-in import sorting and Tailwind class sorting); config in.oxfmtrc.jsonpnpm typecheck— runscf-typegenfirst, thentsc --noEmit(TypeScript 7, the native compiler) for both app andtests/tsconfig.jsonpnpm cf-typegen— builds, then regeneratesworker-configuration.d.tsfrom.output/server/wrangler.json(not fromwrangler.jsoncdirectly)pnpm check— the CI gate:format:check && lint && typecheck && deploy:dry-runpnpm deploy/pnpm deploy:dry-run— publishes viawrangler --cwd .output; deploy-dry-run is part ofcheckto catch Worker-level misconfig before merge
Run a single test file: pnpm test <path> (e.g. pnpm test tests/features/prompt-library/persistence/remote/remote-prompt-library-persistence.server.test.ts). Filter by name with -t "<pattern>".
Apply D1 migrations locally: pnpx wrangler d1 migrations apply promptrc --local.
Architecture
Local-first storage with a unified client
The prompt library has two backends behind one interface:
src/features/prompt-library/persistence/prompt-library-storage.ts— thePromptLibraryStoragediscriminated union (mode: 'local' | 'remote')persistence/local-prompt-library-storage.ts—localStorageadapter (anonymous users)persistence/remote-prompt-library-storage.ts— Cloudflare D1 via TanStack server functions (signed-in users)sync/prompt-library-client.ts—createPromptLibraryClientbuilds a singlePromptLibraryClienton top of either storage; components never branch on auth/mode
PromptLibraryProvider (components/prompt-library-provider.tsx) wires Clerk auth → usePromptLibraryStorage (picks adapter) → createPromptLibraryClient → Zustand store. Hydration happens in usePromptLibraryHydration: local mode subscribes to the store to persist every change; remote mode does not (writes go through server funcs explicitly).
Implication: don't add mode checks in components/hooks. If a behavior differs between local and remote, it belongs inside the client/storage layer.
Server functions + Cloudflare bindings
src/features/prompt-library/server/prompt-library-functions.ts defines TanStack Start createServerFn endpoints. Important patterns:
- The D1 binding is accessed via
const { env } = await import('cloudflare:workers')insidegetDatabase()— not a top-level import. Vite externalizescloudflare:workers(seevite.config.tsbuild.rolldownOptions.external), so a static import would break the client bundle. - Every handler calls
requireUserId()(Clerkauth()) and scopes queries byext_user_id. New endpoints must follow this pattern; there is no separate authorization layer. - Exported pure DB helpers (
listPromptsForUser,upsertPromptForUser, etc.) exist so tests can call them with a directD1Databasehandle without going through the serverfn wrapper. - D1 row encoding/decoding and remote write transitions live in
persistence/; theserver/folder should stay focused on TanStack server-function wrappers and Cloudflare binding access.
State
Zustand vanilla store (store/prompt-library-store.ts) — the React tree consumes it through useStore(store, selector) exposed by PromptLibraryProvider. The store holds prompts, workspace state (query/selection/composer), and sync state together; mutations go through the actions slot (never direct set from outside).
Routing
File-based routes in src/routes/. The generated routeTree.gen.ts is .gitignored in effect (regenerated by the TanStack router plugin during dev/build). sign-in.$.tsx / sign-up.$.tsx are catch-all Clerk routes.
Pages for search
/ is the app, and a crawler finds little to index in an app. The pages that say what promptrc is live in src/features/site/: /about, /manual (the ? overlay's ManualContent as a page) and /guides/*. They share SiteShell, render on the server, and each sets its own title, description, canonical link and structured data through src/lib/seo.ts.
- A guide is a markdown file in
src/features/site/guides/, an entry inguides.ts, and a route file. Write the route as a static file (guides.<slug>.tsx):src/lib/vite-sitemap-plugin.tsbuildssitemap.xmlfrom the static routes and skips dynamic ones. - A title fits about 60 characters and a description about 155 before a search result cuts them.
tests/features/site/guides.test.tsholds the home page and the guides to that. - The home page's server HTML carries
ReaderBanner(what promptrc is, with links to these pages) until the library loads. src/start.tsredirects page visits onwww.promptrc.appto the canonical host, so each page has one address. Server-function calls are left alone, because a tab that was already open onwwwstill makes them there.wwwused to serve the app, so a signed-out library may sit in that origin'slocalStorage. The canonical host fetches it once through a hidden frame on/www-library(persistence/local/www-host-library.ts). The answer arrives after the library has loaded, solifecycle/www-host-library-import.tsmerges it into the store as it stands then, and a draft in progress stays. Delete the route, those two modules, the call insync/prompt-library-session.tsand the exemption insrc/lib/canonical-host.tsonce oldwwwvisitors have had time to come back, for example after November 2027.- A share link (
:share) is private to whoever holds it:/share/<id>renders withnoindexand no page links to it.:publishsetslisted_aton the share, and only then is the page indexable, listed on/promptsand included in/sitemap-prompts.xml(a server route, because the list changes without a deploy;robots.txtnames it beside the static sitemap).:unpublishclearslisted_atand keeps the link working. Nothing else may make a share public, so a new page that reads shares must filter onlisted_at. - Published Prompts are text written by users. Links in a rendered body carry
rel="nofollow ugc", and the public pages show only the title, body, Project, tags and kind, never notes, runs, pins or use counts.
Interface
The app is a TUI in a browser, and should keep feeling like one. The library screen (components/prompt-library-app.tsx) is a tmux-style tab line, three panes (components/ui/pane.tsx, focused with 1 2 3; the lit frame and the active tab both follow the screen's activePane), a vim status line (status-line.tsx, shows the mode: NORMAL / INSERT / CAPTURE / FIND / COMMAND / HELP) and a command line (command-line.tsx). The panes are library-pane.tsx (the Projects tree and the current Project's tags, plus sync/colorscheme/account), prompt-list.tsx (kind/★ toggles, grep, sort, catalog numbers), and either prompt-reader.tsx or prompt-editor.tsx. Overlays are quick-capture-dialog.tsx (c), finder.tsx (⌘K, cmdk, with a preview), and manual.tsx (?, a man page). Below lg the library pane is a drawer; below md one pane shows at a time.
- Commands: single-key commands are defined in
commands/prompt-library-command-surface.tsand routed byprompt-library-command-router.ts. The:command line is parsed bycommands/prompt-library-ex-commands.ts(pure, tested:parseExCommand,completeExCommand) into anExActionthat the screen executes. New commands usually need an entry in both, plus the manual picks them up automatically. - Projects and the filter: a Prompt's Project is stored as
category(record field and D1 column). Project identity, suggestions and typo matching live inmodel/prompt-projects.ts— compare Projects withisSameProject/projectKey, never raw strings. The library filter is{ project, kind, pinned, tag }; the parts stack, and UI changes them with partial patches. New entries resolve their Project to an existing spelling on save (store and capture), andcomponents/project-picker.tsxis the input for choosing one. Seedocs/adr/0005-projects-with-stacking-filters.md. - Messages: use
echo()fromsrc/lib/echo.ts— it prints in the command-line row like vim's message area. There are no toasts. - Kinds (
prompt,fragment,sequence,benchmark) are one record shape; seedocs/adr/0004-prompt-kinds-share-one-record.md. Kind metadata and copy live inmodel/prompt-kinds.ts; kind glyphs (❯ “ » ◆), their colours and their optical alignment incomponents/kind-mark.tsx. Render a kind withKindMarkorKindTag, which carry that alignment. - Template variables (
{{name}},{{name | fallback}}) are parsed inmodel/prompt-templates.ts, turned into inline inputs byrendering/remark-prompt-variables.ts+rendering/prompt-variable-slot.tsx, and substituted on copy bymodel/prompt-copy.ts. Typed values are remembered per Prompt inlocalStorage(hooks/use-prompt-variable-values.ts). The raw view (rendering/prompt-source-view.tsx) renders the same slots inside line-numbered source. - Colorschemes:
src/lib/theme.tslists them (COLOR_SCHEMES) and owns the preference plus the inline no-flash script in__root.tsx, which setsdata-scheme(anddata-crtfor the CRT schemes). Each scheme insrc/global-styles/tailwind.cssdefines terminal colours (--bg,--fg,--line,--accent,--red…--cyan) plus its overlay--shadowand--scrim; shadcn names are mapped from them so Base UI and Clerk follow along. Usebg-bg*,text-fg*,border-line*,accentand the named colours. Every text colour holds 4.5:1 on every surface, including the selection tint, so check a new or changed scheme against all of--bg*and--bg-sel. - Colour has jobs: the accent means "you are here" or "this commits" (the mode badge, the selection rail, focus, the primary action, the capture row). ANSI colours carry meaning only: kind glyphs, benchmark verdicts, sync state, the ★ of a pinned entry. Everything else is
fg,fg-dimorfg-faint, andfg-faintis the quietest text that still has to be read. Links in running text use.link. - Type: everything is Recursive at
MONO 1. Sizes come from the named steps intailwind.css(text-meta,text-ui,text-body,text-head,text-title, andtext-displayfor the sign-in headline); weights are 400, 600 and 800. The steps grow together at 105rem (1680px), and layout widths are inchso they follow..voice-titleis the display weight for an entry's title,.voice-notethe casual slanted cut for notes and fragments. Box-drawing and symbol glyphs come fromsrc/global-styles/fonts/terminal-symbols.woff2(a JetBrains Mono subset, OFL) viaunicode-range; if you use a new symbol, check it's covered or extend the subset. Chrome icons are glyphs from these fonts. - Shape: pane frames and overlays round at 6px (
rounded-md), keycaps at 2px (rounded-sm), and every fill inside a pane is square. Overlays put their name in the top border withpane-title, like panes do. - One pattern per job: a selected row is
.row-selected(tint, accent rail, weight 600). The chosen option in a set isBracketed([new] used a-z, incomponents/ui/choice.tsx). An action bar isKeyActionBarwithKeyActions (components/ui/key-action.tsx): a keycap, then the label, with oneprimaryper bar. A part of an entry that promptrc adds around the author's words is headed bySectionLabel. Prose sits in.measure. Key hints for the screen live in the message row only. - Touch: below
md, interactive rows are 44px tall (max-md:h-11), typed inputs are 16px, and key prefixes hide. - The React Compiler (native oxc port, via
@vitejs/plugin-react) memoizes components, so don't adduseMemo/useCallbackfor render performance alone.
Feature layout convention
Colocate under src/features/<feature>/: components/, hooks/, model/ (Prompt records, defaults, normalization), selectors/ (derived state for UI/workflows), commands/ (shared command metadata and executors), rendering/ (display formatting and body tokenization), persistence/ (storage adapters, D1 mapping, remote transitions), sync/ (client/session/hydration orchestration), server/ (serverfn wrappers), store/ (Zustand), types.ts. New features should follow this shape when the same concerns exist.
Tests should mirror the feature folders under tests/features/<feature>/. Use the .server.test.ts suffix for tests that need the Cloudflare workers pool, including D1 persistence and server-function tests.
Path alias
@/* → src/* (tsconfig + vitest alias). Use the alias in imports; Oxfmt's import sorting groups @/ imports separately from third-party and relative imports — don't hand-reorder.
Testing
vitest.config.ts defines two projects in one run:
browser-unit—jsdom, includestests/**/*.test.{ts,tsx}but excludestests/**/*.server.test.{ts,tsx}cloudflare-server—@cloudflare/vitest-pluginMiniflare, includestests/**/*.server.test.{ts,tsx}, runstests/setup-cloudflare.tswhich re-applies D1 migrations and truncatespromptsbefore each test
Naming matters: D1 and server-function tests must use the .server.test.ts suffix so they hit the workers pool (and get the D1 binding). Put browser/unit tests in the mirrored feature folder without that suffix, or they'll run in the wrong environment.
Version pins worth knowing
nitrois pinned to3.0.260610-beta. In3.0.260903-betathe workerd dev runner inlines CommonJS dependencies (React) andpnpm devfails withmodule is not defined.3.0.261103-rcrunspnpm dev, but its build rejects the trailing commas inwrangler.jsonc: it reads the file with confbox'sparseJSONCwithoutallowTrailingComma.miniflare@^4is a direct dev dependency because Wrangler and@cloudflare/vitest-pluginnow ship miniflare 5 (alpha), while Nitro'senv-runnerneeds v4.vite.config.tsmarkscloudflare:workersexternal for the dependency optimizer too; otherwise the dependency scan aborts on the dynamic import.
Deployment
Target: Cloudflare Workers with a D1 binding named DB (see wrangler.jsonc). nitro.config.ts sets the Nitro preset to Cloudflare; retargeting elsewhere is a preset change. pnpm build outputs the Worker bundle + .output/server/wrangler.json, and pnpm deploy runs wrangler against that output directory — never the repo root.
Production routes (promptrc.app, www.promptrc.app) and the D1 database id are pinned in wrangler.jsonc. Neither the Deploy workflow nor pnpm deploy applies D1 migrations: run pnpx wrangler d1 migrations apply promptrc --remote by hand before merging (or deploying) code that needs one, and keep migrations additive so the live version keeps working in between. There are no preview databases: PR previews (versions upload) bind the production D1 database and R2 bucket, so a preview of code that needs a new migration only works once that migration has been applied to production. Fork-to-deploy requires editing those and setting CLERK_SECRET_KEY as a Worker secret.
Environment
VITE_CLERK_PUBLISHABLE_KEY— client, requiredCLERK_SECRET_KEY— server/worker only, requiredVITE_SITE_URL— optional canonical origin for SEO; defaults handled bysrc/lib/site-config.ts
Only VITE_* vars reach the client bundle.
Conventions
- Oxfmt: no semicolons, single quotes, trailing commas, imports sorted into third-party /
@// relative groups. Don't fight it. - Oxlint:
array-simplefor array types; inline type specifiers (import { type Foo }) are enforced; React Compiler rules (react/refs,react/set-state-in-effect,react/purity,react/static-components) and jsx-a11y are on. Prefer native elements (<input type="radio">viacomponents/ui/choice.tsx,<button>) over ARIA roles. - Copy in the UI is calm and sentence-case. Notifications read like
Copied “Title”, not terminal output. - Adding a shadcn component:
npx shadcn@latest add <name>(registry config incomponents.json).
Agent skills
Issue tracker
Issues and PRDs are tracked in GitHub Issues for AdiRishi/promptrc. See docs/agents/issue-tracker.md.
Triage labels
Triage uses the canonical mattpocock/skills label vocabulary. See docs/agents/triage-labels.md.
Domain docs
This is a single-context repo with root-level domain docs. See docs/agents/domain.md.
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.

