| name | turborepo-monorepo |
| description | Turborepo monorepo structure and pnpm workspace conventions. Use when adding packages, configuring build pipelines, managing dependencies, running scripts, or working with the monorepo root config. Triggers on tasks involving workspace setup, package management, turbo.json, pnpm-workspace.yaml, or cross-package dependencies. |
| frameworks | ["turborepo"] |
| languages | ["typescript"] |
| category | tooling |
| updated | "2026-03-06T00:00:00.000Z" |
Turborepo Monorepo Skill
Quick Reference
When to Use: Adding workspace packages, configuring build pipelines, managing dependencies, or cross-package operations
Package Manager: pnpm 10.27+ (NEVER use npm or yarn)
Runtime: Node.js ≥22.20.0
Workspace Structure
turbo-template/
├── apps/
│ ├── web/ # Next.js 16 frontend (port 3001)
│ ├── backend/ # NestJS API server (port 3000)
│ └── mobile/ # Flutter mobile app
├── packages/
│ ├── auth/ # @repo/auth — Better Auth config
│ ├── db/ # @repo/db — Drizzle schema + client
│ └── contracts/ # @repo/contracts — oRPC contracts + Zod schemas
├── tooling/
│ ├── eslint/ # @repo/eslint-config — ESLint configs
│ ├── prettier/ # @repo/prettier-config — Prettier config
│ └── typescript/ # @repo/typescript-config — TSConfig bases
├── turbo.json # Task pipeline configuration
├── pnpm-workspace.yaml # Workspace definition + catalogs
└── package.json # Root scripts
pnpm Workspace Config
packages:
- apps/*
- packages/*
- tooling/*
catalog:
"@orpc/contract": ^1.13.4
"@tanstack/react-query": ^5.90.16
better-auth: 1.4.12
drizzle-orm: 1.0.0-beta.9
next: 16.1.1
react: 19.2.3
tailwindcss: ^4.1.18
typescript: ^5.9.3
zod: ^4.3.5
Common Scripts
Development
pnpm dev
pnpm dev:web
pnpm dev:backend
pnpm dev:mobile
Build & Quality
pnpm build
pnpm lint
pnpm lint:fix
pnpm format
pnpm format:fix
pnpm typecheck
pnpm lint:ws
Database
pnpm db:push
pnpm db:generate
pnpm db:migrate
pnpm db:studio
Auth
pnpm auth:generate
Turbo Pipeline Configuration
{
"tasks": {
"build": {
"dependsOn": ["^build", "^lint", "^typecheck"],
"outputs": [".cache/tsbuildinfo.json", "dist/**"],
"cache": true
},
"dev": { "cache": false, "persistent": false },
"lint": {
"dependsOn": ["^topo", "^build"],
"outputs": [".cache/.eslintcache"],
"cache": true
},
"typecheck": {
"dependsOn": ["^topo", "^build"],
"outputs": [".cache/tsbuildinfo.json"],
"cache": true
}
},
"globalPassThroughEnv": ["NODE_ENV", "CI", "VERCEL", "VERCEL_ENV", "VERCEL_URL"]
}
Key points:
^build = build dependencies first (topological)
build depends on ^lint + ^typecheck for quality gate
dev is not cached (live reload)
globalPassThroughEnv passes env vars to all tasks
Package Cross-References
Importing Workspace Packages
{
"dependencies": {
"@repo/auth": "workspace:*",
"@repo/contracts": "workspace:*",
"@repo/db": "workspace:*"
}
}
import { auth } from "@repo/auth"
import { v1Contract } from "@repo/contracts"
import { createDBClient } from "@repo/db/client"
import { todos, users } from "@repo/db/schema"
Package with Sub-Path Exports
{
"name": "@repo/db",
"exports": {
"./schema": { "types": "./dist/schema.d.ts", "default": "./dist/schema.js" },
"./client": { "types": "./dist/client.d.ts", "default": "./dist/client.js" }
}
}
Next.js transpilePackages
const config: NextConfig = {
transpilePackages: [
"@repo/auth", "@repo/contracts", "@repo/db",
"@t3-oss/env-core", "@t3-oss/env-nextjs",
],
}
Creating a New Package
-
Create directory structure:
packages/[name]/
├── src/index.ts
├── package.json
└── tsconfig.json
-
Package manifest:
{
"name": "@repo/[name]",
"version": "0.0.0",
"private": true,
"type": "module",
"exports": { ".": "./src/index.ts" },
"scripts": { "build": "tsc", "dev": "tsc --watch" }
}
-
TypeScript config:
{ "extends": "@repo/typescript-config/pkg.json", "include": ["src"], "exclude": ["node_modules"] }
-
Add to consumers:
{ "dependencies": { "@repo/[name]": "workspace:*" } }
-
Run pnpm install to link the new package.
Tooling Config Sharing
ESLint
import nestConfig from "@repo/eslint-config/nest.mjs"
export default [...nestConfig]
TypeScript
{ "extends": "@repo/typescript-config/next.json" }
Prettier
{ "prettier": "@repo/prettier-config" }
Key Rules
- Always use
pnpm — never npm or yarn
- Use
workspace:* for internal package dependencies
- Use pnpm catalog for shared version pinning
- Packages MUST have
index.ts — exception to no-barrel-files rule
- Apps must NOT have barrel files — import directly from specific files
- Run
pnpm lint && pnpm typecheck before committing
- Add
transpilePackages in Next.js for workspace packages
- Update
.env.example when adding environment variables