test-studio-script-runner

작성자: sanity-io

dev/test-studio Script Runner 도구를 설명합니다. dev/test-studio/src/script-runner에서 스크립트를 추가, 편집, 실행 또는 문서화할 때 사용하거나...

npx skills add https://github.com/sanity-io/plugins --skill test-studio-script-runner

Test Studio Script Runner

Use this skill when working with the Scripts tool in dev/test-studio.

Key Files

  • Tool plugin: dev/test-studio/src/script-runner/index.tsx
  • Runner UI: dev/test-studio/src/script-runner/ScriptRunnerTool.tsx
  • Script registry: dev/test-studio/src/script-runner/registry.ts
  • Script contract: dev/test-studio/src/script-runner/types.ts
  • Script modules: dev/test-studio/src/script-runner/scripts/*/index.ts
  • Agent-facing docs: dev/test-studio/src/script-runner/README.md

Read README.md and types.ts before changing the runner or adding scripts.

What The Tool Does

The runner is a Sanity Studio custom tool registered in the home workspace.

  • Home route: <studio>/home/scripts
  • Script route: <studio>/home/scripts/<script-name>

Scripts are browser-side TypeScript modules discovered at build time with Vite import.meta.glob. They run inside Sanity Studio with the logged-in user's permissions and receive the Studio client.

Adding A Script

Add a folder under dev/test-studio/src/script-runner/scripts/. The folder name should match the script name. Put the registered entrypoint in index.ts; any helper files can live beside it.

scripts/
  my-script-name/
    index.ts
    helpers.ts

Only scripts/*/index.ts files are discovered at build time.

import type {StudioScript} from '../../types'

const script: StudioScript = {
  name: 'my-script-name',
  title: 'My script name',
  description: 'What this script does.',
  apiVersion: '2026-03-01',
  inputs: [
    {
      name: 'documentId',
      title: 'Document ID',
      defaultValue: 'example-id',
      required: true,
    },
  ],
  async run({client, inputs, log}) {
    log.info(`Running for ${inputs.documentId}`)
    await client.fetch('*[_type == "post"][0...1]')
    log.success('Done')
  },
}

export default script

Script names must be unique and use lowercase letters, numbers, and hyphens. Keep the folder name and script name aligned. The script name becomes the URL segment.

Runtime Contract

run() receives:

  • client: Sanity Studio client, configured with the script apiVersion or the runner default.
  • inputs: string values from the run screen, keyed by input name.
  • log: info, success, warning, and error methods that append output in the UI.
  • signal: an AbortSignal reserved for script code that supports cancellation.

String Variables

Use inputs for string variables. Each input renders as a text field on the script run screen. Required inputs disable the run button until non-empty.

Available input fields:

  • name
  • title
  • description
  • defaultValue
  • placeholder
  • required

All values passed to scripts are strings. Validate and trim values inside run() when needed.

Browser-Safe Rules

Script runner modules execute in the browser. Do not use:

  • fs, path, or other Node built-ins
  • process.exit
  • direct environment variable access
  • SANITY_AUTH_TOKEN

Do not create a separate Sanity client from env vars. Use the provided client.

If a task needs Node-only APIs or token-based CLI behavior, keep it in dev/test-studio/scripts/ instead of the Studio script runner.

Verification

After changing the runner or adding scripts, run:

pnpm lint
pnpm --filter test-studio build

If pnpm --filter test-studio build fails because workspace package dist output is missing, build with dependencies first:

pnpm --filter test-studio... build

sanity-io의 다른 스킬

performance-optimization
sanity-io
애플리케이션 성능을 최적화합니다. 성능 요구사항이 있거나, 성능 회귀가 의심되거나, Core Web Vitals 또는 로드 시간이…
official
rxjs-like-a-pro
sanity-io
이 스킬은 관용적이고 조합 가능하며 일반적인 함정이 없는 RxJS 코드를 작성하는 데 도움을 줍니다. 핵심 철학: 로직을 observable 체인 안에 유지하세요. .subscribe()를 사용할 때마다 해당 작업을 .pipe() 내부의 변환으로 표현할 수 있는지 물어보세요.
official
find-skills
sanity-io
사용자가 "X를 어떻게 하죠", "X를 위한 스킬을 찾아줘", "X를 할 수 있는 스킬이 있나요..." 같은 질문을 하거나 특정 요구를 표현할 때 에이전트 스킬을 찾고 설치하도록 도와줍니다.
official
next-cache-components
sanity-io
Next.js 16 캐시 컴포넌트 - PPR, use cache 지시어, cacheLife, cacheTag, updateTag
official
vercel-react-best-practices
sanity-io
Vercel Engineering의 React 및 Next.js 성능 최적화 가이드라인입니다. 이 스킬은 React/Next.js 코드를 작성, 검토 또는 리팩토링할 때 사용해야 합니다.
official
frontend-design
sanity-io
차별화된 프로덕션 수준의 프론트엔드 인터페이스를 높은 디자인 품질로 제작합니다. 사용자가 웹 컴포넌트, 페이지 등을 구축해 달라고 요청할 때 이 스킬을 사용하세요.
official
plugin-transfer
sanity-io
에이전트가 copy-plugin 생성기 워크플로를 사용하여 기존 플러그인을 이 모노레포로 마이그레이션하도록 안내합니다.
official
create-agent-with-sanity-context
sanity-io
Sanity Context를 통해 Sanity 콘텐츠에 구조화된 접근 권한을 가진 AI 에이전트를 구축합니다. Sanity 기반 챗봇을 설정하거나 AI 어시스턴트를 Sanity에 연결할 때 사용합니다…
official