sanity-plugin-best-practices
Skill by sanity-io
Gives coding conventions for building Sanity Studio plugins in the sanity-io/plugins monorepo. It covers styling with vanilla-extract, avoiding raw style tags, and avoiding forwardRef.
Install sanity-plugin-best-practices
Built from the published package, never by AI.
git clone --depth 1 https://github.com/sanity-io/plugins /tmp/plugins && mkdir -p ~/.claude/skills && cp -r /tmp/plugins/.agents/skills/sanity-plugin-best-practices ~/.claude/skills/sanity-plugin-best-practicesRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
Step-by-step: install sanity-plugin-best-practices in Claude Code
git clone --depth 1 https://github.com/sanity-io/plugins /tmp/plugins && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/plugins/.agents/skills/sanity-plugin-best-practices ~/.gemini/antigravity-cli/skills/sanity-plugin-best-practicesAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install sanity-plugin-best-practices in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
This agent skill sets conventions for writing Sanity Studio plugins in the sanity-io/plugins monorepo. It lists anti-patterns and preferred approaches, with Incorrect and Correct examples taken from existing plugins in the repo. The main rule is to use vanilla-extract for all plugin styling and never to render raw style tags.
The skill links to reference files on styling and refs. It says styled-components is legacy and should be migrated to vanilla-extract. It also says to use lodash-es instead of lodash and never to use forwardRef on React 19. It is meant for developers writing, reviewing, or refactoring plugin code under plugins/.
Written from the project's SKILL.md and checked against it.
What it can do
- vanilla-extract stylingUse style() for static styles and createVar() with assignInlineVars() for dynamic ones.
- Raw style tag ruleAvoid raw style tags, including via dangerouslySetInnerHTML or document.head.
- Component encapsulationWrap vanilla-extract classes in small components that spread props onto @sanity/ui primitives.
- styled-components migrationGuides moving legacy styled-components usage to vanilla-extract.
- Ref handlingDeclare ref as a regular prop on React 19 instead of using forwardRef.
- Theme tokensRead colors, spacing and fonts from the @sanity/ui theme with useTheme_v2().
- Lodash import ruleUse lodash-es, not lodash.
Try asking
- Review this plugin component for raw style tags and suggest vanilla-extract
- Migrate this styled-components file to vanilla-extract in my Sanity plugin
- Remove forwardRef from this plugin component and use ref as a prop
Good to know
- styled-components is legacy and kept only as a last-resort escape hatch.
- Migration should preserve visual fidelity and not happen during a transfer's initial port.
- The skill is intended to grow with more reference files.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: .agents/skills/sanity-plugin-best-practices/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Alternatives to sanity-plugin-best-practices
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
sanity-plugin-best-practices: common questions
Should I use styled-components in a new Sanity plugin?
No. The source says styled-components is legacy and should not be added for ordinary styling. Its only sanctioned use is last-resort CSS-in-JS for arbitrary runtime CSS.
How should plugins handle refs on React 19?
Declare ref in props as Ref<T> and use it directly. The lint config bans the forwardRef import.
Why avoid raw style tags in plugins?
The source says they re-parse on every render, duplicate per instance, bypass the theme, and are an injection risk.
How do I install sanity-plugin-best-practices?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is sanity-plugin-best-practices free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is sanity-plugin-best-practices safe to use?
It scores 55 of 100. Grades: maintenance A, licence A, quality C. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to sanity-plugin-best-practices?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
