agentleFS
krisyangdevkrisyangdev/motionboard/AGENTS.md

motionboard

AGENTS.md73 starsChanged 30 days agoMITView on GitHub

The template every site is built from: React 19 + TanStack Start/Router/Query + Tailwind CSS v4 + coss ui (Base UI), prerendered and served by one Cloudflare Worker. Demo: https://template.krisyang.dev. Status and log: ~/code/home/projects/site-template.md. Shared site rules: ~/code/home/lines/sites.md. Look and tokens: DESIGN.md.

  • Reads credentials
  • Sends data out
  • Commits and pushes

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. Ryan-yang125/motion-lexicon★ 73100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • 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 33,398 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 repository2 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

9 rules. About 0 are common, 1 is distinctive, and 8 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.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep other per-request work small: no heavy SSR, no large JSON parsing or image work in a Worker.

    line 53
  2. Very specific:

    Add a credit pack: add an entry to src/site/plans.ts (code, credits, price in minor units, currency, Dodo product ids per mode).

    line 94
  3. Very specific:

    Add a paid action (a generation kind): add a provider to src/site/generation.ts (cost, run).

    line 95
  4. Very specific:

    Add a queue job of another kind: same path.

    line 96
  5. Very specific:

    Add an admin view: a list query in src/core/admin/queries.ts, a route in src/routes/api/admin/ (requireAdmin first, audit() for any write), …

    line 97
  6. Very specific:

    Use an existing password hash format (users moved in from an older auth): set password in src/site/auth.ts to { hash, verify }.

    line 99
  7. Very specific:

    After editing content: npm run stamp (-- --minor <slug> for a typo fix), then npm test (unit tests, build, output checks) and npm run …

    line 130
  8. Very specific:

    If the code is not in src/core/locale-data.ts, or src/core/messages/<code>.ts does not exist, add them in the template (copy en.ts, …

    line 135
  9. Very specific:

    Add content: content/guides/<code>/…, content/legal/<code>/…, content/about/<code>/about.mdx, a <code> block in each content/tools/*.json …

    line 137

≈ “Common” is an estimate: at least 1 in 5 of the 43,423 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

Site template: notes for agents

The template every site is built from: React 19 + TanStack Start/Router/Query + Tailwind CSS v4 + coss ui (Base UI), prerendered and served by one Cloudflare Worker. Demo: https://template.krisyang.dev. Status and log: ~/code/home/projects/site-template.md. Shared site rules: ~/code/home/lines/sites.md. Look and tokens: DESIGN.md.

Commands

  • npm run dev: dev server on http://127.0.0.1:3000.
  • npm run build: writes the generated public files (robots, _redirects, _headers, llms.txt, the sitemaps, feed.xml), then builds and prerenders every page in every language into .cloudflare/output/v1/workers/default/assets.
  • npm test: unit tests (Vitest), build, then scripts/test.mjs checks the output: sitemap index and child sitemaps (well formed, lastmod, no priority/changefreq, each page in the child of its type), their union = exactly the indexable pages, feed.xml and changelog/rss.xml, content hashes (npm run stamp), hreflang (per page: its indexable languages plus x-default), canonical (self), titles (length, unique), descriptions (length, unique per language), exactly one h1 that contains the keyword, hub pagination pages (self-canonical, not in the sitemap, linked), item pages (ImageObject/VideoObject, media with alt and size, 4-level breadcrumb, noindex items out of sitemap, llms.txt and hub lists), the compare/alternatives/glossary/use-case/gallery/changelog pages (visible "Updated" date = JSON-LD date, disclosure line, table of 6 rows, gallery images with alt, size and lazy loading, changelog sections and feed), the about page's Organization node (/about/#org), <html lang dir>, JSON-LD (valid, types per page type, no FAQPage, visible breadcrumb = JSON-LD breadcrumb = registry), og:image, year in title = updated year, internal links, redirects, robots, headers, llms.txt, noindex outside the sitemap, and that no page starts its JS before LCP or links an external stylesheet.
  • npm run seo-report: per page type (per collection for items) and language, how many pages are indexable and which are noindex, with the reasons from the quality gates, and the stale pages (comparison and alternatives older than 180 days, guides older than 365; a warning only). Reads content only, no build. Exits 1 when a collection is above seo.maxNoindexShare.
  • npm run typecheck: tsc --noEmit (run after a build or dev start, which generates src/routeTree.gen.ts).
  • npm run stamp: sets updated to today in every content file whose content changed and records the hashes in content/.hashes.json (commit it). npm run stamp -- --minor <slug> records a change and keeps the date (typo fixes). See "Freshness, sitemaps, feed".
  • npm run deploy: build, cf deploy (never wrangler), crawler check (npm run check-crawlers), IndexNow ping (npm run indexnow; -- --all pings every URL).
  • npm run e2e: the money path end to end in Chromium (Playwright) against the built Worker on http://127.0.0.1:3000 with the mocks on: sign up → verification email → signup credits → buy a pack through the mock Dodo checkout (real signed webhook into the real handler) → replayed webhook grants nothing → generate (hold → commit) → a failing generation is refunded → admin bootstrap, sign-in, credit adjust, audit row. Passing = 1 passed. Stop npm run dev first (same port). Against the live demo: E2E_BASE_URL=https://template.krisyang.dev E2E_BOOTSTRAP_TOKEN=$(security find-generic-password -s site-template-admin-bootstrap -a template -w) npm run e2e. Playwright prints request headers when a step fails, so rotate the bootstrap token after a failed live run.
  • npm run db:generate after editing src/core/db/schema.ts (writes migrations/NNNN_*.sql); npm run db:migrate:local / db:migrate:remote apply them (cf d1 migrations apply).
  • npm run lighthouse -- --url <url> [--perf 99]: local Lighthouse gate (95 per category by default). Its performance numbers run behind the local proxy and come out lower; pagespeed.web.dev mobile is the reference for the 99 gate (the anonymous PSI API quota is often used up, so use the web page).

Who owns what

Sites merge template updates, so the split matters:

  • Template-owned (sites do not edit; fix it in the template and merge): src/core/**, scripts/**, src/router.tsx, vite.config.ts, vitest.config.ts, tsconfig.json, components.json, DESIGN.md, this file's template sections.
  • Site-owned (each site edits freely): site.config.ts, cloudflare.config.ts, src/site/**, content/**, public/** (except the generated files), the route files a site adds, README.md, the "Site notes" section at the end of this file.
  • Shared route files under src/routes/ (root, locale layout, tools, guides, hubs, about, legal) ship with the template; a site may change them, accepting a merge conflict when the template changes them too.

Where things are

  • site.config.ts: domain, name, languages, home title/description, OG image, contact email, PostHog key variable, IndexNow key, llms.txt switch, CSP allowlist. The only place for these values; scripts import it too.
  • i18n: the language list is languages (+ defaultLang) in site.config.ts; everything that depends on a language reads it, so adding a language changes no code. src/core/locale-data.ts (registry: hreflang, og, intl, dir, name per URL code), src/core/i18n.ts (pure rules: default language at the root, others under /<lang>/; paths passed around are default-language paths with leading and trailing slash; HTML_LANG, OG_LOCALE, DIR, INTL_LOCALE, formatDate, formatNumber; it checks the config on import and throws an error saying what to fix), src/core/locale.tsx (useLocale(), useLocaleParam(), useMessages(), useCoreMessages()). Routes live under src/routes/{-$locale}/; route.tsx there 404s unknown prefixes and the default language's prefix. UI strings: src/core/messages/<code>.ts (one file per language: shell, page templates, account/app pages, emails; en.ts defines the type), src/site/messages.ts (site, Record<Locale, …>). Admin is English only. Links in the current language: <Link to="/{-$locale}/tools/$slug/" params={{ locale: useLocaleParam(), slug }}>.
  • No fallback for content: a page exists in a language only when that language has content for it (pageLocales(page) in src/core/pages.ts: the languages with a title). A missing translation means no page in that language (404, no sitemap entry, no hreflang), never another language's text under /<code>/. Home exists in every language (SITE.title and description need every language). The tools and guides hubs exist in a language only when they have a text block there and at least one member. The language switcher links to the same page where it exists, else to that language's home.
  • SEO: seoHead() and JSON-LD helpers in src/core/seo.ts; every route's head() uses it. seoHead({ breadcrumb }) writes the BreadcrumbList from the same Crumb[] the page shows (trail() and <Breadcrumb crumbs> in src/core/pages/HubPage.tsx). Every page's graph points at the Organization by @id (ORG_ID, /about/#org). There is no FAQPage JSON-LD: the FAQ is visible content only. The page list for the sitemap, llms.txt and redirects is sitePages() in src/core/pages.ts (each page has type, keyword, indexable/reasons, lastmod, breadcrumb); extra static pages go in src/site/pages.ts (ExtraPage). The sitemaps are written from the same list by scripts/generate.mjs (see "Freshness, sitemaps, feed"); the TanStack sitemap plugin is off.
  • Content contract: src/core/content/schema.ts (zod). Every tool JSON and MDX frontmatter is validated when sitePages() reads it; a bad file stops the build with its path and field. Each indexable page has per language keyword (unique per language across the site, contained in the title), demand ({source, note, checked}: where the demand for the keyword was checked; none is not allowed on tools and guides), title (60 characters, 32 CJK, without the site name), description (120-160, 50-90 CJK), lede, optional h1 (default: the keyword); plus published and updated (YYYY-MM-DD). Guides add kind. In MDX frontmatter, nested values (demand, sources, faq, products, table, seeAlso) are one-line JSON.
  • Page types and templates (each route is a thin file over a template in src/core/pages/, built from the blocks in src/core/ui/page/: Breadcrumb, Byline, FaqList, RelatedGrid, StepsList, SourcesList, Pagination, Evidence, Examples):
    • Tool: content/tools/<slug>.json (ToolPage.tsx; a tool needs a widget id from src/site/tools/index.ts, a page without a tool is a guide); fields beyond the common ones: steps (3-4), examples, limits, sections (1-3), faq, related.
    • Guide, about, legal: MDX in content/guides/<lang>/, content/about/<lang>/about.mdx, content/legal/<lang>/ (DocPage.tsx). MDX can use <Evidence caption="…"> for first-hand tables and images. Guides take sources and related (slugs, guides then tools) in the frontmatter; guide and about take faq.
    • Hub: content/hubs/<id>.json (HubPage.tsx; id = tools, guides or a collection id) and content/hubs/<collection>/<category>.json for a category hub: keyword, demand (none allowed), intro, optional name (breadcrumb name of a collection or category hub), sections/faq, pageSize (default and maximum 60). Members are the hub's indexable pages. A collection hub links its category hubs. Further pages are /<hub>/page/<n>/ (route files page/$n.tsx): prerendered, self-canonical, a numbered title and h1, never in the sitemap, linked with plain <a href>. A hub exists in a language only when it has a text block there and at least one member. Without a hub file there is no hub page and the Tools/Guides breadcrumb level is left out.
    • Item (programmatic page): a collection declared in src/site/collections.ts, one file per item in content/collections/<id>/<slug>.json, at /<id>/<slug>/ (ItemPage.tsx, loader loadCollectionPage). Fields: category (category ids), tags, optional related (slugs), optional media (image or video), data (the collection's zod schema), and per language name, optional ownName, keyword, demand, title, description, lede, body (blocks {h2, body}), alt (required with media), faq (0-4). The language block exists only when it has name, keyword and body. Order: breadcrumb (Home, collection, category, name), h1 = name, lede, media, the site's itemData slot, body, FAQ, related items (3 to 8: the item's related, else same category, then shared tags, chosen at build time). JSON-LD: BreadcrumbList and ImageObject or VideoObject (uploadDate = published) for the main media; no FAQPage.
    • Compare (content/compare/<lang>/<a>-vs-<b>.mdx, /compare/<a>-vs-<b>/, ComparePage.tsx), glossary term (content/glossary/<lang>/<slug>.mdx, /glossary/<slug>/, GlossaryPage.tsx): MDX with one-line JSON frontmatter values. Alternatives (content/alternatives/<product>.json, /alternatives/<product>/), use case (content/use-cases/<slug>.json, /for/<slug>/), gallery (content/gallery/<slug>.json, /gallery/<slug>/): JSON with a text block per language like a tool. Changelog: content/changelog/changelog.json, /changelog/ (entries {date, slug, title, items}, newest first, 50 per page, /changelog/page/<n>/, RSS at /changelog/rss.xml). Fields and minimums: "Adding a page". A compare hub (content/hubs/compare.json, /compare/) and a glossary index (content/hubs/glossary.json, /glossary/) use the hub machinery and exist only when the site adds those hub files.
    • Slots: src/site/slots.tsx (PageSlots in src/core/ui/page/slots.ts: afterLede, afterContent, card, itemData) lets a site add visuals to these templates without forking a route.
    • Admin slots (types in src/core/admin/types.ts): src/site/admin.ts (adminSite.nav, read in the browser) appends entries to the admin nav (pages in src/routes/admin/<name>.tsx); src/site/admin-jobs.ts (adminJobs, server only) replaces the jobs table as the admin's job source (dashboard counts, Jobs page, user page jobs). Unset = template behaviour. Test: src/core/admin/queries.test.ts.
  • Quality gates: src/core/seo/quality.ts decides per page and language whether it may be indexed (minimum content per type: tool 250 words / 450 CJK characters, 3-4 steps, 4 FAQ items, 1 example; guide 600 / 1100, 2 H2, 3 in-copy internal links, 1 first-hand element; hub 6 indexable members and a 50-word intro, lowered with seo.hubMinMembers in site.config.ts; about 150 / 280; legal 100 / 180 or noindex: true; item 80 words / 150 CJK characters of its own text (lede, body, FAQ, dataText), an image or video or a data block of 10 entries, 3 related items, no near-duplicate in its collection and language: 5-word shingles, 4-character for CJK, Jaccard above 0.6 fails, and the later item of a pair is the one that fails; compare, alternatives, glossary, use case, gallery and changelog: see "Adding a page"; their near-duplicate check runs within the type and language, at 0.4 for use cases). An item below its minimum is not a build error; the build fails only when more than seo.maxNoindexShare (default 0.2 in site.config.ts) of a collection's items in one language are noindex, with a message naming the collection and the noindex items. A page below its minimum is still built and linkable, but noindex (noindex,follow, no canonical or hreflang), out of the sitemap, llms.txt, hub lists and the hreflang sets of its other languages. SitePage.noindex (language → reasons), SitePage.indexable and indexableLocales(page) carry the result; the app reads it from the content registry modules built in src/core/pages.ts. Run npm run seo-report to see the reasons. Registry modules: virtual:content-index is loaded on every page and holds only what the shell and heads need (languages and noindex state of every page except collection items, hub names, categories; no descriptions; seoState(), isIndexable(), pageExists() in src/core/content/exists.ts). Text for lists loads on demand inside route loaders: virtual:content-lists (tools and docs with descriptions) and virtual:content-collection/<id> (one collection's items: names, descriptions, languages, noindex, related, plus a lazy import per item file; loadCollection() in src/core/content/collection.ts). So the every-page bundle does not grow with the number of items, and members(), relatedEntries() and relatedItemEntries() are async: call them in loaders only. Restart npm run dev after adding a content file.
  • Content folders: content/{tools,guides,legal,about,hubs,collections,compare,alternatives,glossary,use-cases,gallery,changelog}; content/renamed.json, content/videos.json, content/.hashes.json. Page blocks added for these types: CompareTable (src/core/ui/page/), templates ComparePage, AlternativesPage, GlossaryPage, UseCasePage, GalleryPage, ChangelogPage (src/core/pages/), JSON loaders src/core/content/pagefiles.ts, definedTermLd in src/core/seo.ts, stale pages in src/core/seo/freshness.ts. Demo images for the gallery: public/gallery/.
  • Generated public files: scripts/generate.mjs (run by the build): robots.txt, _redirects (from content/renamed.json, every language, with and without trailing slash), _headers (security headers + CSP from src/core/headers.ts, immutable caching for /assets/* and /fonts/*), llms.txt, sitemap.xml (index) with its child sitemaps, sitemap-video.xml (from content/videos.json and the video items), feed.xml, changelog/rss.xml. Every public/sitemap*.xml is generated. They are gitignored.
  • Analytics: src/core/track.ts (PostHog capture API, cookieless, no SDK; no key = console + window.__events), src/core/Analytics.tsx ($pageview, errors → $exception, data-cta link clicks), page types in src/site/analytics.ts. Every event carries site and lang. Events use PostHog's cookieless mode (distinct_id: $posthog_cookieless, PostHog hashes the id server-side per day, nothing stored in the browser), the landing URL's UTM/click-id/ref params, and the country from /cdn-cgi/trace (the first flush waits up to 1.5 s for it); bot user agents send nothing. Cloudflare Web Analytics is turned on per zone in the dashboard, not in code.
  • Shell: src/core/shell/ (Header, Footer, ThemeToggle, LanguageSwitch, NotFound), nav links in src/site/nav.ts. Theme: .dark class set before paint by THEME_SCRIPT (src/core/theme.ts); SITE.theme.default 'system' follows the system preference, 'light' stays light until the visitor picks dark; SITE.theme.color gives the theme-color metas.
  • coss ui: src/core/ui/ (shadcn CLI, components.json, registry @coss). Only components in use are kept: every class in src/ ends up in the CSS inlined in every page. Add with npx shadcn@latest add @coss/<name>.

Performance rules (PSI mobile 99+)

  • Workers Paid since 2026-11-28 ($5/month, spend cap $5, alert at $1). Every site and job shares one account. Included each month: 10M requests and 30M CPU-ms; D1 25B rows read, 50M written, 5 GB; 1,000 cron triggers. A request may use 30 s CPU by default (5 min max). Going over the included amounts costs money, and the old Free limits no longer stop a runaway job: a CPU-heavy bug or a loop over a table now shows up on the bill. The rules below keep usage small.
  • Public pages, sitemaps, feeds and llms.txt are prerendered static assets: Cloudflare serves them from its cache without running the Worker. Never move a public page or a sitemap to SSR or an API route.
  • D1 on a request path: no full-table scans. Every WHERE, JOIN and ORDER BY column has an index (src/core/db/schema.ts). Always LIMIT, and paginate with a cursor, not OFFSET. Check a new query with EXPLAIN QUERY PLAN: it must say SEARCH ... USING INDEX, never SCAN.
  • Bulk jobs (imports, backfills, migrations of data, cron sweeps): estimate rows read and written first (rows × passes) and write the estimate in the commit or PR. Process only changed rows, in small batches. Stop at the first error. Never loop over a whole table per item.
  • Write only when data actually changes. Cron, queue and retry paths guard every UPDATE with the old value in its WHERE (e.g. status = 'held'), so a repeat or redelivery writes 0 rows. Never rewrite a row with the values it already has. Inserts that may repeat use onConflictDoNothing. The ledger (src/core/credits/ledger.ts), cron, queue and webhook follow this.
  • Imports into D1: one pass with foreign keys and triggers off (PRAGMA defer_foreign_keys = ON and drop/recreate triggers around the load, or load into tables before they get triggers). Measure rows read and written on a small table first (meta.rows_read / rows_written from cf d1 query), multiply by the real row count, and check the total is small against the monthly included amounts before running the full import.
  • R2 bills storage and operations above its free tier (10 GB, 1M Class A, 10M Class B per month). Every upload goes through putObject (src/core/storage/r2.ts), which refuses objects over MAX_OBJECT_BYTES (10 MB). Every prefix that grows has a bound: a rate limit on what creates objects (jobs: 20 per user per minute), and deletion of what expires (the cron deletes mock emails after a day). No per-request list on a large prefix.
  • Password hashing: scrypt at N=2^14, r=8, p=5 (src/core/auth/hash.ts, OWASP-equivalent, ~115 ms CPU). Cloudflare's WebCrypto refuses PBKDF2 above 100k iterations in production, though local workerd allows it. Each hash stores its parameters, so older PBKDF2 hashes keep verifying, and a sign-in with one stores a new hash (template hasher only). A site hasher (src/site/auth.ts) keeps its own format.
  • Keep other per-request work small: no heavy SSR, no large JSON parsing or image work in a Worker.
  • Every public page is prerendered; all CSS is inlined in <head> (?inline import in __root.tsx); fonts from SITE.fonts (src/core/head.ts): body inter (self-hosted Inter Latin, preloaded) or system (nothing loaded), plus an optional display heading font (h1-h3, prose headings, font-heading), preloaded; every self-hosted font has a metric-matched local fallback, so the swap causes no layout shift. Site colours, radius and surfaces: override the coss tokens in src/site/styles.css.
  • src/core/Scripts.tsx replaces TanStack's <HeadContent>/<Scripts>: the app JS (entry + modulepreloads) is only added once every element with an elementtiming attribute in the first viewport has painted (3 s fallback). Mark the LCP element with elementtiming="lcp" (images also fetchPriority="high"). Otherwise Lighthouse counts the JS toward LCP and mobile scores drop to 90–95 (seen on Motionboard).
  • Popup components (menu, select, dialog, sheet, toast, tooltip, popover) never render in the first screen of a content page and are never imported by the shell; FAQs are native <details>; widgets load after hydration inside a fixed-height slot.
  • Measured 2026-11-26 on template.krisyang.dev, PSI mobile: home 100/100/100/100, tool page 100/100/100/100.

Freshness, sitemaps, feed

  • npm run stamp after editing content. Each tool JSON, guide, legal, about, hub and collection item file has a hash in content/.hashes.json (the content without updated). Changed files get updated set to today, so lastmod stays true. npm test fails while a hash differs, naming the file. A typo fix: npm run stamp -- --minor <slug> (the slug names every language of the page, or <collection>/<slug>). New files are recorded as they are. Pages from extraPages are not stamped; they set their own lastmod. A new page type adds its content folder to STAMP_DIRS in src/core/seo/stamp.ts. The changelog's updated must not be before its newest entry; its lastmod is updated.
  • sitemap.xml is an index. Children: sitemap-tools.xml (tools), sitemap-guides.xml (guides), sitemap-hubs.xml (all hubs, page 1 only), sitemap-<collection>.xml (items of a collection), sitemap-items.xml (item pages without a collection), sitemap-pages.xml (home, about, legal, compare, alternatives, glossary, use case, gallery, changelog), sitemap-video.xml. Search Console shows the indexed share per file. A child over 45,000 URLs continues in sitemap-<name>-2.xml; an empty child is not written. Every URL has lastmod and the hreflang alternates of its head, no priority or changefreq. A hub's lastmod is its newest member's updated. Code: src/core/seo/sitemaps.ts.
  • /feed.xml is RSS 2.0: guides, compare and alternatives pages and the changelog entries in the default language, newest first (pubDate = updated, or the entry's date; an entry links to its #<date>-<slug> anchor), at most 50 items, linked from every page's head. /changelog/rss.xml holds the changelog entries only and is linked from the changelog page. src/core/seo/feed.ts, written by scripts/generate.mjs.
  • Deploy: after cf deploy, scripts/check-crawlers.mjs fetches / as Googlebot, Bingbot, OAI-SearchBot, PerplexityBot, Claude-SearchBot and Applebot and expects 200; a block fails the deploy and names the agent (turn off Cloudflare "Block AI bots"). SITE.seo.allowTraining: false makes robots.txt disallow GPTBot, ClaudeBot and Google-Extended.
  • IndexNow pings only URLs whose lastmod changed since the last successful ping (.indexnow-sent.json, gitignored; without it, the first run pings everything).

Accounts, credits, payments (layer 1)

Everything runs in the same Worker as the pages: src/server.ts is the entry (fetch → TanStack Start, queue → job consumer, scheduled → cron every 10 min). Turn accounts off with SITE.accounts.enabled = false (the header link and account APIs go away).

  • Env: src/core/server/env.ts (AppEnv, appEnv(), flag()); bindings in cloudflare.config.ts. Local values in .dev.vars (copy .dev.vars.example). Only bindings declared bindings.secret() take local values from .dev.vars (text bindings cannot be overridden locally), which is why BETTER_AUTH_URL is a secret. Production secrets: cf workers secrets update <NAME> --worker <worker> --type secret_text --text … for BETTER_AUTH_URL (https://<domain>), BETTER_AUTH_SECRET, ADMIN_BOOTSTRAP_TOKEN, and when used DODO_PAYMENTS_API_KEY, DODO_PAYMENTS_WEBHOOK_SECRET, RESEND_API_KEY, TURNSTILE_SECRET_KEY, POSTHOG_KEY, GOOGLE_CLIENT_ID/SECRET. The template demo's values live in the macOS keychain (site-template-*). Never print or commit them.
  • Mocks (MOCK_PAYMENTS, MOCK_EMAIL, MOCK_GENERATION = true): a mock Dodo checkout page (/api/mock/dodo/checkout) whose Pay button signs a Dodo-format webhook with the webhook secret and hands it to the real webhook handler; emails stored in R2 under mock-emails/ and readable at GET /api/mock/emails with the x-bootstrap-token header; generation by src/core/jobs/mock-provider.ts (a prompt containing "fail" fails). The template demo runs fully on mocks.
  • DB: src/core/db/schema.ts (Drizzle, D1). Better Auth tables + credit_accounts, credit_transactions (append-only, unique (type, source_type, source_id) so nothing applies twice), credit_reservations, payment_orders, payment_webhook_events, jobs, rate_limits, admin_users, admin_sessions, admin_audit_logs.
  • Auth: src/core/auth/server.ts (Better Auth: email + password with required verification, Google when its keys are set, Dodo plugin, signup credits in the user-create hook), session.ts (getSessionUser, requireUser), client.ts. Site hooks in src/site/auth.ts (authSite): password hasher, basePath, cookie prefix, trusted origins, account options, extra plugins, verification mail, afterUserCreated; empty = template behaviour. Pages: src/routes/{-$locale}/{login,signup,forgot-password,reset-password,account,app}.tsx (noindex, rendered per request, never prerendered: PRIVATE_PATHS in src/core/pages.ts).
  • Credits: only src/core/credits/ledger.ts changes balances (grant, hold, commit, refund, adjust; each one D1 batch guarded so a failed check changes nothing). Tests: ledger.test.ts on in-memory SQLite.
  • Payments: src/core/billing/ (checkout.ts creates an order then a Dodo checkout session; webhooks.ts verifies amount/currency/product, records the event once, grants credits once, marks the order paid; refunds and failures update the order; handleDodoWebhookRequest(request, secret) receives Dodo at a site's own path). Packs: src/site/plans.ts. Portal: POST /api/billing/portal.
  • Jobs: POST /api/jobs → src/core/jobs/create.ts (Turnstile, rate limit, hold credits, queue message) → queue.ts (runs the provider from src/site/generation.ts, stores the file in R2, commits; retries 3×, then fails and refunds) → cron.ts settles stale reservations. Files: GET /api/files/<key> (owner only).
  • Abuse: src/core/security/rate-limit.ts (D1 fixed window, one atomic upsert), turnstile.ts (skipped when no secret key is set).
  • Email: src/core/email/send.ts (Resend HTTP API), templates.ts (verify, reset, receipt; per locale).
  • Server analytics and errors: src/core/server/track.ts (trackServer, captureServerException → PostHog $exception). Server events carry $lib: posthog-server, and inside a request also its user agent and request.cf.country.
  • Admin: separate identity (not Better Auth). src/core/admin/ + src/routes/api/admin/* + src/routes/admin/* (English, no site chrome). First admin: curl -X POST https://<domain>/api/admin/bootstrap -H "x-bootstrap-token: …" -H 'content-type: application/json' -d '{"email":"…","password":"…"}' (also resets that admin's password and sessions). Every credit adjust and login is in the audit log.

Where layer 1 came from

Ported from ShotFrames (~/Documents/imagesaas/apps/api/src), same semantics, rewritten for Drizzle + TanStack Start server routes:

  • credits/ledger.ts ← services/credits.ts + the reserve/commit/refund part of services/images.ts
  • billing/* ← services/payments.ts, services/payments/, domain/payment-plans.ts (Dodo through @dodopayments/better-auth instead of the hand-written client)
  • auth/server.ts ← services/better-auth.ts
  • admin/*, routes/api/admin/* ← services/admin-auth.ts, routes/admin*.ts, utils/crypto.ts
  • security/rate-limit.ts ← services/rate-limit.ts (made atomic); security/turnstile.ts ← services/turnstile.ts
  • server/track.ts ← services/track.ts
  • db/schema.ts ← migrations/0001_initial.sql, 0005_admin_identity.sql, 0022_payment_provider_orders.sql, 0023_better_auth.sql New here: the mock Dodo checkout, mock emails in R2, the Playwright e2e, account/app pages (coss ui). Layer 0 pieces from Motionboard: src/core/Scripts.tsx (JS after LCP), the font fallback approach, scripts/test.mjs checks, IndexNow script.

Recipes

  • Add a credit pack: add an entry to src/site/plans.ts (code, credits, price in minor units, currency, Dodo product ids per mode). Create the product in the Dodo dashboard (test mode first) and paste its id. npm run e2e buys plans[0].
  • Add a paid action (a generation kind): add a provider to src/site/generation.ts (cost, run); the client posts { kind, input } to /api/jobs. Nothing else changes: holding, retries, refunds and storage are core.
  • Add a queue job of another kind: same path; a provider's run can do any work that returns a file. Work that returns no file belongs in a new core handler; ask before adding one.
  • Add an admin view: a list query in src/core/admin/queries.ts, a route in src/routes/api/admin/ (requireAdmin first, audit() for any write), a page in src/routes/admin/ using src/core/admin/ui.tsx, and a link in src/routes/admin/route.tsx.
  • Change the schema: edit src/core/db/schema.ts, npm run db:generate, npm run db:migrate:local, test, then npm run db:migrate:remote before deploying.
  • Use an existing password hash format (users moved in from an older auth): set password in src/site/auth.ts to { hash, verify }; core passes it to Better Auth as emailAndPassword.password. Test: src/core/auth/password.test.ts (ShotFrames' i2s-pbkdf2:<salt>:pbkdf2-sha256:<n>:<hash> format through a real sign-in).
  • Receive the payment webhook at another path (e.g. a URL already registered in Dodo live mode): add a site route file, e.g. src/routes/payments/webhooks/dodo.ts, whose POST returns auth().handler(new Request(new URL('/api/auth/dodopayments/webhooks', request.url), request)). Signature checks and idempotency are unchanged.
  • Move existing credit data in: map each user's balance to one credit_accounts row (available, frozen); history rows to credit_transactions with type grant|purchase|hold|commit|refund|adjust, source_type/source_id (dedupe on the unique (type, source_type, source_id) first), and available_after/frozen_after; open holds to credit_reservations with status held (others committed/refunded). The balance is the credit_accounts row, kept by ledger.ts; the DB has no triggers, so drop any balance triggers from the old database.
  • Go live with real payments: in Dodo create the live products and a webhook to https://<domain>/api/auth/dodopayments/webhooks; set DODO_PAYMENTS_ENVIRONMENT=live_mode, MOCK_PAYMENTS=false and the two Dodo secrets. Real payments need Rui's OK.

Adding a page

Pick the type from the table, record where the demand for the keyword was checked, create the files, then npm run stamp, npm test, npm run seo-report. The slug is ASCII kebab-case and the same in every language; a language with no text block or file has no page. Paths below are default-language paths.

TypeFiles to createURLFields beyond the common onesMinimums (below: noindex)
Toolcontent/tools/<slug>.json, widget in src/site/tools/index.ts/tools/<slug>/tool, steps, examples, limits, sections, faq, related250 words, 3 to 4 steps, 4 FAQ, 1 example
Guidecontent/guides/<lang>/<slug>.mdx/guides/<slug>/kind, sources, related600 words, 2 H2, 3 internal links, 1 first-hand element
Hubcontent/hubs/<id>.json (tools, guides, compare, glossary, a collection)/<id>/intro, sections, faq, pageSize6 indexable members (glossary 8), intro 50 words
Itemcontent/collections/<id>/<slug>.json ("Add a collection")/<id>/<slug>/category, media, data, body, alt80 words, media or 10 data entries, 3 related
Comparecontent/compare/<lang>/<a>-vs-<b>.mdx/compare/<a>-vs-<b>/products (2, each ours or third-party), verdict, table (factor, a, b, chooseIf), pricing (asOf, a, b), sources700 words, 6 table rows, 3 sources
Alternativescontent/alternatives/<product>.json/alternatives/<product>/product, criteria, entries (name, url, bestFor, price, relation, notes), sections, sources, faq5 entries of 40 words each, 600 words, 3 sources
Glossarycontent/glossary/<lang>/<slug>.mdx/glossary/<slug>/definition, example (text, caption), seeAlso, useIt (name, path)definition 40 to 60 words, definition and body 200 words, 3 see-also, 1 try-it link
Use casecontent/use-cases/<slug>.json/for/<slug>/audience, problems (3), workflow (3 to 6), examples, cta, faq (3 to 6)400 words, 3 examples of 20 words each, near-duplicate at 0.4
Gallerycontent/gallery/<slug>.json, images in public//gallery/<slug>/intro, entries (media, alt, title, caption, facts, link), faqintro 80 words, 6 entries with 15-word captions
Changelogcontent/changelog/changelog.json/changelog/entries (date, slug, title, items), newest first1 entry

CJK minimums are 1.8 times the word counts (compare 1260, alternatives 1080, glossary 360, use case 720, gallery intro 144). A text block in JSON has keyword, demand, title, description, optional h1, lede; the file has slug, published, updated (use YYYY-MM-DD of today, UTC). In MDX the same fields are frontmatter lines.

Rules for the copy: write for a term someone searches, and check page 1 shows pages of the same type (record it in demand.note; none is only for hubs, about, legal and the changelog). The title is at most 60 characters (30 CJK) and contains the keyword; the description is 120 to 160 characters (50 to 90 CJK) and answers the query in the first clause; the lede answers in one or two sentences. The h1 contains the keyword. H2s name the reader's questions. Every fact about another product has a source with the date checked, and a price appears only when a source states it; write "not checked" otherwise. Pages with one of our products next to third-party ones show the disclosure line by themselves (relation: 'ours'). Alt text describes the image (at most 125 characters). A year in a title only on guides and comparisons, and it must be the year of updated. The FAQ is visible text; there is no FAQPage markup.

What fails the build (npm run build, npm run seo-report): invalid JSON or frontmatter; any schema error (missing field, bad date or slug, title width over 60, description length, keyword not in the title or h1, demand: none outside hub/about/legal/changelog, a file name that differs from its slug, a compare slug that is not <a>-vs-<b>, updated before published, a changelog out of order or with a repeated <date>-<slug> or an updated before its newest entry); a keyword, title or description used twice in a language; a collection with more noindex items than seo.maxNoindexShare. npm test also fails while content/.hashes.json differs from the content (run npm run stamp) and on any post-build check.

What becomes noindex (the page is built and linkable, with noindex,follow, no canonical or hreflang, and left out of the sitemap, llms.txt, hub lists and feeds): content below the minimums above, a near-duplicate of an older page of the same type and language (the later one fails), a hub with too few indexable members, a legal page with noindex: true. npm run seo-report lists each with its reasons.

JSON-LD (always plus BreadcrumbList, from the visible breadcrumb): compare and alternatives Article, glossary DefinedTerm, use case, gallery and changelog the breadcrumb only. "Updated <date>" is visible on guides, compare, alternatives, glossary, use case and the changelog, and is the same date as dateModified. Sitemap child for all six: sitemap-pages.xml. Hubs: add content/hubs/compare.json once there are 6 comparisons and content/hubs/glossary.json at 8 terms (without the file the page has no hub and the Compare/Glossary breadcrumb level is left out); other types have no hub. Inbound links come from the copy of other pages and from src/site/nav.ts; the demo content links to its pages from the case-converter guide.

After editing content: npm run stamp (-- --minor <slug> for a typo fix), then npm test (unit tests, build, output checks) and npm run seo-report (noindex reasons, stale pages). Replace the demo pages with the site's own; the template's tests for them run only while the demo files exist.

Add a language

No code changes.

  1. site.config.ts: add the code to languages and its text to title and description.
  2. If the code is not in src/core/locale-data.ts, or src/core/messages/<code>.ts does not exist, add them in the template (copy en.ts, translate) and merge into the sites.
  3. Fill the new entries in src/site/messages.ts, src/site/nav.ts and the other Record<Locale, …> data of the site (npm run typecheck lists them).
  4. Add content: content/guides/<code>/…, content/legal/<code>/…, content/about/<code>/about.mdx, a <code> block in each content/tools/*.json and content/hubs/*.json. Pages without a translation do not exist in that language.
  5. npm test.

Add a collection

A collection is a set of programmatic pages, one per item (symbols, recipes, prompts), each with its own data. The demo is symbols.

  1. src/site/collections.ts: add defineCollection({ id, categories, data, dataEntries?, dataText? }). id is the folder name and the URL segment (/<id>/<slug>/); categories are the category ids; data is a zod schema for the data of an item; dataEntries(data) returns the entries of its data block (10 or more count as main content when there is no media); dataText(data) returns item-specific text inside data.
  2. Routes: copy src/routes/{-$locale}/symbols/ (four files) and rename symbols to the id.
  3. Hubs: content/hubs/<id>.json and content/hubs/<id>/<category>.json for every category. A slug cannot be a category id.
  4. Items: content/collections/<id>/<slug>.json (fields in "Page types", example in content/collections/symbols/). Media files go in public/. Show the data in the itemData slot in src/site/slots.tsx.
  5. npm run seo-report lists every noindex item with its reasons; npm test.

An item is noindex (kept out of the sitemap, llms.txt, hub lists and hreflang, still built and linkable) when it has fewer than 80 words / 150 CJK characters of its own text, has no media and fewer than 10 data entries, has fewer than 3 related items, or is a near-duplicate of an older item. The build fails when more than seo.maxNoindexShare of a collection's items are noindex: fix the items, do not raise the limit. A schema error, a duplicate keyword, title or description also fails the build. A language the item has no text for has no page.

Starting a new site from the template

  1. gh repo create krisyangdev/<slug> --private and clone the template into ~/code/sites/<slug> (git clone git@github.com:krisyangdev/site-template.git <slug>), then git remote rename origin template and git remote add origin <new repo>; git push -u origin main.
  2. Edit site.config.ts (id, name, domain, worker, languages, copy, email, IndexNow key + public/<key>.txt), src/site/styles.css (--brand light/dark), public/favicon.svg, public/og.png, cloudflare.config.ts (bindings).
  3. Replace the demo content in content/, src/site/home/, src/site/tools/, src/site/nav.ts.
  4. npm test, npm run deploy, check the live URL and PSI.

Taking template updates into a site

git fetch template && git merge template/main, resolve conflicts (site-owned files keep the site's version), npm install, npm test, deploy. Make shared fixes in the template first, then merge them into each site; never fix src/core/ only in a site.

Adopting the template in an existing site (e.g. Motionboard)

Add the template as a remote and merge with unrelated histories (git remote add template …; git fetch template; git merge template/main --allow-unrelated-histories), or start from a fresh clone and copy the site's content in. Then move: site config values into site.config.ts; the duplicated /zh/ route tree into {-$locale} routes; seo.ts/track.ts/Scripts.tsx/scripts to the core versions; hand-written CSS to Tailwind + coss tokens; keep site-only parts (data generators, video components, D1 bindings) under src/site/ and scripts/site/. Acceptance: same URLs (sitemap diff empty), npm test green, PSI mobile ≥ 99 on home and one deep page.

Decisions (2026-11-26, template dev)

  • npm, single package (no monorepo), Node 22 (type stripping for site.config.ts in scripts).
  • i18n with the official {-$locale} optional segment and plain typed dictionaries per locale (no Paraglide compile step): our sites carry few UI strings; page text lives in content files that are loaded per page.
  • MDX through @mdx-js/rollup + import.meta.glob (no Content Collections): fewer moving parts, one chunk per document.
  • Fonts: Inter only (coss default), Latin subset self-hosted; Geist Mono dropped for the system mono.
  • coss html { font-sans font-mono } from the registry was a bug (everything rendered mono); fixed to font-sans in app.css.
  • Template demo runs on template.krisyang.dev (a throwaway subdomain of an existing zone).

Site notes: Motionboard

motionboard.app: 58 launch-film shot recipes and a free HyperFrames skill for Claude Code and Codex. Status, next steps and log: ~/code/home/projects/motionboard.md. This repo is built from the template: the template remote is site-template (a local path until it moves to GitHub), updates come in with git fetch template && git merge template/main. Sections above are the template's; this section is Motionboard's.

What lives where

  • Config: site.config.ts (template shape: domain, name, id, languages, home title and description, ogImage = the hero film cover, IndexNow key, llmsTxt, CSP with the media host). Motionboard extras (media host, GitHub URL, skill install command, H1 copy) are in src/site/config.ts. cloudflare.config.ts is Motionboard's own (Worker motionboard, D1 DB) and must not import anything the app imports: the Cloudflare Vite plugin adds every file the config imports to Vite's fs.deny, and the dev server then answers 500 ("Failed to load url /site.config.ts"). Its name and domain repeat SITE.worker and SITE.domain; scripts/site/test.mjs checks they match.
  • Content: recipes are the template collection recipes (declared in src/site/collections.ts): one file per recipe, content/collections/recipes/<slug>.json, with the item text per language (keyword, demand, title, description, lede = one-line definition, name = common name, ownName = Motionboard shot name, body = how-to, alt = poster description, faq) and data (number, film id, original samples, and the long recipe text per language: why, spec, prompt, says, vs). The template gates, lists, breadcrumbs and JSON-LDs them like any collection. Hubs and guides in content/pages/<id>.json (schema in src/site/data/content.ts), 301s in content/renamed.json (default-language paths, the template adds every language and the no-slash form).
  • Routes: src/routes/{-$locale}/ has home, recipes/$slug (Motionboard's own RecipePage on the template's loadItem, relatedItemEntries and itemHead; there is no /recipes/ hub, it 301s to /, and the home page links every recipe), $hub (the five hub pages; its params.parse declines other single-segment paths such as /zh/, so they reach the home route), guides/$id and saved (noindex). Same URLs as before the migration.
  • App code: src/site/components/ (home: compact hero HeroFilm.tsx = one H1 line + search + chips, then the shelves with the grid on the first screen; film tiles: desktop tiles loop while ≥50% in view after page load, phones play the one nearest the centre, nothing under reduced motion, first-shelf first 4 posters eager and the first fetchpriority high; posters use srcset -xs.jpg 480w / -m.jpg 960w (media(t, 'jpgXs'); new films need the -xs.jpg too, made from the 1920 poster and uploaded with upload-media.sh); on phones the card Copy pill sits on the poster's bottom-right, from 768px in the title row; recipe page, content pages), src/site/data/ (typed access to the recipe data; gen/ is generated), src/site/lib/ (saved list in localStorage, like and copy counts with a React store, GSAP registration, locale-aware links), src/site/server/stats.ts (D1 server functions), src/site/seo.ts (head data on the template's seoHead() and JSON-LD helpers), src/site/messages.ts (UI strings), src/site/nav.ts (header and footer links), src/site/brand.tsx (logo mark), src/site/styles.css (--brand and the few rules Tailwind cannot express: hero and compare-block sizing, copy burst, view-transition timing).
  • Sitemap, _redirects, _headers, llms.txt and the video sitemap come from the template's scripts/generate.mjs. Recipe pages and recipe films come from the collection (one video sitemap entry per recipe and language). Motionboard feeds the rest through src/site/pages.ts: hub and guide pages, the showcase films (extraVideos, three on /guides/launch-video-examples/), /r/<old>.md redirects, the X-Robots-Tag: noindex block for /r/* (extraHeaders), the llms.txt text, and sitemapExclude (saved list, #recipes, the /r/*.md files the crawler finds). scripts/site/recipes.mjs writes the lists it reads into src/site/data/gen/ before every dev start and build (predev/prebuild).
  • Scripts in scripts/site/: recipes.mjs (recipe files for agents in public/r/ and skills/motionboard/recipes/, public/source, README tables, gen/), zone-redirects.mjs (keeps the zone's trailing-slash rule in step with _redirects, runs in npm run deploy), upload-media.sh (npm run upload-media -- <files>), test.mjs (Motionboard's output checks, run by npm test after the template's).
  • Analytics: events page_view, copy (with recipe), cta_click (links marked data-cta: GitHub and skills.sh), video_play. PostHog key in .env.production (VITE_POSTHOG_KEY).
  • Look: prototype C "Bright reel" (Rui 2026-11-28; prototype in ~/Library/Application Support/Claude/side-session-notes/local_08c08a06-7bf4-404e-9c7d-e1e9a83b6f8e/visual/motionboard/c/). Tokens in src/site/styles.css override the coss tokens (red primary #d9381f, warm surfaces, soft-shadow white cards 24-28px, sky-to-peach gradients bg-hero/bg-recipe/bg-hub, position dot colours) and add Motionboard utilities (bg-surface, shadow-card, rounded-card, font-display…); dark is derived from the same tokens. site.config.ts: theme.default: 'light', fonts.body: 'system', fonts.display = Bricolage Grotesque (public/fonts/bricolage-grotesque-latin.woff2, Latin, weights 700-800). Copy is visible without hover on every card and on the recipe page. Tracking: copy carries from = page type of the page the Copy was on (home, hub, recipe, guide, saved); $pageview carries prev_path (template). The header (template shell) is made sticky and translucent from styles.css; its nav row is hidden below 768px. Containers use --site-width (82rem).

Commands

  • npm run dev (http://127.0.0.1:3000), npm run build, npm run preview (http://127.0.0.1:4173), npm test (Vitest, build, the template's checks, Motionboard's checks), npm run typecheck (needs a build or dev start first for routeTree.gen.ts), npm run deploy (build, cf deploy, zone redirect rule, IndexNow).
  • Video renders never run on the Mac.

Checks before reporting a UI change

  • npm test passes.
  • node ~/code/home/tools/design-check/check.mjs --allow posthog.com --allow cloudflareinsights.com --allow motionboard.app <url>. Known false positive: it reports load failed: ...-m.mp4 on pages with media="(max-width: 767px)" sources, because the browser fires error on a <source> whose media does not match.
  • Home and one recipe page on pagespeed.web.dev, mobile (the local Lighthouse numbers run behind a proxy and come out lower). The first-screen posters carry elementtiming="poster" and fetchPriority="high"; a new LCP image needs both so src/core/Scripts.tsx holds the app JS back until it is on screen.

Handoff (2026-11-16)

The repo moved from ~/Documents/motion-lexicon-site to ~/code/sites/motionboard. The task-3 audit table: ~/Library/Application Support/Claude/side-session-notes/local_b345c0d6-e7e0-4bab-8a09-d8143b50b9a1/mb-task3-audit.md.

Launch-film showcase and film tools (task 10, 2026-11-26)

  • /guides/launch-video-examples/ is a guide page built from the showcase block (src/site/data/content.ts, rendered by ShowFilm in src/site/components/page/ContentPage.tsx). Films are launch-<product>-<tool>{.mp4,-m.mp4,.jpg} on R2; the video sitemap lists the films whose name ends in -motionboard (scripts/site/recipes.mjs).
  • Skill film/join.mjs snaps cuts to the beat of the bundled tracks (tempo table at the top of the file) and mixes per-shot sfx cues (render clock) from film/sfx/ (CC0). Film sources and v3 joins: winlinux ~/mb/film-test/motionboard-v2/<product>/launch-film/ (film-v3.json), Mac copies in marketing/film-test/ (git-excluded). Web encodes: winlinux ~/mb/showcase/enc.sh <src> <base> [poster s].
  • Long unbroken links in zh body text overflow at 390 px; the content column has overflow-wrap: break-word.

Adding recipes (task 11, 2026-11-26)

  • A recipe = content/collections/recipes/<slug>.json (en and zh blocks with a checked demand and an alt written from the film) + skills/motionboard/source/<video>/ + a film/shots.json slot + five media files (<video>.mp4, -m.mp4, -s.mp4, .jpg, -m.jpg, posters 960x540) + orig-<youtubeId>-<startSec>.{mp4,jpg} per sample. npm run build regenerates recipe md, README tables, llms.txt, the sitemap lists and the video sitemap.
  • Original clip names collide when two recipes sample the same film at the same start second (orig-TNhX1uR2vO8-0 serves light-reveal, text-object-interleave and text-behind-object-effect). Reuse the existing file; never re-encode it over the R2 copy.
  • The batch kit's merge.py (in ~/Library/Application Support/Claude/side-session-notes/local_b345c0d6-e7e0-4bab-8a09-d8143b50b9a1/mb-batch-kit/) still writes the old terms.json/en.json/seo files, which no longer exist (task 15, v8.4.0). Change it to write one content/collections/recipes/<slug>.json per recipe before batch 2.

Plan to 100: where batch 1 stopped (2026-11-26)

  • Plan: ~/Library/Application Support/Claude/side-session-notes/local_582a33d3-16af-453e-b9c7-f939718a155c/mb-plan-100.md (5 batches, one minor release each, v8.0.0 at 100). Batch 1 (#49–58) shipped as v7.1.0 (95e6407). Rui stopped the work after batch 1 (「做完第一批停下来」); start batch 2 only when Rui or the lead says so.
  • Batch kit (copies of the scratchpad files): ~/Library/Application Support/Claude/side-session-notes/local_b345c0d6-e7e0-4bab-8a09-d8143b50b9a1/mb-batch-kit/: BRIEF.md (film builder brief for Sonnet subagents, hyperframes check rules at the end), COPY.md + FORMAT-example.json (copy brief; each subagent writes <slug>.json as {terms, en, seo, shot}), merge.py (merge into the recipe files and shots.json; needs the change above), sheet.sh <folder> "<times>" <tag>, dl.sh / dl2.sh (yt-dlp downloads of the original moments).
  • winlinux ~/mb/p100/: sheet.sh + cj.py, render.sh <folder> <poster s> (renders, then enc.sh, CRF env default 20, -m CRF+3, -s CRF+7, grainy films need CRF=27), orig/out/ (encoded original clips), orig/raw/ (raw downloads for batches 2–3, <ytid>-<startSec-1>.mp4).
  • Batch-1 lessons: review every film from contact sheets before rendering (builders usually needed 1–3 rounds: framing, text size, headlines 72px+, captions 26px+, a lockup hold of at least 2.2 s, cold-seek fromTo errors); text_occluded and contrast errors on blurred or flare layers are false positives.
  • Batch 2 needs, in order: read the batch-2 rows in mb-plan-100.md; download and encode the originals (check orig/raw/ first); brief one builder per film, review the sheets, then render; collect copy JSONs and run merge.py; add hub links and bump the counts (58→68) the way 95e6407 did (the count also sits in site.config.ts and content/pages); ship with npm run upload-media -- <files>, npm test, design-check, commit, push, npm run deploy, gh release create v7.2.0; check live (200, both sitemaps, playback at 1440 and 390); run PSI on 2 new pages and report to the lead. The Netflix-style page uses "link": true on its sample, so no clip is self-hosted.

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.