Set up a production-ready monorepo with Turborepo including shared packages, workspace configuration, CI/CD pipelines, and dependency management.
## ROLE You are a developer tooling specialist who has set up and maintained monorepos for organizations with 10-50 developers and dozens of packages. You understand the trade-offs between monorepo tools (Turborepo, Nx, Lerna), workspace managers (pnpm, npm, yarn), and the organizational challenges that come with sharing code across multiple applications. You set up monorepos that are fast to build, easy to understand, and scale as the team grows. ## CONTEXT Monorepos solve the code sharing problem: instead of publishing shared code to npm and managing version synchronization, all code lives in one repository with direct imports between packages. But monorepos introduce new challenges: build orchestration (build packages in dependency order), caching (do not rebuild unchanged packages), CI performance (do not test everything on every PR), and workspace management (dependency hoisting, version conflicts). Turborepo solves most of these with its task caching and pipeline system, but it needs to be configured correctly. ## TASK Set up a complete Turborepo monorepo: 1. **Workspace Structure**: Design the monorepo structure: apps/ directory for deployable applications (web, admin, mobile, docs), packages/ directory for shared code (ui, utils, config, database, types), and tooling/ for shared configuration (ESLint, TypeScript, Tailwind). 2. **Turborepo Configuration**: Configure turbo.json with: pipeline definitions for build, dev, lint, test, and type-check tasks. Set up proper task dependencies (build depends on ^build for dependencies). Configure caching with inputs and outputs for each task. 3. **Package Configuration**: For each shared package, create: package.json with proper exports field (supporting ESM and CJS), TypeScript configuration extending the base tsconfig, build configuration (tsup for libraries, no build for internal packages), and proper peer dependency declarations. 4. **Shared UI Package**: Set up a shared UI component package with: component exports, shared Tailwind configuration, Storybook integration for isolated development, and proper tree-shaking support. 5. **Shared Configuration**: Create shared config packages for: ESLint (base rules + framework-specific extensions), TypeScript (base tsconfig + app-specific extensions), Tailwind (shared theme + plugin configuration), and Prettier. 6. **CI/CD Pipeline**: Configure GitHub Actions for the monorepo: use Turborepo's remote caching, run only affected tests (turbo run test --filter=...[origin/main]), parallel job execution for independent packages, and deployment triggers per app. 7. **Development Workflow**: Configure the dev experience: single pnpm dev command starts all apps, hot reload across package boundaries, proper TypeScript path aliases, and VS Code workspace settings. 8. **Dependency Management**: Set up dependency policies: shared dependencies hoisted to root, version pinning strategy, update automation (Renovate or Dependabot), and workspace protocol (workspace:*) for internal packages. ## INFORMATION ABOUT ME - [APPLICATIONS TO INCLUDE] (web app, admin panel, docs site, mobile, API) - [SHARED CODE NEEDS] (UI components, utilities, types, database client) - [PACKAGE MANAGER PREFERENCE] (pnpm recommended) - [CI/CD PLATFORM] ## RESPONSE FORMAT Deliver: the complete directory structure, all configuration files (turbo.json, root package.json, tsconfig base, eslint config), shared package setup, CI pipeline, and a developer onboarding guide.
Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[APPLICATIONS TO INCLUDE][SHARED CODE NEEDS][PACKAGE MANAGER PREFERENCE]