Skip to content

How to understand a Turborepo monorepo codebase

A Turborepo monorepo holds several apps and shared packages in one repository, linked by the package manager's workspaces. `turbo.json` describes how tasks such as `build` and `test` depend on each other across packages, and Turborepo caches their outputs.

How to tell it's Turborepo monorepo

  • turbo.json at the root and turbo in devDependencies
  • apps/ and packages/ folders
  • Workspace dependencies such as "@acme/ui": "workspace:*"

Where things usually live

turbo.json
Task definitions (tasks, called pipeline before v2), dependsOn, outputs and inputs.
apps/*
Deployable applications, such as web, docs and api.
packages/*
Shared code: UI kit, config, database client, TypeScript and ESLint presets.
package.json (root)
Workspace globs and root scripts that call turbo run.
pnpm-workspace.yaml
Workspace list when using pnpm.

Conventions, not rules. Real projects rename and move things, so confirm against the repository.

Where to start reading

  1. The root package.json and workspace config, to list every package
  2. turbo.json, for how builds depend on each other
  3. The package.json of the app you care about, for its internal dependencies

How a request moves through the code

  1. 1turbo run build reads the workspace graph from each package.json.
  2. 2dependsOn: ["^build"] makes each package's dependencies build first.
  3. 3Turbo hashes each task's inputs and restores cached outputs when nothing changed.
  4. 4Apps import internal packages by name, resolved to local folders through workspaces.

Questions to ask about the repository

  • Draw the dependency graph between apps and packages.
  • Which packages are compiled and which are consumed as source?
  • Which apps would be affected by a change to packages/ui?

What trips people up

  • Internal packages may point main at TypeScript source or at built output; mixing the two causes confusing errors.
  • Missing outputs or inputs in turbo.json leads to stale cache hits or no caching at all.
  • For RepoGrasp's size limit, paste a link to one app or package folder rather than the whole monorepo.