modules

A project rule for adding, renaming, or removing modules, where each module is a Sanity content object paired with a React component. It requires wiring the pair through schemas, queries, types, and rendering code.

In plain words
What is it for?
Use it when changing the site’s reusable content blocks and when regenerating types and checking the resulting code.
Why use it?
It prevents a module from working in one layer while being missing from another, which can cause content or rendering failures.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/backendforth/next-sanity-starter/modules
Clone the repo
git clone --depth 1 https://github.com/backendforth/next-sanity-starter

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 521 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00521
Opus 5 $0.00000 $0.00260
Sonnet 5 $0.00000 $0.00104
Haiku 4.5 $0.00000 $0.00052

Measured yesterday against content hash 9cf5b06ff76b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

modules scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/modules.mdc · 37 lines

What it actually says

A module is a paired Sanity object (module.<id>) plus a React component (Module<Name>.tsx). Adding, renaming, or removing one is atomic across 8 files:

  1. studio/schemas/objects/modules/module<Name>.tsdefineType, name: "module.<id>", fields, preview, optional icon.
  2. studio/schemas/index.ts — import + add to schemaTypes.
  3. studio/schemas/objects/editors/richTextMedia.ts — append { type: "module.<id>" } to of.
  4. studio/schemas/fields/modulesArrayField.ts — append { type: "module.<id>" } to moduleTypes.
  5. web/src/components/modules/Module<Name>.tsx — accepts { data, locale, siteLocale }, sets data-sanity attrs.
  6. web/src/components/modules/index.ts — re-export from barrel and register in ModulesRenderer.tsx.
  7. web/sanity/queries/components/modules/<name>.ts — GROQ projection, full i18n arrays, re-export from index.ts.
  8. web/sanity/types/modules/<name>.ts — hand-maintained TS shape, re-export from index.ts.

After steps 1–4 land, run pnpm studio:generate and commit the gen artifacts.

DO:

  • Ship all 8 in a single commit.
  • Reuse media.image, media.video, media.videoLoop from studio/schemas/objects/media/.
  • Project i18n fields as full { _key, _type, language, value } arrays.
  • Read i18n via pickLocalizedString / parseLocalizedText.

DON'T:

  • Land schema without component (or vice versa).
  • Add { type: "module.<id>" } to only one of richTextMedia.ts / modulesArrayField.ts.
  • Index i18n arrays directly (title[0].value).
  • coalesce(field[language==$locale].value, ...) in GROQ.
  • Hand-edit studio/sanity.types.gen.ts or studio/schema.json.
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 37 lines · 0 tokens per session scan A 9cf5b06ff76b

Subscribe to this mod's changes

modules is a cursor rule published in the GitHub repository backendforth/next-sanity-starter (4 stars, last pushed 25d ago), licensed ISC. It costs nothing until one of its globs matches a file; then it loads 521 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.