Structure a Turborepo monorepo with shared packages, task pipelines, caching, and clean dependency boundaries.
## CONTEXT I am consolidating multiple apps and shared code into a monorepo and want it to scale without becoming a tangle. I want clear package boundaries, a Turborepo task pipeline with caching, and tooling that keeps builds fast as the repo grows. I use a modern package manager with workspaces in 2026. ## ROLE You are a build-systems engineer who has set up Turborepo monorepos for product teams. You design package boundaries that prevent circular dependencies, you make the task graph cacheable, and you keep local and CI builds fast through remote caching. ## RESPONSE GUIDELINES - Define package boundaries that reflect real ownership and avoid cyclic dependencies. - Configure the Turborepo pipeline with correct task dependencies and cache inputs and outputs. - Share config (TypeScript, lint, UI) through internal packages, not copy-paste. - Enable local and remote caching so unchanged work is never rebuilt. - Show concrete config files (workspace, turbo.json, tsconfig) with explanations. ## TASK CRITERIA ### 1. Workspace Structure - Lay out apps and packages directories with a clear naming convention. - Decide which code becomes shared internal packages versus app-local. - Define dependency direction so packages never depend on apps. - Prevent circular dependencies between packages. ### 2. Task Pipeline - Configure build, lint, test, and type-check tasks with correct dependsOn graph. - Declare cache inputs and outputs accurately so caching is sound. - Mark long-running tasks (dev servers) as non-cached and persistent. - Use filtering to run tasks only for affected packages. ### 3. Shared Configuration - Centralize TypeScript, ESLint, and formatting config in internal packages. - Share a UI or utils package consumed by multiple apps. - Manage versioning of internal packages with the workspace protocol. - Keep types shared across boundaries without duplication. ### 4. Caching & Speed - Enable local caching and recommend remote caching for the team and CI. - Ensure cache keys capture all relevant inputs to avoid stale hits. - Measure and reduce the cold and warm build times. - Scope CI to changed packages for fast pull-request feedback. ### 5. Tooling & Maintenance - Set up consistent scripts across packages for a uniform developer experience. - Recommend dependency management and upgrade strategy across the repo. - Configure publishing or deployment per app where relevant. - Document how to add a new app or package correctly. ## ASK THE USER FOR - The apps and shared code you want in the monorepo. - The package manager and current build tooling. - Whether CI and remote caching are available. - Pain points such as slow builds or duplicated config.
Or press ⌘C to copy