.cursor/skills/turborepo/SKILL.md
Turborepo task configuration patterns for monorepo management. Use when configuring turbo.json tasks, setting up task dependencies, managing cache inputs/outputs, or working with cross-package dependencies in the monorepo.
npx skillsauth add firtoz/cf-multiworker-boilerplate turborepoInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Patterns and best practices for configuring Turborepo tasks and dependencies in this monorepo.
Use when:
turbo.json filesAlways run turbo commands from the workspace root.
# ✅ CORRECT - From workspace root
cd /workspace
bun run build # Turbo builds all packages in correct order
bun run typecheck # Turbo typechecks all packages
bun run lint # Turbo lints all packages
# ❌ WRONG - From subdirectory
cd /workspace/apps/web
bun run build # This bypasses turbo orchestration
Turbo automatically:
You don't need --cwd or --filter flags - turbo handles everything.
Bad:
// apps/web/turbo.json
"cf-typegen": {
"inputs": [
"wrangler.jsonc",
"$TURBO_ROOT$/packages/scripts/src/cf-typegen.ts" // ❌ Direct file reference
]
}
Good:
// apps/web/turbo.json
"cf-typegen": {
"dependsOn": ["scripts#build"], // ✅ Depends on package task
"inputs": [
"wrangler.jsonc" // ✅ Only this package's files
]
}
Why: If task B depends on task A, B should depend on A's outputs, not A's inputs. Turbo handles the transitive dependency chain automatically.
package#taskWhen a package needs files from another package to be ready:
Step 1: Source package defines a build task
// packages/scripts/package.json
{
"scripts": {
"build": "echo '✓ scripts package ready'" // Can be a no-op
}
}
// packages/scripts/turbo.json
{
"tasks": {
"build": {
"inputs": ["src/**/*.ts", "package.json"],
"outputs": []
}
}
}
Step 2: Consumer package depends on package#build
// apps/web/turbo.json
{
"tasks": {
"generate-wrangler": {
"dependsOn": ["scripts#build"], // ✅ Cross-package dependency
"inputs": ["wrangler.jsonc.hbs", "$TURBO_ROOT$/.env.local"]
}
}
}
Never do:
// ❌ DON'T reference other package's files directly
"inputs": ["$TURBO_ROOT$/packages/scripts/src/utils/file.ts"]
Tasks are defined in three places:
Root turbo.json - Global defaults and settings
Package turbo.json - Package-specific tasks
Package package.json - Actual scripts
Inputs - Files that affect the task output:
"inputs": [
"src/**/*.ts", // Source files
"package.json", // Dependencies
"tsconfig.json", // Configuration
"$TURBO_ROOT$/.env.local" // Root-level files (use sparingly)
]
Outputs - Files generated by the task:
"outputs": [
"dist/**/*", // Build artifacts
"*.d.ts", // Type definitions
".next/**", // Framework outputs
"!.next/cache/**" // Exclude from outputs
]
Rules:
[] means task always runs (but can still cache based on inputs)// Task that generates code from a template
"generate-config": {
"dependsOn": ["scripts#build"], // Wait for scripts to be ready
"inputs": [
"config.template.json", // Template file
"$TURBO_ROOT$/.env.local" // Environment variables
],
"outputs": ["config.json"] // Generated file
}
// Task that depends on generated files
"typegen": {
"dependsOn": ["generate-config"], // Wait for config generation
"inputs": [
"src/**/*.ts", // Source files
"config.json" // Generated config (from previous task)
],
"outputs": ["types/**/*.d.ts"]
}
"build": {
"dependsOn": ["^build", "typegen"], // ^build = dependencies' build first
"inputs": [
"src/**/*",
"public/**/*",
"package.json",
"tsconfig.json"
],
"outputs": ["dist/**/*", ".next/**", "!.next/cache/**"]
}
// package.json
{
"scripts": {
"build": "echo '✓ Package ready'" // Simple marker
}
}
// turbo.json
{
"tasks": {
"build": {
"inputs": ["src/**/*.ts"], // Files that must be ready
"outputs": [] // No actual build output
}
}
}
// Root turbo.json
{
"globalEnv": [
"NODE_ENV",
"CLOUDFLARE_API_TOKEN"
]
}
// Package turbo.json
{
"tasks": {
"deploy": {
"env": ["DEPLOY_ENV", "API_TOKEN"],
"cache": false // Don't cache tasks with secrets
}
}
}
"build": {
"inputs": ["src/**/*"],
"outputs": ["dist/**"]
// cache: true is default
}
"deploy": {
"cache": false, // Deployment has side effects
"dependsOn": ["build"]
}
"dev": {
"cache": false, // Dev server is persistent
"persistent": true
}
"task-c": {
"dependsOn": ["task-a", "task-b"] // Both must complete first
}
"build": {
"dependsOn": ["^build"] // Build all workspace dependencies first
}
"deploy": {
"dependsOn": [
"^build", // Dependencies' build
"build", // Own build
"scripts#pre-deploy" // Specific package task
]
}
"inputs": ["$TURBO_ROOT$/packages/utils/src/helper.ts"]
"dependsOn": ["utils#build"]
"inputs": ["**/*"] // Too broad, slows down hashing
"inputs": ["src/**/*.ts", "package.json", "tsconfig.json"]
"build": {
"inputs": ["src/**/*"]
// Missing outputs - turbo can't restore from cache
}
"build": {
"inputs": ["src/**/*"],
"outputs": ["dist/**"]
}
bun run build --graph
bun run build --dry-run
bun run build --summarize
bun run build --force
bun run build --verbose
globalDependencies, ui, task defaultsbuild, typecheck, typegen, cf-typegen, rr-typegen, dev, lint, pre-deploy, deploy, cleanglobalEnv: CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID, SESSION_SECRETpre-deploy - Pre-deployment validation (inputs: wrangler.jsonc, .env.local)typegen - Depends on cf-typegen, rr-typegencf-typegen - Cloudflare Worker types (worker-configuration.d.ts)rr-typegen - React Router route typeslint - Depends on typechecktypecheck - Depends on typegenbuild - Depends on typecheckdeploy - Depends on scripts#pre-deploy, build, example-do#deploy, coordinator-do#deploy, processor-do#deploydeploy and other tasks as needed.typegen → cf-typegen, rr-typegen
typecheck → typegen
lint → typecheck
build → typecheck
deploy → scripts#pre-deploy, build, example-do#deploy, coordinator-do#deploy, processor-do#deploy
development
Repo-root commands, typegen and typecheck cadence, lint, deploy, adding packages with bun, and Alchemy app layout. Use at the start of a task, before PR, or when choosing turbo/typegen commands.
development
Fork and template gotchas (env import, routes, typegen, forms, D1, Turbo, HMR, new DO packages). Use when working on apps/web or durable-objects, or when behavior diverges from this stack’s conventions.
testing
Turborepo task configuration patterns for monorepo management. Use when configuring turbo.json tasks, setting up task dependencies, managing cache inputs/outputs, or working with cross-package dependencies in the monorepo.
development
React Router v7 routing patterns and environment variable configuration. Use whenever you touch React Router–related code (routes, links, params, loaders, actions, route config, or env in route context).