link-workspace-packages
This skill enables AI assistants to automatically establish and configure dependency links between packages within an Nx monorepo workspace. It streamlines the process of wiring up package relationships, helping developers maintain clean dependency graphs and avoid manual configuration errors.
link-workspace-packages enables you to establish dependencies between packages in your monorepo by using workspace protocols and package manager commands. In npm and yarn, use the `workspace:*` protocol in your package.json to reference sibling packages; pnpm uses `workspace:*` similarly; bun supports workspace linking through its native monorepo features. The skill automates wiring up these relationships so imports like `import { utils } from '@org/shared'` resolve correctly without manual node_modules manipulation.
AI-generated summary based on this skill's SKILL.md
Install
nrwl/nx-ai-agents-config/link-workspace-packages · repository language: JavaScript
git clone https://github.com/nrwl/nx-ai-agents-config
cp -r nx-ai-agents-config/skills/link-workspace-packages ~/.claude/skills/link-workspace-packagesFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How to link packages in monorepo?
link-workspace-packages enables you to establish dependencies between packages in your monorepo by using workspace protocols and package manager commands. In npm and yarn, use the `workspace:*` protocol in your package.json to reference sibling packages; pnpm uses `workspace:*` similarly; bun supports workspace linking through its native monorepo features. The skill automates wiring up these relationships so imports like `import { utils } from '@org/shared'` resolve correctly without manual node_modules manipulation.
What is the pnpm add workspace dependency syntax?
link-workspace-packages guides you through pnpm's workspace dependency syntax: use `pnpm add @org/package-name` from within a package to link a sibling, or manually add `"@org/package-name": "workspace:*"` to your package.json dependencies. The `workspace:*` protocol tells pnpm to resolve the dependency from your local workspace rather than npm registry, creating an efficient symlink in node_modules that points directly to the source package.
How does link-workspace-packages help resolve 'cannot find module' workspace package errors?
link-workspace-packages addresses module resolution failures by ensuring proper workspace protocol configuration and symlink creation across npm, yarn, pnpm, and bun. When you encounter 'cannot find module' errors for workspace packages, this skill helps verify that dependencies are declared with the correct workspace syntax, that package.json exports are configured, and that your package manager has properly linked the packages. It also helps diagnose TS2307 errors in TypeScript by confirming path mappings and tsconfig.json settings align with your workspace structure.
Can link-workspace-packages help with yarn workspace symlink packages setup?
Yes, link-workspace-packages covers yarn workspace linking across both yarn classic and yarn berry. For yarn workspaces, declare dependencies using `"@org/package": "workspace:*"` in package.json, then run `yarn install` to create symlinks automatically. The skill explains how yarn's workspaces feature differs from npm's, including yarn berry's stricter module resolution, and helps you configure your workspace root's package.json to enable workspace mode so sibling packages are discoverable.
How do I fix workspace import resolution errors and TS2307 errors in my monorepo?
link-workspace-packages helps debug and fix TS2307 or module resolution failures by guiding you through workspace protocol setup, tsconfig.json path mappings, and package.json exports configuration. Ensure each workspace package has proper exports defined, verify your package manager's workspace linking is active, and confirm that TypeScript's path mappings (if used) point to the correct source directories. The skill also addresses common issues like missing `@org/*` namespace declarations and ensures symlinks are created correctly in node_modules.
What monorepo package manager linking guide does link-workspace-packages provide for bun?
link-workspace-packages includes guidance for bun's native monorepo support, which automatically discovers and links workspace packages without requiring explicit workspace protocol declarations in many cases. With bun, you can reference sibling packages directly in imports, and bun's package manager handles symlink creation during `bun install`. The skill explains how bun's approach differs from npm, yarn, and pnpm, and helps you configure your workspace structure so bun correctly identifies and wires up package dependencies.
SKILL.md
rendered from the published skill — quoted content, verbatim
Link Workspace Packages
Add dependencies between packages in a monorepo. All package managers support workspaces but with different syntax.
Detect Package Manager
Check whether there's a packageManager field in the root-level package.json.
Alternatively check lockfile in repo root:
pnpm-lock.yaml→ pnpmyarn.lock→ yarnbun.lock/bun.lockb→ bunpackage-lock.json→ npm
Workflow
- Identify consumer package (the one importing)
- Identify provider package(s) (being imported)
- Add dependency using package manager's workspace syntax
- Verify symlinks created in consumer's
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
skills/link-workspace-packages/SKILL.md