Agent Native

test-studio-script-runner

This skill documents the Scripts tool in Sanity Studio's test environment, allowing agents to add, edit, and run browser-side TypeScript scripts within the…

by SanityOfficial publisherNot reviewed

Identity proven by GitHub's verified organisation badge (sanity-io)

Agents
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
License
MIT (permissive)
Pin
a80a997pinned Oct 9, 2026
Context cost
about 880 tokenswhen the skill loads
GitHub stars
20on sanity-io/plugins
Scripts
None found

What it does

“Explains the dev/test-studio Script Runner tool. Use when adding, editing, running, or documenting scripts in dev/test-studio/src/script-runner, or when the user mentions the Scripts tool, Studio runner scripts, script variables, or browser-side Sanity Studio scripts.”
The author's description, from SKILL.md

Generated summary from the skill's own text

This skill documents the Scripts tool in Sanity Studio's test environment, allowing agents to add, edit, and run browser-side TypeScript scripts within the Studio interface. Scripts execute with the logged-in user's permissions using the provided Studio client and can accept string inputs through a UI form.

When to use it

  • Adding new scripts to the test Studio environment
  • Editing existing script runner tool components or configuration
  • Running scripts that need Studio client access with user permissions
  • Creating scripts that accept variable inputs through the UI

When not to

  • Tasks requiring Node.js built-ins like fs or process module
  • Scripts needing environment variable or token-based authentication
  • Operations that must run outside the browser environment

Install

These commands install from the publisher's repository and need no account.

skills CLI

npx skills add sanity-io/plugins --skill test-studio-script-runner

Installs from the repository's default branch, which may have changed since the commit we checked.

GitHub CLI 2.90 or later

gh skill install sanity-io/plugins test-studio-script-runner@a80a997e3d11d188f9639ac3efab1d8f93a276ef

Installs the commit we checked (a80a997).

Copy by hand

Download the folder at a80a997 and put it in .claude/skills/test-studio-script-runner for Claude Code and in .agents/skills/test-studio-script-runner for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.

Skill folder on GitHub at a80a997

Claude Code plugin

/plugin install sanity@claude-plugins-official

The publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.

Copy for your agent

A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.

Prompt

Install the agent skill "test-studio-script-runner" by Sanity.

Source, pinned to commit a80a997e3d11d188f9639ac3efab1d8f93a276ef:
https://github.com/sanity-io/plugins/tree/a80a997e3d11d188f9639ac3efab1d8f93a276ef/.agents/skills/test-studio-script-runner

1. Download that folder at exactly this commit. Do not use the default branch.
2. Copy every file unchanged, keeping the folder structure, into .claude/skills/test-studio-script-runner/ for Claude Code and .agents/skills/test-studio-script-runner/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist.
3. Do not edit the files, and do not run any script in the folder unless I ask you to.
4. When you are done, list the files you copied and where you put them.

Listing and checks: https://www.agentnative.dev/skills/sanity/test-studio-script-runner

SKILL.md at the pin

---
name: test-studio-script-runner
description: Explains the dev/test-studio Script Runner tool. Use when adding, editing, running, or documenting scripts in dev/test-studio/src/script-runner, or when the user mentions the Scripts tool, Studio runner scripts, script variables, or browser-side Sanity Studio scripts.
---

# 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.

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

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

```ts
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:

```bash
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:

```bash
pnpm --filter test-studio... build
```

From sanity-io/plugins at a80a997, shown as plain text under its license: MIT (permissive). The license text is in LICENSE.

View SKILL.md on GitHub at a80a997

Files

1 file, 3.8 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.

Skill folder on GitHub at a80a997
All 24 skills from Sanity

More from Sanity

  • sanity-live-cache-components

    Integrates Sanity Live with Next.js Cache Components in next-sanity v13+ apps, setting up shared cached data fetching through sanityFetch, live content…

    Claude Code, Codex, Cursor +4 · about 4K tokens · pinned 6 days ago

  • content-experimentation-best-practices

    This skill provides guidance for designing and running content experiments using A/B and multivariate testing.

    Claude Code, Codex, Cursor +4 · about 360 tokens · pinned 6 days ago

  • content-modeling-best-practices

    Guides agents through structured content modeling principles for headless CMSes like Sanity, covering schema design, content reuse strategies, and field…

    Claude Code, Codex, Cursor +4 · about 340 tokens · pinned 6 days ago

  • portable-text-conversion

    Converts HTML and Markdown content into Portable Text blocks for Sanity using markdownToPortableText, htmlToBlocks, or manual construction.

    Claude Code, Codex, Cursor +4 · about 510 tokens · pinned 6 days ago

  • portable-text-serialization

    This skill enables rendering Portable Text content across multiple frameworks and output formats using the @portabletext library family.

    Claude Code, Codex, Cursor +4 · about 940 tokens · pinned 6 days ago

  • sanity-best-practices

    This skill provides best practices for Sanity headless CMS development across schema design, GROQ queries, framework integrations (Next.js, Nuxt, Astro…

    Claude Code, Codex, Cursor +4 · about 1.1K tokens · pinned 6 days ago

All Coding workflow skills
  • planning

    This skill orchestrates multi-workflow projects with dependencies and shared data tables by creating a task graph in the orchestrator via the create-tasks tool.

    by n8nOfficial publisher

    Claude Code, Codex, Cursor +3 · about 2.4K tokens · pinned 6 days ago

  • progressive-building

    This skill implements incremental workflow development for agents building or extending workflows.

    by n8nOfficial publisher

    Claude Code, Codex, Cursor +3 · about 1.4K tokens · pinned 6 days ago

  • workflow-builder

    Builds and edits n8n workflows using the TypeScript SDK.

    by n8nOfficial publisher

    Claude Code, Codex, Cursor +3 · about 14.2K tokens · pinned 6 days ago

  • remotion-upgrade

    This skill upgrades Remotion and its related packages to the latest stable version.

    by RemotionOfficial publisher

    Claude Code, Codex, Cursor +3 · about 460 tokens · pinned 6 days ago

  • remotion-upgrade

    This skill upgrades Remotion and related packages across a project, automatically detecting the package manager and workspaces.

    by RemotionOfficial publisher

    Claude Code, Codex, Cursor +3 · about 460 tokens · pinned 6 days ago

  • final-release-review

    Audits Python SDK release candidates or plans against the previous release, comparing diffs for regressions, API changes, and version compatibility.

    by OpenAIOfficial publisher

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 5.4K tokens · pinned 6 days ago

The skills listed here are third-party software, collected from public GitHub repositories as a catalog of recent skills and provided as is. Agent Native does not write or control them and is not responsible for any harm, loss or damage caused by installing or using them. Labels and checks describe what we saw at one commit and are not a guarantee. Read a skill's files before you run it. Terms of use