Link workspace packages in monorepos (npm, yarn, pnpm, bun). USE WHEN: (1) you just created or generated new packages and need to wire up their dependencies, (2) user imports from a sibling package and needs to add it as a dependency, (3) you get resolution errors for workspace packages (@org/*) like "cannot find module", "failed to resolve import", "TS2307", or "cannot resolve". DO NOT patch around with tsconfig paths or manual package.json edits - use the package manager's workspace commands t
The link-workspace-packages skill automates dependency management in monorepo environments by properly linking workspace packages across npm, yarn, pnpm, and bun. It solves the common problem of module resolution errors that occur when packages within a monorepo need to depend on each other, eliminating manual configuration mistakes and ensuring proper symlink creation between sibling packages.
This skill intelligently detects the package manager being used by checking lockfiles or the packageManager field in package.json, then applies the correct workspace syntax for that manager. It handles the nuances of each package manager's approach - from pnpm's explicit workspace protocol and strict isolation to npm's automatic symlink resolution and yarn's Plug'n'Play system. The skill creates proper dependency declarations in package.json files and verifies that symlinks are correctly established in node_modules directories.
Primary use cases include wiring up dependencies after generating new packages, resolving import errors for workspace packages (like TS2307 or 'cannot find module' errors), and adding sibling package dependencies when cross-package imports are needed. It's designed for developers working in monorepos who need reliable, manager-specific commands rather than fragile workarounds like manual tsconfig path edits or hand-crafted package.json modifications.
The skill supports all major JavaScript package managers: pnpm, yarn (v2+/berry), npm, and bun. It automatically detects which package manager your project uses by checking lockfiles (pnpm-lock.yaml, yarn.lock, bun.lock/bun.lockb, package-lock.json) or the packageManager field in root package.json.
Use this skill when you encounter workspace package resolution errors (like 'cannot find module' or TS2307), after creating new packages that need to depend on each other, or when adding imports from sibling packages. It ensures proper workspace protocol syntax and symlink creation, which manual edits often miss.
pnpm requires explicit workspace protocol declarations (workspace:*) and creates symlinks only when dependencies are explicitly added. npm automatically symlinks workspace packages during install without requiring a special workspace: protocol. pnpm also uses strict isolation with no hoisting, while npm hoists shared dependencies to the root node_modules.
The workspace flag (--workspace) or protocol (workspace:*) tells the package manager to link to the local workspace version rather than trying to fetch from the npm registry. Without it, the package manager may attempt to install a published version or fail with resolution errors.
Your root package.json should include "private": true to prevent accidental publishing of the workspace root. Different package managers require different workspace configuration formats in package.json, which this skill handles automatically based on the detected package manager.
Quick Setup:
.claude/skills/Repository
nrwl/nx-ai-agents-config