
Adding a new content module to a Sanity + Next.js project involves a surprising number of touch points. You need a schema file, a registration in the schema index, an entry in the modules fragment, potentially a GROQ query update, a frontend component, and a registration in the component map. Miss one step and nothing breaks loudly: the module just silently doesn't appear, or renders without its data, or throws a TypeScript error after typegen.
The pattern is consistent enough that it's a perfect candidate for automation. With Claude Code's slash commands, you can encode the entire workflow as a project-local skill and scaffold a new module with a single command.
What Claude Code skills are#
Claude Code supports a .claude/commands/ directory in your project root. Any markdown file you drop in there becomes a /command-name you can invoke from the Claude Code CLI: a reusable skill that Claude can execute on demand. The file's contents are the prompt, and you can use $ARGUMENTS to pass in a dynamic value at call time.
So a skill at .claude/commands/new-module.md becomes /new-module, callable as:
/new-module <module name>The $ARGUMENTS placeholder gets replaced with hero-banner, and Claude works through the skill's instructions top to bottom.
The /new-module skill β¨#
The skill itself is a step-by-step specification. Rather than a vague "create a Sanity module", it walks through each file that needs to change, in order, with code templates and explicit notes about edge cases.
The seven steps it covers:
- Create the schema file: generates
src/sanity/schemaTypes/modules/<module-name>.tswith the correctdefineTypestructure, groups (content,options, optionallyasset), the requiredmodule-attributesfield, and a sensiblepreviewimplementation usinggetBlockTextandcount. - Register the schema: adds the import and the entry to
src/sanity/schemaTypes/index.ts, in alphabetical order. - Add to the module fragment: inserts the
{ type: 'my-module' }entry into theofarray insrc/sanity/schemaTypes/fragments/modules.ts. - Update the GROQ query: only if the module has nested CTAs with links, references, or other joins. The skill explicitly tells Claude to skip this step for simple scalar/block-only modules, which avoids unnecessary query bloat.
- Run typegen: executes
npm run typegento regeneratesrc/sanity/types.tsand export the new type in PascalCase. - Create the frontend component: but first, Claude pauses and asks whether the module needs client-side interactivity. The answer determines the file layout: a single
src/ui/modules/<module-name>.tsxfor pure RSC, or asrc/ui/modules/<module-name>/index.tsxsubdirectory layout when a siblingclient.tsxwill be needed later. - Register the component: adds the import and the
'my-module': MyModuleentry tosrc/ui/modules/index.tsx.
The skill also includes a verification checklist at the end: typegen clean, TypeScript clean, module visible in Studio, component renders in preview.
Using the skill#
Drop the markdown file into .claude/commands/new-module.md, then from Claude Code:
/new-module resource-listYou'll get:
src/sanity/schemaTypes/modules/resource-list.tsβ ready to extend with your fields- Updated
index.tsandmodules.tsregistrations ResourceListexported from typegen- A frontend component stub with
moduleAttributes,PortableText, and the right prop types already wired up
From there you fill in the actual fields and layout. The scaffolding work β the part that's identical every time and easy to get slightly wrong β is already done.

Running the /new-module skill in Claude Code to generate a "resource-list" module
The broader pattern#
What makes this skill useful beyond the specific command is the structure: a prompt that encodes your project's conventions, handles branching decisions explicitly, and leaves the creative work to you. The module schema and component still need real design thinking. The seven-file shuffle does not.
Any workflow in your project that has this shape β consistent steps, clear conventions, low-variance boilerplate β is worth encoding as a skill. New API route, new Sanity document type, new test file: the same idea applies.
Skills live in .claude/commands/ as plain markdown files. That's the whole system.
Start building with SanityPress#
The /new-module skill ships with SanityPress β a production-ready starter built on Sanity, Next.js, and Tailwind. If you want a foundation where this kind of workflow is already set up and the conventions are already decided, it's a good place to start.
Build your next module, your next page, your next website. Get started with SanityPress today.


