Turbo Scripts turbo-scripts
Conventions for package.json scripts and turbo.jsonc tasks in the monorepo.
Use it when adding, changing or reviewing scripts in any apps/* or packages/* package.json, any turbo.jsonc (root or per-package), pre/post hooks, script chains (&&, run-p), maybe-turbo, or turbo task inputs, outputs, env and caching. Includes an audit script that flags scripts that should use maybe-turbo.
- Our test
- —
- not tested yet
- GitHub stars
- 116k
- supabase/supabase
- Added by
- 0
- members
- Updated
- Dec 6
- commit 9140cc7
- Content
- 2 files
- 1 script · 9 KB
- License
- Apache 2.0
- free to use
What our test found
Not tested yet. Our model tries every skill on a realistic request and scores the result, the most popular skills first. Until then, the safety checks on the right still apply.
name: turbo-scripts description: Conventions for package.json scripts and turbo.jsonc tasks in the monorepo. Use when adding, changing or reviewing scripts in any apps/* or packages/* package.json, any turbo.jsonc (root or per-package), pre/post hooks, script chains (&&, run-p), maybe-turbo, or turbo task inputs, outputs, env and caching. Includes an audit script that flags scripts that should use maybe-turbo.
Turbo scripts
Task ordering belongs in turbo.jsonc (dependsOn), not in package.json. pnpm pre/post hooks and &&/run-p chains hide steps from turbo, so it can't cache or parallelize them, and running the script through turbo can run them twice. apps/docs is the reference implementation.
Audit first
Run the audit for every package you touch, before and after your change:
node .agents/skills/turbo-scripts/scripts/audit.mjs apps/docsIt lists each turbo task the package can run (its own turbo.jsonc plus the root's) and reports:
NEEDS maybe-turbo: the task has same-packagedependsOnentries, but the script isn't wrapped.pre/post hooks to migrate:pre<name>/post<name>scripts.preinstallis ignored.scripts that call other scripts: chains such aspnpm a && pnpm borrun-p a b. An alias that calls a single script with extra args or env (pnpm run embeddings --refresh) isn't reported.maybe-turbo scripts with no turbo task:turbo runfails for these withCould not find task.
Fix every finding in the package you're changing, or tell the user why one stays.
Rules
Ordering
- Express ordering as
dependsOnin the package'sturbo.jsonc. Remove the hook or chain it replaces. - Wrap a script with
maybe-turbo(frompackages/maybe-turbo; add"maybe-turbo": "workspace:*"todevDependencies) when its task has same-packagedependsOnentries. Outside turbo,pnpm <script>then runsturbo run <script> --filter=<package>, so prerequisites still run. Leaf scripts with no dependencies don't need it. - Don't split a task into a
turbo run <name>-innerscript plus an inner script. Usemaybe-turbo, so each task has one script name for callers andturbo.jsonc. - Put compound commands in one quoted argument:
"typecheck": "maybe-turbo \"next typegen && tsc --noEmit\"".maybe-turboexits with an error if&&,||,;or|appears outside the quotes. - A task that only groups other tasks gets a bare
"<name>": "maybe-turbo"script, sopnpm <name>still works. - Every wrapped script needs a task in
turbo.jsonc(the package's or the root's). - When you override
dependsOnfor a root task such asbuildortypecheck, keep^build/^typecheck. - Persistent sidecars that must run next to
dev(for examplevelite dev) go in the task'swithkey, notrun-p.
Caching
- Declare
outputsfor every cacheable task that writes files. If two tasks write into the same directory, list only each task's own files. - Mark tasks that fetch remote content or check local state as
"cache": false. - Default
inputsskip gitignored files, and plain globs are hashed whenturbostarts, before any task runs. A task that reads gitignored files written by an uncached task must list them injitmode, or a cache hit can restore output built from stale content:
"inputs": ["$TURBO_DEFAULT$", { "mode": "jit", "globs": ["content/guides/**"] }]- Keep generated output deterministic (sorted keys, stable order). A tracked file that a task rewrites differently on every run invalidates the whole package's cache.
Env
- Turbo runs tasks in strict env mode, which drops undeclared variables. Declare every variable the task reads:
envfor values that change the output,passThroughEnvfor secrets and credentials that don't. - Check what the script and the modules it imports read (
git grep "process.env"), including shared packages.
Side effects
- On a cache hit, turbo restores outputs without running the script. Keep uploads, deploys and database writes in uncached tasks or outside turbo (for example in a
vercel.jsonbuildCommandafterpnpm build).
Callers
- Find everything that runs the scripts you change:
.github/workflows,vercel.json, rootpackage.json, other apps' scripts,e2e/*, and docs/READMEs. A plainpnpm <script>keeps working once the script is wrapped withmaybe-turbo. - A wrapped script called from inside another turbo task sees
TURBO_HASHand runs without its prerequisites. Declare the dependency inturbo.jsoncinstead of calling the script from another script.
Verify
- Run the audit again.
- Check the graph:
pnpm turbo run <task> --filter=<package> --dry=json. - Run the entry point the way callers do, for example
pnpm buildin the package, then run it again and confirm the second run hits the cache. Tasks that usejitinputs reporthash: nullin--dry=json; that's expected.