link-workspace-packages

Detect package managers and wire workspace dependencies across monorepos.

Updated Oct 9, 2024
One-click install
npx skills add https://github.com/pengtoshi/pengtoshi-boilerplate --skill link-workspace-packages-pengtoshi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: link-workspace-packages
Source: https://github.com/pengtoshi/pengtoshi-boilerplate/tree/main/.cursor/skills/link-workspace-packages
Command: npx skills add https://github.com/pengtoshi/pengtoshi-boilerplate --skill link-workspace-packages-pengtoshi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

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 to fix actual linking.

Core Features & Use Cases

  • Detect Package Manager by root package.json or lockfiles and identify workspace framework
  • Wire dependencies between consumer and provider packages within monorepo
  • Validate that node_modules contains symlinks or workspace references after install

Quick Start

Run the workspace command to wire a new provider package into the consumer and verify dependencies resolve.

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?

To fix "cannot find module" errors in a monorepo, you need to link workspace packages using your package manager's native workspace commands rather than manually editing tsconfig paths. This Skill detects your root package manager and executes the appropriate commands to wire dependencies automatically.

How do I link dependencies between workspace packages in pnpm or yarn?

Linking dependencies between workspace packages in pnpm or yarn involves detecting the root lockfile and running the specific workspace command for that manager. This wires the provider package into the consumer without requiring manual package.json edits.

Do I need to manually edit tsconfig paths when adding a new package to an npm workspace?

You do not need to manually edit tsconfig paths when adding a new package to an npm workspace. Instead, use the package manager's workspace commands to establish actual linking, which resolves inter-package dependencies properly.

What is the best way to wire inter-package dependencies after creating a new monorepo package?

The best way to wire inter-package dependencies after creating a new monorepo package is to use your package manager's workspace commands. This ensures node_modules contains the correct symlinks or workspace references to resolve imports.

Why does my monorepo fail to resolve imports like TS2307 after adding a new package?

Monorepo resolution errors like TS2307 occur because the new sibling package has not been wired as a dependency. Running the package manager's workspace commands links the provider package into the consumer, resolving the import error.

Can I use workspace linking to validate node_modules symlinks for monorepo packages?

Yes, workspace linking validates that node_modules contains symlinks or workspace references after install. By executing the appropriate workspace commands, you confirm that inter-package dependencies resolve correctly across the monorepo.