nexity / base
AGENTS.md19 starsChanged 9 days agoMITView on GitHub
Project-level instructions for any AI coding agent (Codex, Claude Code, Cursor and others). Agents that look for another file name get a pointer to this one (CLAUDE.md is a one-line @AGENTS.md import). Detailed rules live in package-specific files: Three files are the project's source of truth for every agent and every skill: this file and its web//studio/ siblings (how to build), DESIGN.md (how it looks) and BRAND.md (what it says; a template here until the project fills it). Read DESIGN.md…
- Commits and pushes
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 31,700 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 repository21 other files it gives its agents.
- AGENTS.mdAGENTS.md
- theme-meridian/AGENTS.mdAGENTS.md
- base/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- theme-meridian/CLAUDE.mdCLAUDE.md
- blog-post-quality-reviewSkill
- blog-post-updateSkill
- brand-kitSkill
- create-sectionSkill
- generate-altsSkill
- internal-linksSkill
- link-fixSkill
- marketing-setupSkill
- product-mockSkill
- project-setupSkill
- pr-writeupSkill
- sanity-module-catalogSkill
- sanity-optimizationsSkill
- site-contradictionsSkill
- source-reviewSkill
- work-humanizerSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
17 rules. About 0 are common, 2 are distinctive, and 15 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
15
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 36
Keep this file and web/AGENTS.md short: Codex reads at most 32 KiB of AGENTS.md per directory chain (root + package together) and drops the …
- Distinctive: line 86
Write PR descriptions (and any other text people will read, such as release notes) in plain language: say what changed and why, keep every …
- Very specific: line 92
Keep the PR genre: ## Summary, a decision/notes section only when the reviewer needs one, and ## Test plan.
- Very specific: line 134
A fixed mistake becomes a rule: When a bug or regression could happen again, add the rule where the next person will read it (this file, …
- Very specific: line 138
All files use kebab-case: my-component.tsx, api-utils.ts.
- Very specific: line 142
Never use shorthand variable names (v, i, k, e) — always use descriptive words (cleanVariant, index, key, error)
- Very specific: line 143
Use camelCase for functions and variables
- Very specific: line 144
Use SCREAMING_SNAKE_CASE for constants
- Very specific: line 145
Use PascalCase for class/component names
- Very specific: line 147
Use descriptive names with auxiliary verbs (isLoading, hasError)
- Distinctive: line 151
Prefer interfaces over types.
- Very specific: line 152
Use satisfies operator for type validation
- Very specific: line 156
Keep HTML flat — implement tabindex, aria-label, keyboard handlers and a visible focus state
- Very specific: line 157
Use rem over px; avoid inline styles
- Very specific: line 161
Add validation in web/src/setup/envVariables.ts whenever a new env var is introduced.
- Very specific: line 177
Never copy the global-section GROQ: a route calls fetchGlobalSections(fullPath) ("/", "blog/my-post") in its Promise.all and renders …
- Very specific: line 189
Read DESIGN.md (the look) and BRAND.md (the copy) first.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 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
Project-level instructions for any AI coding agent (Codex, Claude Code, Cursor and others). Agents that look for another file name get a pointer to this one (CLAUDE.md is a one-line @AGENTS.md import). Detailed rules live in package-specific files:
| File | What to find there |
BRAND.md | What the site says: who the company is, audience, voice and tone, messaging, product facts, the names and numbers copy may use, what must never be invented. Ships as an unfilled template (first line brand-template); until it is filled in, write obviously placeholder copy. Read with DESIGN.md before any section or page work |
DESIGN.md | The visual contract. Read before building anything a visitor sees: tokens (colors, type, radius, spacing) in the frontmatter, then how to use them — section anatomy, buttons, cards, dark bands, do's and don'ts. Ships with neutral defaults (Tailwind neutral, Inter); replace it with your design system. An approved design file wins over it; it wins over mockups and screenshots |
web/AGENTS.md | React/Next.js 16 patterns, section components, Tailwind v4 styling, GROQ queries, images/links, RichText typography, CTA rendering, color inversion |
studio/AGENTS.md | Sanity schema rules, field conventions, section schema template, CTA vs link type, rich text type selection, content modelling, ndjson import |
docs/agents/ | The full checklists and rules this file and web/AGENTS.md summarise: new section, new document type and listing pages, content patterns, template setup, dependency constraints, styling, RichText, images and links, client code. Each summary below links its file; open it before doing that task |
docs/README.md | What this starter is, how to get it running, and an index of the guides below |
docs/FEATURES.md | Editor/marketer-facing feature inventory: content types, page-builder sections, SEO, integrations |
docs/guides/sanity-blueprints.md | CORS origins + revalidate webhook as code (root sanity.blueprint.ts): env, first run, plan/deploy, moving off hand-made resources |
docs/guides/markdown-for-agents.md | Markdown for AI agents: /x.md and Accept: text/markdown → proxy.ts → /api/markdown, the per-section serializers (SECTION_MARKDOWN_SERIALIZERS), the Portable Text serializer, llms.txt, the "Copy as Markdown" button, headers and caching, how to test with curl |
docs/guides/before-release.md | Pre-launch checklist — brand assets, llms.txt, sitemap/robots, IS_INDEXABLE, SEO field query, JSON-LD validation, placeholder sweep, nav active state, Sanity CORS, consent, GTM, stale CSS, PageSpeed/Lighthouse |
CONCEPTS.md | Shared domain vocabulary (entities, named processes, status concepts) — read when orienting to the codebase or discussing domain concepts |
Agent layer: context, skills, reviewers
Three files are the project's source of truth for every agent and every skill: this file
and its web//studio/ siblings (how to build), DESIGN.md (how it looks) and BRAND.md
(what it says; a template here until the project fills it). Read DESIGN.md and BRAND.md before any work a visitor will see, and
treat what they say as binding over your own defaults.
Repeatable workflows live as skills in .agents/skills/<name>/SKILL.md, and read-only
reviewers in .agents/agents/<name>.md (bundled with this project, see
docs/guides/skills.md). When a task matches a skill, follow the
skill instead of improvising: first setup → project-setup, a new section →
create-section, a visual change → sanity-module-catalog, links → link-fix, alt texts
→ generate-alts, Sanity speed or cost → sanity-optimizations; before launch, walk
docs/guides/before-release.md. These docs write a skill call as /name (Claude Code);
in Codex it is $name, and any other agent opens the SKILL.md and follows it. An agent
without named subagents reads the reviewer's .md and walks its checklist itself.
Keep this file and web/AGENTS.md short: Codex reads at most 32 KiB of AGENTS.md per
directory chain (root + package together) and drops the rest. A long checklist goes in
docs/agents/ with a two-line summary and a link here.
⚠️ This repo is a TEMPLATE — rename it as a next step after init
This starter runs under a placeholder name (Nexity, npm scope @nexity). Offer the rename once the site runs, before project-specific features, and ask for the project name if it isn't given. Rename the package scope first (root, web/ and studio/ package.json plus web's @nexity/studio dependency in lockstep, then pnpm install and pnpm typecheck), then the display name. Project IDs are env-driven, never hardcoded. Never hand-edit web/public/admin/static/*; regenerate it.
Read docs/agents/template-setup.md before the rename or any setup work: the full file list, first content, keeping the template installable, linking the Sanity blueprint.
Workspace Structure
This is a pnpm workspace monorepo with two packages:
web/— Next.js 16 application with embedded Sanity Studio at/adminstudio/— Standalone Sanity Studio (same schemas, for editors)
Schema types live in studio/ and are imported by web/ via @nexity/studio workspace dep.
Commands
# Root (affects all packages)
pnpm dev # Start both web and studio in parallel
pnpm dev:web # Start Next.js web app only
pnpm dev:studio # Start standalone Sanity Studio only
pnpm build # Build the Next.js web app
pnpm lint # Oxlint (repo-wide) + check:client; pnpm lint:fix to auto-fix
pnpm check:client # Client boundary check: no RichText/FeatureIcon/@sanity/client in client code, sections import ./client-lazy
pnpm lint:strict # Oxlint with type-aware rules (slower; needs oxlint-tsgolint)
pnpm format # Format with Oxfmt (repo-wide); pnpm format:check to verify
pnpm typecheck # TypeScript type check in all packages
pnpm agent:install # Repair client links; --source <checkout> to install skills
pnpm agent:update # Update with --source <checkout>; preserves local edits
pnpm agent:doctor # Read-only setup diagnostics; --json for agents
pnpm blueprints:plan # Diff sanity.blueprint.ts (CORS + revalidate webhook) against the live project
pnpm blueprints:deploy # Apply it (plan first). Setup: docs/guides/sanity-blueprints.md
# Web-specific (run from repo root or web/)
pnpm --filter @nexity/web ts:typegen # Regenerate Sanity TypeScript types
pnpm --filter @nexity/web envs:validate # Validate environment variables
# Studio-specific
pnpm --filter @nexity/studio deploy # Deploy standalone studioAlways use pnpm — never npm or yarn.
Pull Requests
Write PR descriptions (and any other text people will read, such as release notes)
in plain language: say what changed and why, keep every fact, commitment and
caveat, and skip filler. If you have the work-humanizer skill installed (MIT,
from phuryn/work-humanizer), run it on
the body before gh pr create / gh pr edit.
Keep the PR genre: ## Summary, a decision/notes section only when the reviewer
needs one, and ## Test plan.
Dependency & Upgrade Constraints
- Sanity 6.x: the
@sanity/ui@4/@sanity/icons@5removals are typednever, sotscpasses and onlynext buildfails. After any Sanity bump runpnpm ts:typegen,pnpm typecheckandpnpm build. @c15t/nextjs: consent UI lives only inweb/src/ui/cookie-consent/consent-manager.tsx(v3,offline()mode, no backend). Third-party tags (GTM) load through itsscripts, never as a separate snippet.pnpm-workspace.yamloverridespin patched transitive deps. Don't remove them.
Read docs/agents/dependency-constraints.md before touching these dependencies.
Architecture Overview
Route Groups (web/src/app/)
(frontend)/— Public-facing Next.js routes; catchall[[...slug]]/page.tsxhandles all CMS-driven pages(studio)/admin/— Embedded Sanity Studio at/admin(vianext-sanity/studio)api/— API routes:draft-mode/enable|disable,revalidate,revalidate-all,og,redirects,markdown(the/x.mdtwins, seedocs/guides/markdown-for-agents.md)
Type System (web/src/types/)
sanity.types.ts— Auto-generated; never edit manually. Runpnpm --filter @nexity/web ts:typegento regenerate.fragments.ts— Type aliases for reusable fragment types (ImageFragment,LinkFragment, etc.)sections.ts—ExtractSectionProps<"section-name">utility for section component typing
UI Layer (web/src/ui/)
components/— Reusable primitives:Image,BaseLink,Button,Icon, etc.sections/— One directory per section type; registered insections/index.tsxviaSECTION_MAP. Complex sections use modular file structure.header/,footer/,RichText/— Layout components
General Coding Conventions
Code design (applies to every change)
- The look comes from
DESIGN.md, the words fromBRAND.md. Any change a visitor sees (a new or restyled section, a token, font, spacing or colour change, new copy, a fixture) starts from them: tokens and visual rules fromDESIGN.md, copy, names and numbers fromBRAND.md. When a request conflicts with them, follow the file and raise the conflict; when the design itself changes, updateDESIGN.mdin the same change. - Search before you write. Before a new component, hook or helper, look for one that already does it:
web/src/ui/components/(Image, BaseLink, ButtonLink, Icon…),web/src/components/ui/(carousel, hover-card),web/src/lib/(hooks such asuseLoadOnIntent,useIsNearViewport;resolveUrl,cn),web/src/ui/listing/(paginated grids), then sibling sections.git grep -n "<concept>"takes seconds. Extend an existing piece (a prop, a variant) before copying it; two near-identical components drift apart. - Small, single-purpose files. One component per file, kebab-case; pure logic in
utils.ts, config inconstants.ts, types intypes.ts. A section that grows state or several visual parts gets split (web/AGENTS.md→ "Section Component Structure"). If a file needs a comment to explain where its parts begin, split it. - No comments that restate the code. Names and types say what code does. Comment only a workaround (a library, browser or platform quirk; link the issue or version), a non-obvious constraint that breaks something when ignored, or the place a project swaps a setting (e.g. the GTM ID). One or two lines; no section dividers, history or commented-out code.
- Server first, client at the leaves. Render on the server by default;
"use client"only for the interactive piece, loaded where it's needed. The rules and patterns are inweb/AGENTS.md→ "Client Code & Performance", andpnpm lintenforces the mechanical ones (pnpm check:client). - Performance claims are measured. Compare JS per page and main-thread work against
mainbefore calling a change an improvement (Lighthouse mobile, median of three runs), and put the numbers in the PR, including what didn't work. - A visual change refreshes the insert-menu tiles. Every section type has a tile in the Studio's "Add item…" grid,
web/public/admin/thumbnails/<type>.webp, a screenshot of its Sections Gallery fixture. After a new section, a restyle of a section, or a change toDESIGN.mdtokens, fonts orapp.cssthat every section picks up, recapture the affected tiles with thesanity-module-catalogskill (/sanity-module-catalog, ornode .agents/skills/sanity-module-catalog/scripts/capture.mjs --project=. --only=<type>withpnpm devrunning; drop--onlyafter a token change) and commit the.webpfiles with the change. A missing tile fails nothing: the menu just shows an icon nobody recognises. - A fixed mistake becomes a rule. When a bug or regression could happen again, add the rule where the next person will read it (this file,
web/AGENTS.md,studio/AGENTS.md) and, if it can be checked mechanically, a check (check:client, thesatisfiesregistries).
File Naming
All files use kebab-case: my-component.tsx, api-utils.ts. React components use .tsx, utilities use .ts.
Naming
- Never use shorthand variable names (
v,i,k,e) — always use descriptive words (cleanVariant,index,key,error) - Use
camelCasefor functions and variables - Use
SCREAMING_SNAKE_CASEfor constants - Use
PascalCasefor class/component names - Prefix event handlers with
handle(handleClick,handleSubmit) - Use descriptive names with auxiliary verbs (
isLoading,hasError)
TypeScript
- Prefer interfaces over types; avoid enums — use const maps instead
- Use
satisfiesoperator for type validation
HTML & Accessibility
- Keep HTML flat — implement
tabindex,aria-label, keyboard handlers and a visible focus state - Use
removerpx; avoid inline styles
Adding New Environment Variables
Add validation in web/src/setup/envVariables.ts whenever a new env var is introduced.
New Document Types (full workflow)
A new document type touches about ten places: schema, registration, Studio structure, presentation, route, sitemap, resolveUrl + link projections (when its URL isn't metadata.slug, or links render an empty href), structured data, Markdown + llms.txt, and docs/FEATURES.md.
Follow the checklist in docs/agents/new-document-type.md.
Listing Page Pattern (listing + detail pages)
A listing + detail feature (blog, case studies) always gets a dedicated route, never the catchall, and reuses the generic grid in web/src/ui/listing/ instead of copying a sibling's plumbing. The title and slug of every routed document live in metadata, never top-level. Publish the listing singleton before building, or the build fails with "Missing Site settings".
Follow the checklist and the content model conventions in docs/agents/new-document-type.md.
Global Sections Helper
Never copy the global-section GROQ: a route calls fetchGlobalSections(fullPath) ("/", "blog/my-post") in its Promise.all and renders before/after around its own content. Details: docs/agents/content-patterns.md.
Shared Sections
shared-section (document) holds inner sections; shared-section-ref (section) references it. INNER_SECTIONS vs SECTIONS in fragments/sections.ts keeps them from nesting; SECTIONS_QUERY reuses SECTION_BRANCHES_QUERY, never duplicated. Details: docs/agents/content-patterns.md.
Document-Backed Listing Section (reusable entities referenced by a section)
Items that are reusable entities (testimonials, team members) are documents, and the section holds an array of references to them, keyed by _id after ->. Inline objects only for content that belongs to one section instance. Details: docs/agents/content-patterns.md.
Creating a New Section (full workflow)
Read DESIGN.md (the look) and BRAND.md (the copy) first. Run the checklist in docs/agents/new-section.md top to bottom (the create-section skill does). Several misses fail silently:
- Register the type in
schemaTypes/index.tsandfragments/sections.ts, or it never appears in the insert menu. - Restart the Studio and the web dev server before editing a document that uses it; a stale Studio strips it on save.
- Gallery fixture, JSON-LD contributor and Markdown serializer:
pnpm typecheckfails until all three exist. - Capture the insert-menu tile and update
docs/FEATURES.md; nothing fails if you skip them.
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.

