Agent Skillssanity-io/sanity › sanity-default-plugins

sanity-default-plugins

GitHub

指导在 Sanity monorepo 中创建、配置和集成核心插件,包括使用 definePlugin 定义插件结构、添加本地化资源及在 resolveDefaultPlugins 中注册接线。

.agents/skills/sanity-default-plugins/SKILL.md sanity-io/sanity

Trigger Scenarios

添加新的 Sanity 核心插件 修改现有核心插件结构 在默认插件列表中注册新插件 为插件添加国际化资源

Install

npx skills add sanity-io/sanity --skill sanity-default-plugins -g -y
More Options

Non-standard path

npx skills add https://github.com/sanity-io/sanity/tree/main/.agents/skills/sanity-default-plugins -g -y

Use without installing

npx skills use sanity-io/sanity@sanity-default-plugins

指定 Agent (Claude Code)

npx skills add sanity-io/sanity --skill sanity-default-plugins -a claude-code -g -y

安装 repo 全部 skill

npx skills add sanity-io/sanity --all -g -y

预览 repo 内 skill

npx skills add sanity-io/sanity --list

SKILL.md

Frontmatter
{
    "name": "sanity-default-plugins",
    "description": "Create and wire Sanity core plugins using the monorepo's default plugin conventions. Use when adding, modifying, or reviewing plugins under packages\/sanity\/src\/core, especially plugins added through resolveDefaultPlugins or studio.components middleware."
}

Sanity Core Plugin

Start Here

Before adding a core plugin, read the sanity-plugin-authoring skill at ../sanity-plugin-authoring/SKILL.md to understand the general Sanity plugin API and what plugins can provide. Then inspect nearby plugins and these files:

  • packages/sanity/src/core/config/resolveDefaultPlugins.ts
  • packages/sanity/src/core/config/types.ts
  • packages/sanity/src/core/config/studio/types.ts
  • A similar plugin under packages/sanity/src/core/*/plugin/

The new plugin should be added inside core so it can be imported into the default plugins.

Prefer local patterns over new abstractions.

Plugin Shape

Use definePlugin and export a stable internal name constant:

import {definePlugin} from '../../config/definePlugin'

export const FEATURE_NAME = 'sanity/feature'

export const feature = definePlugin({
  name: FEATURE_NAME,
  studio: {
    components: {
      layout: FeatureStudioLayout,
    },
  },
  i18n: {
    bundles: [featureUsEnglishLocaleBundle],
  },
})

Use ../../config/definePlugin when matching existing internal plugin files. ../../config is also available in some folders.

Locale Resources

Default core plugins that render UI text should add a locale resource bundle. Follow the pattern from packages/sanity/src/core/singleDocRelease:

  • packages/sanity/src/core/<feature>/i18n/index.ts: exports the locale namespace, US English bundle, and resource key type.
  • packages/sanity/src/core/<feature>/i18n/resources.ts: exports default locale strings and keyof resource type.
  • packages/sanity/src/core/<feature>/plugin/index.ts: imports the bundle and registers it under i18n.bundles.

Example i18n/index.ts:

import {type LocaleResourceBundle} from '../../i18n'

export const featureNamespace: 'feature' = 'feature'

export const featureUsEnglishLocaleBundle: LocaleResourceBundle = {
  locale: 'en-US',
  namespace: featureNamespace,
  resources: () => import('./resources'),
}

export type {FeatureLocaleResourceKeys} from './resources'

Example i18n/resources.ts:

const featureLocaleStrings = {
  'action.example': 'Example',
}

export type FeatureLocaleResourceKeys = keyof typeof featureLocaleStrings

export default featureLocaleStrings

Example plugin registration:

import {featureUsEnglishLocaleBundle} from '../i18n'

export const feature = definePlugin({
  name: FEATURE_NAME,
  i18n: {
    bundles: [featureUsEnglishLocaleBundle],
  },
})

Default Plugin Wiring

Default core plugins are listed in resolveDefaultPlugins.ts.

  1. Import the plugin and its name constant.
  2. Add the plugin to defaultPlugins(options) in the desired composition order.
  3. If gated, add a plugin.name === FEATURE_NAME branch in getDefaultPlugins.
  4. Add any required options to DefaultPluginsWorkspaceOptions in types.ts.
  5. In getDefaultPluginsOptions, build default plugin options directly from workspace config defaults and spreads. Do not call config property reducers here; reducers belong to resolved source/workspace config, while default plugin options are a lightweight workspace-level input for plugin insertion.
  6. Update packages/sanity/src/core/config/__tests__/resolveConfig.test.ts with focused default plugin tests:
    • The plugin is not added by default.
    • The plugin is added when the proper config flag is enabled.
  7. Add ordering coverage when plugin order affects UI composition.

Example default option shape:

variants: {
  enabled: false,
  ...workspace.beta?.variants,
}

Remember: user plugins are appended before default plugins in prepareConfig.tsx, then the component middleware chain reverses flattened config order. Check the existing chain before relying on wrapper order.

Verification

For default plugin changes, run:

pnpm vitest run --project=sanity packages/sanity/src/core/config/__tests__/resolveConfig.test.ts

Also run lint/read diagnostics for edited files. Add component-level tests only when the plugin changes runtime rendering beyond insertion.

Version History

  • 3235fb3 Current 2026-08-20 10:56

Same Skill Collection

.agents/skills/code-review-and-quality/SKILL.md
.agents/skills/code-simplification/SKILL.md
.agents/skills/grill-me/SKILL.md
.agents/skills/improve-codebase-architecture/SKILL.md
.agents/skills/performance-optimization/SKILL.md
.agents/skills/playwright-cli/SKILL.md
.agents/skills/pr-description/SKILL.md
.agents/skills/rxjs-like-a-pro/SKILL.md
.agents/skills/sanity-config-reducers/SKILL.md
.agents/skills/sanity-plugin-authoring/SKILL.md
.agents/skills/sanity-visual-regression/SKILL.md
.agents/skills/tdd/SKILL.md
.agents/skills/vercel-react-best-practices/SKILL.md
.agents/skills/write-a-skill/SKILL.md
.agents/skills/find-skills/SKILL.md
.agents/skills/playwright-best-practices/SKILL.md

Metadata

Files
0
Version
3235fb3
Hash
fef97969
Indexed
2026-08-20 10:56

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-24 20:45
浙ICP备14020137号-1 $방문자$