Guided Build Lab — Phase 02: Monorepo, pnpm Workspaces & Repository Foundation
Purpose
Create a pnpm monorepo whose boundaries, scripts, shared configuration, and dependency ownership are understandable before feature code grows.
Deliverable
TaskFlow repository root with apps/web, apps/api, shared packages, workspace metadata, root scripts, and clean Git hygiene.
Before you touch the code
Open the previous phase checkpoint, run the repository's verification commands, and make sure Git is clean. A guided lab is useful only when you know which change introduced a failure. Write down the current browser/API/database behavior you expect before modifying anything.
Architecture trace
Repository root -> pnpm-workspace.yaml -> apps/* -> packages/* -> workspace dependencies -> root scripts -> Turbo/task graph
Read this flow left to right, then right to left. For each arrow, say what data crosses the boundary, which side trusts the other, and what evidence would prove that this boundary works. This habit prevents framework APIs from becoming disconnected memorization.
Step 1 — Create the repository root and initialize Git before generating applications.
Do the smallest version of this step first. After the change, stop and verify it before continuing. Use terminal output, HTTP responses, browser DevTools, tests, or database inspection depending on the boundary. If the result differs from your prediction, do not add more code; explain the mismatch and fix the earliest failing assumption.
Step 2 — Declare workspace globs and explain why apps and packages are separate categories.
Do the smallest version of this step first. After the change, stop and verify it before continuing. Use terminal output, HTTP responses, browser DevTools, tests, or database inspection depending on the boundary. If the result differs from your prediction, do not add more code; explain the mismatch and fix the earliest failing assumption.
Step 3 — Create web and API workspaces without copying node_modules between them.
Do the smallest version of this step first. After the change, stop and verify it before continuing. Use terminal output, HTTP responses, browser DevTools, tests, or database inspection depending on the boundary. If the result differs from your prediction, do not add more code; explain the mismatch and fix the earliest failing assumption.
Step 4 — Create a shared TypeScript configuration package and consume it through workspace dependencies.
Do the smallest version of this step first. After the change, stop and verify it before continuing. Use terminal output, HTTP responses, browser DevTools, tests, or database inspection depending on the boundary. If the result differs from your prediction, do not add more code; explain the mismatch and fix the earliest failing assumption.
Step 5 — Add root dev/build/typecheck/test scripts that delegate to workspaces.
Do the smallest version of this step first. After the change, stop and verify it before continuing. Use terminal output, HTTP responses, browser DevTools, tests, or database inspection depending on the boundary. If the result differs from your prediction, do not add more code; explain the mismatch and fix the earliest failing assumption.
Step 6 — Inspect pnpm why/list output so you can explain where a dependency is owned and why.
Do the smallest version of this step first. After the change, stop and verify it before continuing. Use terminal output, HTTP responses, browser DevTools, tests, or database inspection depending on the boundary. If the result differs from your prediction, do not add more code; explain the mismatch and fix the earliest failing assumption.
Useful verification commands
pnpm -w install
pnpm --filter web dev
pnpm --filter api start:dev
pnpm -r typecheck
git status
Do not run commands mechanically. Before each command, predict what successful output should prove. If it fails, capture the exact message and identify whether the failure is environment, dependency, compile-time, runtime, network, authorization, or persistence related.
Checkpoint
When the lab works, inspect git diff. Remove accidental debugging output and unrelated edits. Run type checking/tests/build commands relevant to this phase. Commit the checkpoint with a message that describes the capability added, not merely the files changed.
Explain-back
Without looking at the lesson, explain why each layer in the architecture trace exists, what this phase added to TaskFlow, and what would break if the new responsibility were moved to the wrong layer. If you cannot explain the boundary, repeat the trace before moving on.