link-workspace-packages

Detect package managers and link sibling workspace packages in monorepos.

Updated Apr 11, 2025
One-click install
npx skills add https://github.com/pabloimrik17/monolab --skill link-workspace-packages-pabloimrik17
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: link-workspace-packages
Source: https://github.com/pabloimrik17/monolab/tree/main/.opencode/skills/link-workspace-packages
Command: npx skills add https://github.com/pabloimrik17/monolab --skill link-workspace-packages-pabloimrik17

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Resolves missing or unresolved imports and dependency resolution errors for sibling packages in monorepos by properly declaring and linking workspace packages so local packages are discoverable at install time.

Core Features & Use Cases

  • Automatic Package Manager Detection: Detects the package manager from the root package.json packageManager field or common lockfiles and selects the correct workspace command.
  • Manager-specific Linking: Adds workspace dependencies using pnpm, yarn (berry), npm, or bun semantics so the consumer package references the provider package with the appropriate workspace protocol or install behavior.
  • Verification Guidance: Shows how to confirm that symlinks or workspace links were created and explains hoisting differences across managers to avoid phantom dependency issues.
  • Use Case: After generating a new library in a monorepo, use this workflow to add it as a dependency to an application that imports it and to fix TS2307 / cannot find module resolution errors.

Quick Start

From the repository root detect the package manager and run the corresponding workspace add command to link the provider package into the consumer package.

Frequently Asked Questions about link-workspace-packages

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

FAQPage Schema
How do I fix cannot find module errors for sibling packages in a monorepo?

Fix cannot find module errors in a monorepo by declaring and linking sibling workspace packages so local packages are discoverable at install time. This resolves missing imports by symlinking the provider package into the consumer package.

How do I link workspace packages when using different package managers?

Link workspace packages by detecting the package manager from the root package.json packageManager field or lockfile, then running manager-specific workspace add or install commands that produce the appropriate workspace protocol entries or local installs.

Does this workspace linking approach work with pnpm, yarn, npm, and bun?

Yes, workspace linking works with npm, pnpm, yarn (berry), and bun. It applies manager-specific semantics to add dependencies, ensuring the consumer package references the provider package with the correct workspace protocol or install behavior.

Why do I need to declare workspace dependencies after creating a new package in a monorepo?

You need to declare workspace dependencies after creating a new package so local sibling packages are properly symlinked and discoverable. Without declaring them, import resolution fails because the package manager cannot find the local provider package.

How do I verify that workspace symlinks were created correctly across different package managers?

Verify workspace symlinks were created by checking for workspace protocol entries or local installs in the consumer package. Verification guidance explains hoisting differences across managers to help you avoid phantom dependency issues.

What is the best way to add a sibling package as a dependency in a monorepo?

The best way to add a sibling package as a dependency is to run the corresponding workspace add command from the repository root after detecting your package manager, which links the provider package into the consumer package using the correct workspace protocol.