t3-monorepo-patterns

Configures pnpm workspaces, Turborepo tasks, and package boundaries for T3 Turbo monorepos.

Updated Aug 2, 2026
One-click install
npx skills add https://github.com/leonardoacosta/skills --skill t3-monorepo-patterns-leonardoacosta
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: t3-monorepo-patterns
Source: https://github.com/leonardoacosta/skills/tree/main/t3-stack-kit/skills/t3-monorepo-patterns
Command: npx skills add https://github.com/leonardoacosta/skills --skill t3-monorepo-patterns-leonardoacosta

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Structuring a T3 Turbo monorepo involves recurring decisions about when to extract packages, how to wire Turborepo task dependencies, and how to keep TypeScript project references consistent — mistakes here surface as broken builds, circular dependencies, and tools silently targeting the wrong database. ## Core Features & Use Cases - Package Extraction Rules: Decision tables for when code belongs in packages/ versus staying inline in an app, preventing premature extraction. - Turborepo and pnpm Configuration: Canonical turbo.json task graphs, workspace filtering commands, and dotenvx run --overload env-loading patterns that stop stray shell variables from shadowing project .env values. - Boundary Packages: Reference patterns for a schema-only packages/contracts (one runtime dependency) and a pino + OpenTelemetry packages/logger leaf package. - Use Case: When adding a new shared package to a T3 monorepo, follow the five-step checklist (package.json exports, root tsconfig paths, project references, pnpm filter install, turbo typecheck) to avoid Cannot find module errors. ## Quick Start Ask the agent to review your monorepo structure and apply the T3 monorepo patterns for package extraction, Turbo tasks, and workspace dependencies.

Frequently Asked Questions about t3-monorepo-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new package to a pnpm Turborepo monorepo?

Create the package with an exports field, add its path to the root tsconfig paths, add a project reference in the consuming package's tsconfig, then run pnpm add with --filter to register the dependency. Verify with pnpm turbo run typecheck from the monorepo root.

When should I extract code into a shared package?

Extract to packages/ only when two or more apps consume the same code. Single-consumer code stays in the app, and single utility functions should never become packages — premature extraction adds cross-package overhead with no reuse payback.

Why does typecheck fail with Cannot find module in a pnpm workspace?

This error means one of four steps is missing: the package.json exports field, the root tsconfig paths entry, the consuming package's project reference, or the pnpm --filter dependency registration. All four are required for module resolution.

Should Turborepo typecheck depend on build?

No. Setting typecheck to depend on ^build turns it into a full build chain. Use composite: true with TypeScript project references instead so typecheck runs independently and in parallel.

Why does drizzle-kit or my dev server connect to the wrong database?

A pre-set shell or global environment variable can shadow the project .env value when with-env scripts omit the --overload flag. Use dotenvx run --overload so the repository .env always wins, and restart the dev server after fixing it.

What is a schema-only contracts package in a monorepo?

It is a narrow-waist package declaring only wire-format types in Zod or Effect Schema, with exactly one runtime dependency and zero internal workspace deps. It keeps client bundles from transitively pulling Drizzle or auth libraries.