Set up monorepo with Turborepo/Nx
✓Works with OpenClaudeYou are a monorepo architect. The user wants to set up a production-ready monorepo using Turborepo or Nx with proper workspace configuration, dependency management, and build optimization.
What to check first
- Verify Node.js version:
node --version(need v18+) - Check if
pnpmornpmworkspaces are available:pnpm --versionornpm --version - Confirm no existing
package.jsonor.gitin the target directory
Steps
- Create a new directory and initialize git:
mkdir my-monorepo && cd my-monorepo && git init - Choose your package manager: use
pnpmfor optimal Turborepo performance (install vianpm install -g pnpm) - Initialize Turborepo with
pnpm dlx create-turbo@latest .or Nx withnpx create-nx-workspace@latest my-workspace - Install dependencies at root:
pnpm install(this installs all workspace packages) - Create app and library packages using
turbo genornx generatecommands - Configure
turbo.json(Turborepo) ornx.json(Nx) with task definitions and caching rules - Set up root
pnpm-workspace.yaml(orpackage.jsonworkspaces field) to define package globs likepackages/*andapps/* - Add shared scripts to root
package.json:"dev","build","lint","test"that run across all packages - Run tasks with
pnpm turbo run build --filter=package-nameornx run-many --target=build
Code
{
"name": "monorepo-root",
"version": "1.0.0",
"private": true,
"packageManager": "pnpm@8.0.0",
"scripts": {
"dev": "turbo run dev",
"build": "turbo run build",
"test": "turbo run test",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,json,md}\"",
"clean": "turbo clean && rm -rf node_modules"
},
"devDependencies": {
"turbo": "^1.11.0",
"prettier": "^3.0.0",
"typescript": "^5.3.0",
"eslint": "^8.54.0"
}
}
# turbo.json
{
"version": "1",
"extends": ["//"],
"globalDependencies": ["**/.env.local", ".npmrc"],
"pipeline": {
"build": {
"dependsOn": ["^build"],
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Scaffolding Skills
Other Claude Code skills in the same category — free to download.
Next.js Starter
Scaffold Next.js project with common setup
Express Starter
Scaffold Express.js project with structure
React Starter
Scaffold React project with Vite
TypeScript Config
Set up TypeScript configuration
ESLint Config
Configure ESLint with custom rules
Prettier Config
Set up Prettier configuration
Jest Config
Configure Jest testing framework
Vitest Config
Configure Vitest testing framework
Want a Scaffolding skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.