# Sanity Typegen

> Troubleshoot and setup Sanity TypeGen configuration. Use when types are missing or incorrect.

- Skill: `majiayu000/sanity-typegen` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add majiayu000/sanity-typegen`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/sanity-typegen/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/sanity-typegen

---


# TypeGen Setup & Fixer

This skill ensures TypeScript types are generating correctly for the Content Lake.

## Procedure

1.  **Check Configuration**
    * Check if `sanity-typegen.json` exists.
    * If missing, ask: "Do you want me to set up Sanity TypeGen?"
    * If yes, create the file based on `sanity://rules/sanity-typegen.mdc`.

2.  **Check Scripts**
    * Read `package.json`.
    * Ensure a `typegen` script exists: `"sanity schema extract && sanity typegen generate"`.
    * If missing, add it.

3.  **Run & Verify**
    * Run `npm run typegen`.
    * If it fails, read the error log and fix the `sanity-typegen.json` paths (often the `path` glob is incorrect for the project structure).
    * If successful, confirm that `sanity.types.ts` (or configured output) was updated.

