Create or update TypeScript scripts for Script Kit. Use when the user wants to write a new script, edit an existing script, or understand Script Kit's SDK and metadata system.
Create or update TypeScript scripts for Script Kit. Use when the user wants to write a new script, edit an existing script, or understand Script Kit's SDK and metadata system.
New Script
Create and manage TypeScript scripts for Script Kit.
Where Scripts Live
~/.scriptkit/plugins/main/scripts/*.ts
Scripts are automatically discovered by Script Kit when saved to this directory.
Creating a New Script
Create a .ts file in ~/.scriptkit/plugins/main/scripts/
Add the SDK import and metadata export
Save — Script Kit detects it immediately
Minimal Template
import"@scriptkit/sdk";
exportconst metadata = {
name: "My Script",
description: "What this script does",
};
// Your code here
import"@scriptkit/sdk";
exportconst metadata = {
name: "New Blog Post",
description: "Scaffold a new blog post",
};
const [title, category] = awaitfields([
{ name: "title", label: "Post Title" },
{ name: "category", label: "Category" },
]);
const slug = title.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
const date = newDate().toISOString().split("T")[0];
const content = `---
title: ${title}
date: ${date}
category: ${category}
---
# ${title}
Write your post here.
`;
const filePath = home("blog", "posts", `${slug}.md`);
awaitBun.write(filePath, content);
hud(`Created: ${filePath}`);
Verification
When you create or edit a script from the Tab AI harness, writing the file is not enough. You must verify the actual script inside the current Claude Code terminal session before you report success.
Required loop for every script:
Save the script to ~/.scriptkit/plugins/main/scripts/<name>.ts
If the script normally uses UI or typed input (arg, div, editor, fields, etc.), add a non-interactive smoke path behind process.env.SK_VERIFY === "1"
Syntax-check / transpile it with Bun:
bun build ~/.scriptkit/plugins/main/scripts/<name>.ts --target=bun --outfile ~/.scriptkit/tmp/test-scripts/<name>.verify.mjs
Execute it with Bun:
SK_VERIFY=1 bun ~/.scriptkit/plugins/main/scripts/<name>.ts
Confirm the stdout, written file, or other observable result matches the request
If either command fails, fix the script and rerun both commands
Never report success until both commands pass and the observed behavior is correct
Only after both commands pass, end your final response with exactly:
Do not emit SCRIPT_READY before both commands pass.
Verification-Friendly Pattern
Use this when the real script flow is interactive but the harness still needs a terminal-only execution path:
import"@scriptkit/sdk";
exportconst metadata = {
name: "My Script",
description: "What it does",
};
const isVerify = process.env.SK_VERIFY === "1";
const value = isVerify
? "verification input"
: awaitarg("What should this script do?");
const output = `Result: ${value}`;
if (isVerify) {
console.log(JSON.stringify({ ok: true, output }));
} else {
awaitdiv(`<div class="p-8 text-2xl">${output}</div>`);
}
For UI-heavy requests, the Bun gate is still mandatory. If you also want to manually open Script Kit afterward, do that after the Bun gate — not instead of it.
Prompt Sequencing
Script Kit prompt APIs are stateful interactive surfaces. Never call them concurrently.
Do not use Promise.all, Promise.race, Promise.any, or Promise.allSettled with arg, fields, editor, div, form, drop, find, path, textarea, select, or grid