next-sanity-starter AGENTS.md

The main repository rulebook for a pnpm monorepo, meaning one codebase containing multiple related apps and packages, including a Next.js site and Sanity studio.

In plain words
What is it for?
It guides code changes, new editorial modules, schema generation, type checking, formatting, and reuse of existing components, utilities, snippets, and queries.
Why use it?
It explains how the project’s reusable content modules and translations must be wired together, preventing incomplete changes and broken generated types.

Instructions file for CodexOpenCode

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 instructions/backendforth/next-sanity-starter/agents-md
Clone the repo
git clone --depth 1 https://github.com/backendforth/next-sanity-starter

Made for: Codex, OpenCode.

Per session 5,512 This file is loaded in full into every session.
When invoked 5,512 The same file — it is already loaded in full.
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.05512 $0.05512
Opus 5 $0.02756 $0.02756
Sonnet 5 $0.01102 $0.01102
Haiku 4.5 $0.00551 $0.00551

Measured 2d ago against content hash ac5eec698343, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

next-sanity-starter AGENTS.md 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 2d ago.

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.

AGENTS.md · 319 lines

How it starts

The opening of the file, as written. The whole thing — 319 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AGENTS.md — next-sanity-starter

This is the canonical guardrails file for AI coding assistants (Claude Code, Cursor, Windsurf, Codex, Copilot). Read this before writing or changing code. Per-subtree CLAUDE.md, .cursor/rules/*.mdc, and .github/copilot-instructions.md all defer to this document — keep edits here, not in mirrors.

TL;DR

This is a pnpm monorepo with two apps (web Next.js 16 App Router, studio Sanity v5) and shared packages/*. Editorial content is rendered via a strict module pattern: every renderable content block is a paired module.<name> Sanity object plus a Module<Name>.tsx React component, wired in eight places. Multilingual content uses @sanity/internationalized-array — locales are resolved at render time, never inside GROQ.

Before writing code:

  1. Search for an existing module, util, snippet, or query that already does what you need.
  2. If you need a new content block → it is a module; wire all 8 points or revert.
  3. After any schema change → run pnpm studio:generate, then pnpm typecheck, then pnpm format.

Principles (priority order — apply top-down when in doubt)

  1. Reuse before invention. Grep studio/schemas/objects/modules/, web/src/components/modules/, web/sanity/queries/snippets/, web/sanity/utils/ first.
  2. Pair or don't ship. A schema without its component (or vice versa) is a bug, not a partial commit.
  3. All 8 wiring points or revert. A partially wired module silently breaks the editor or the renderer. Atomic.
  4. Typegen is the source of truth for Studio types. Never hand-edit studio/sanity.types.gen.ts or studio/schema.json. web/sanity/types/* are hand-maintained for now — keep them aligned with schema field changes.
  5. Locale-aware at render time, not query time. Never coalesce(field[language=="en"]...) in GROQ. Always resolve via pickLocalizedString / parseLocalizedText.
  6. READMEs are deep docs. Per-folder README.md files are authoritative for the local pattern — link to them, do not duplicate.

Read the full file on GitHub · 319 lines

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. 2d ago First seen · 319 lines · 5,512 tokens per session scan A ac5eec698343

Subscribe to this mod's changes

next-sanity-starter AGENTS.md is an instructions file published in the GitHub repository backendforth/next-sanity-starter (4 stars, last pushed 26d ago), licensed ISC. It adds 5,512 tokens to every session, about $0.0276 per session on Opus 5. 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.