agentleFS
VercelKnown publishervercel/examples/starter/cms-sanity-graphql-fragments/CLAUDE.md

examples / cms-sanity-graphql-fragments

CLAUDE.md5.2k starsChanged 10 months agoMITView on GitHub

Trending

Quiet this year.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the vercel/examples repository that our weekly crawl found: only 6 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about vercel/examples

The biggest 5 of 6 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 6

The file

Show its rules and text

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

16 rules. About 0 are common, 3 are distinctive, and 13 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 13

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No test command configured: - check with user if tests are needed

    line 11
  2. Very specific:

    Component Files: Use kebab-case for component filenames (e.g., my-component.tsx)

    line 18
  3. Distinctive:

    Error Handling: Use TypeScript strict mode, handle async errors properly

    line 20
  4. Very specific:

    Use next/image for images, next/font for fonts

    line 31
  5. Very specific:

    Use className prop for styling

    line 33
  6. Very specific:

    Client Setup: Use createGraphQLClient() from @/lib/graphql

    line 38
  7. Very specific:

    Error Handling: Always check for error object and provide user-friendly error UI

    line 54
  8. Very specific:

    ISR: Use export const revalidate = 60 for Incremental Static Regeneration

    line 55
  9. Very specific:

    Update types: Run npm run schema:generate to regenerate TypeScript types

    line 60
  10. Very specific:

    Import types: Use generated types from @/lib/graphql for type safety

    line 62
  11. Very specific:

    Fragment files: Use -fragment.ts suffix (e.g., nav-link-fragment.ts)

    line 69
  12. Very specific:

    When a component needs "use client" directive:

    line 72
  13. Very specific:

    Development: Use npm run sanity:dev to start Sanity Studio

    line 129
  14. Very specific:

    Schema Changes: After modifying src/lib/schema.ts, deploy with npm run sanity:deploy

    line 130
  15. Very specific:

    Type Generation: Run npm run schema:generate to update GraphQL types

    line 131
  16. Distinctive:

    Content Creation: Use Sanity Studio to create and manage content

    line 132

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.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
CLAUDE.md

Agent Guidelines for cms-graphql-fragments

Commands

  • Build: npm run build (uses Next.js with Turbopack)
  • Dev: npm run dev (development server with Turbopack)
  • Lint: npm run lint (Biome linter)
  • Format: npm run format (Biome formatter)
  • Sanity Studio: npm run sanity:dev (start Sanity Studio development server)
  • Deploy GraphQL: npm run sanity:deploy (deploy GraphQL API to Sanity)
  • Generate Types: npm run schema:generate (generate GraphQL types from Sanity schema)
  • No test command configured - check with user if tests are needed

Code Style

  • Formatter: Biome with 2-space indentation
  • Imports: Auto-organized by Biome, use @/* for src imports
  • Types: Strict TypeScript, explicit types for props/exports
  • Naming: camelCase for variables/functions, PascalCase for components
  • Component Files: Use kebab-case for component filenames (e.g., my-component.tsx)
  • Components: Function declarations with explicit return types when complex
  • Error Handling: Use TypeScript strict mode, handle async errors properly

Biome Configuration

  • Import Organization: Automatically enabled on save/format
  • Domain Rules: Next.js and React recommended rules enabled
  • Ignored Files: node_modules, .next, dist, build, .sanity, lib/generated
  • VCS Integration: Git integration enabled with ignore file support

Framework Specifics

  • Next.js 15 App Router with React 19
  • Tailwind CSS for styling
  • Use next/image for images, next/font for fonts
  • Export metadata objects for SEO
  • Use className prop for styling

GraphQL & Data Fetching

  • Client: URQL with @urql/next/rsc for React Server Components
  • Type Safety: gql.tada with GraphQL introspection from src/lib/generated/graphql-env
  • Client Setup: Use createGraphQLClient() from @/lib/graphql
  • Query Pattern:
    import { registerUrql } from "@urql/next/rsc";
    import { createGraphQLClient, graphql } from "@/lib/graphql";
    
    const { getClient } = registerUrql(createGraphQLClient);
    
    const QUERY = graphql(`
      query QueryName($param: String!) {
        field
      }
    `);
    
    const { data, error } = await getClient().query(QUERY, { param: "value" });
  • Error Handling: Always check for error object and provide user-friendly error UI
  • ISR: Use export const revalidate = 60 for Incremental Static Regeneration
  • Scalars: DateTime, Date (string), JSON (TypedObject from Sanity)

Schema Generation Workflow

  1. After Sanity schema changes: Deploy GraphQL API with npm run sanity:deploy
  2. Update types: Run npm run schema:generate to regenerate TypeScript types
  3. Generated files: Types are created in src/lib/generated/ (auto-ignored by Biome)
  4. Import types: Use generated types from @/lib/graphql for type safety

GraphQL Fragment Colocation

Fragment Definition Rules

  • Server Components: Define fragments directly in component files
  • Client Components: Define fragments in separate .ts files to avoid client/server boundary issues
  • Fragment files: Use -fragment.ts suffix (e.g., nav-link-fragment.ts)

Client Component Pattern

When a component needs "use client" directive:

  1. Fragment Definition (component-fragment.ts):
    import { graphql } from "@/lib/graphql";
    
    export const componentFragment = graphql(`
      fragment ComponentName on Type {
        field1
        field2
      }
    `);
  2. Client Component (component.tsx):
    "use client";
    
    import { type FragmentOf } from "@/lib/graphql";
    import type { componentFragment } from "./component-fragment";
    
    interface Props {
      data: FragmentOf<typeof componentFragment>;
    }
    
    export function Component({ data }: Props) {
      // Client-side logic (hooks, event handlers, etc.)
    }
  3. Parent Server Component:
    import { componentFragment } from "./component-fragment";
    import { Component } from "./component";
    
    const parentFragment = graphql(`...`, [componentFragment]);

Why This Pattern?

  • Prevents Runtime Errors: Avoids "f.definitions is not iterable" errors
  • Maintains Colocation: Fragments stay close to components that use them
  • Respects Boundaries: Separates server-side GraphQL logic from client-side interactivity
  • Type Safety: Components get proper TypeScript types via FragmentOf<typeof {GraphQL Fragment}>

Sanity CMS Integration

Available Schema Types

The project includes comprehensive Sanity schemas defined in src/lib/schema.ts:

  • Post: Blog posts with title, slug, excerpt, content, publishedAt
  • Page: Static pages with title, slug, excerpt, content, SEO settings, published status
  • Navigation: Site navigation with title and navigation items (label, href, isExternal)
  • Footer: Footer configuration with title, description, links, social links, copyright
  • SEO: SEO settings object with metaTitle and metaDescription
  • Social Links: Platform-specific social media links (Twitter, GitHub, LinkedIn, etc.)

Content Management Workflow

  1. Development: Use npm run sanity:dev to start Sanity Studio
  2. Schema Changes: After modifying src/lib/schema.ts, deploy with npm run sanity:deploy
  3. Type Generation: Run npm run schema:generate to update GraphQL types
  4. Content Creation: Use Sanity Studio to create and manage content
  5. ISR: Content changes trigger revalidation automatically (only available on deployed project)

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.