agentleFS
AdiRishiAdiRishi/promptrc/AGENTS.md

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

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
  1. Very specific:

    Run a single test file: pnpm test <path> (e.g.

    line 20
  2. Distinctive:

    Implication: don't add mode checks in components/hooks.

    line 37
  3. Very specific:

    Every handler calls requireUserId() (Clerk auth()) and scopes queries by ext_user_id.

    line 44
  4. Very specific:

    Messages: use echo() from src/lib/echo.ts — it prints in the command-line row like vim's message area.

    line 74
  5. Very specific:

    Only VITE_* vars reach the client bundle.

    line 122

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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 8080
  • pnpm build — production build into .output/
  • pnpm preview — preview the production build locally
  • pnpm test — run Vitest (see "Testing" below for project split)
  • pnpm lint — Oxlint with type-aware rules (oxlint --type-aware, powered by oxlint-tsgolint); config in .oxlintrc.json
  • pnpm format / pnpm format:check — Oxfmt (Prettier-compatible output, with built-in import sorting and Tailwind class sorting); config in .oxfmtrc.json
  • pnpm typecheck — runs cf-typegen first, then tsc --noEmit (TypeScript 7, the native compiler) for both app and tests/tsconfig.json
  • pnpm cf-typegen — builds, then regenerates worker-configuration.d.ts from .output/server/wrangler.json (not from wrangler.jsonc directly)
  • pnpm check — the CI gate: format:check && lint && typecheck && deploy:dry-run
  • pnpm deploy / pnpm deploy:dry-run — publishes via wrangler --cwd .output; deploy-dry-run is part of check to 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 — the PromptLibraryStorage discriminated union (mode: 'local' | 'remote')
  • persistence/local-prompt-library-storage.ts — localStorage adapter (anonymous users)
  • persistence/remote-prompt-library-storage.ts — Cloudflare D1 via TanStack server functions (signed-in users)
  • sync/prompt-library-client.ts — createPromptLibraryClient builds a single PromptLibraryClient on 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') inside getDatabase() — not a top-level import. Vite externalizes cloudflare:workers (see vite.config.ts build.rolldownOptions.external), so a static import would break the client bundle.
  • Every handler calls requireUserId() (Clerk auth()) and scopes queries by ext_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 direct D1Database handle without going through the serverfn wrapper.
  • D1 row encoding/decoding and remote write transitions live in persistence/; the server/ 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 in guides.ts, and a route file. Write the route as a static file (guides.<slug>.tsx): src/lib/vite-sitemap-plugin.ts builds sitemap.xml from 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.ts holds 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.ts redirects page visits on www.promptrc.app to the canonical host, so each page has one address. Server-function calls are left alone, because a tab that was already open on www still makes them there.
  • www used to serve the app, so a signed-out library may sit in that origin's localStorage. 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, so lifecycle/www-host-library-import.ts merges it into the store as it stands then, and a draft in progress stays. Delete the route, those two modules, the call in sync/prompt-library-session.ts and the exemption in src/lib/canonical-host.ts once old www visitors have had time to come back, for example after November 2027.
  • A share link (:share) is private to whoever holds it: /share/<id> renders with noindex and no page links to it. :publish sets listed_at on the share, and only then is the page indexable, listed on /prompts and included in /sitemap-prompts.xml (a server route, because the list changes without a deploy; robots.txt names it beside the static sitemap). :unpublish clears listed_at and keeps the link working. Nothing else may make a share public, so a new page that reads shares must filter on listed_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.ts and routed by prompt-library-command-router.ts. The : command line is parsed by commands/prompt-library-ex-commands.ts (pure, tested: parseExCommand, completeExCommand) into an ExAction that 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 in model/prompt-projects.ts — compare Projects with isSameProject/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), and components/project-picker.tsx is the input for choosing one. See docs/adr/0005-projects-with-stacking-filters.md.
  • Messages: use echo() from src/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; see docs/adr/0004-prompt-kinds-share-one-record.md. Kind metadata and copy live in model/prompt-kinds.ts; kind glyphs (❯ “ » ◆), their colours and their optical alignment in components/kind-mark.tsx. Render a kind with KindMark or KindTag, which carry that alignment.
  • Template variables ({{name}}, {{name | fallback}}) are parsed in model/prompt-templates.ts, turned into inline inputs by rendering/remark-prompt-variables.ts + rendering/prompt-variable-slot.tsx, and substituted on copy by model/prompt-copy.ts. Typed values are remembered per Prompt in localStorage (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.ts lists them (COLOR_SCHEMES) and owns the preference plus the inline no-flash script in __root.tsx, which sets data-scheme (and data-crt for the CRT schemes). Each scheme in src/global-styles/tailwind.css defines terminal colours (--bg, --fg, --line, --accent, --red … --cyan) plus its overlay --shadow and --scrim; shadcn names are mapped from them so Base UI and Clerk follow along. Use bg-bg*, text-fg*, border-line*, accent and 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-dim or fg-faint, and fg-faint is 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 in tailwind.css (text-meta, text-ui, text-body, text-head, text-title, and text-display for the sign-in headline); weights are 400, 600 and 800. The steps grow together at 105rem (1680px), and layout widths are in ch so they follow. .voice-title is the display weight for an entry's title, .voice-note the casual slanted cut for notes and fragments. Box-drawing and symbol glyphs come from src/global-styles/fonts/terminal-symbols.woff2 (a JetBrains Mono subset, OFL) via unicode-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 with pane-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 is Bracketed ([new] used a-z, in components/ui/choice.tsx). An action bar is KeyActionBar with KeyActions (components/ui/key-action.tsx): a keycap, then the label, with one primary per bar. A part of an entry that promptrc adds around the author's words is headed by SectionLabel. 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 add useMemo/useCallback for 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, includes tests/**/*.test.{ts,tsx} but excludes tests/**/*.server.test.{ts,tsx}
  • cloudflare-server — @cloudflare/vitest-plugin Miniflare, includes tests/**/*.server.test.{ts,tsx}, runs tests/setup-cloudflare.ts which re-applies D1 migrations and truncates prompts before 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

  • nitro is pinned to 3.0.260610-beta. In 3.0.260903-beta the workerd dev runner inlines CommonJS dependencies (React) and pnpm dev fails with module is not defined. 3.0.261103-rc runs pnpm dev, but its build rejects the trailing commas in wrangler.jsonc: it reads the file with confbox's parseJSONC without allowTrailingComma.
  • miniflare@^4 is a direct dev dependency because Wrangler and @cloudflare/vitest-plugin now ship miniflare 5 (alpha), while Nitro's env-runner needs v4.
  • vite.config.ts marks cloudflare:workers external 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, required
  • CLERK_SECRET_KEY — server/worker only, required
  • VITE_SITE_URL — optional canonical origin for SEO; defaults handled by src/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-simple for 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"> via components/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 in components.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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.