nrwl/nx-ai-agents-config

link-workspace-packages

Help an agent declare and resolve dependencies between packages in one workspace.

View source

Overview

Use this Skill when an application imports a sibling package that exists in the repository but is not correctly declared as a dependency. Its starting point is the relationship between the consuming package and the providing package, rather than an editor-only path alias. A missing declaration and a missing build output require different fixes.

The source covers npm, pnpm, Yarn and Bun. It asks the agent to identify the repository’s package manager, select the consumer and use the corresponding workspace command. For example, its pnpm recipe targets the consumer with --filter and requires a local package with --workspace. The resulting manifest and lockfile changes still need review.

Verification depends on the install mode: Yarn Plug’n’Play can resolve packages through .pnp.cjs without node_modules. A missing symlink therefore does not establish failure. Test the affected import and its normal build or type check; package exports and generated artifacts can still cause errors after the dependency is correctly linked.

What to prepare

  • The consumer and provider package names, their package.json files and the failing import.
  • The root packageManager field, lockfile, workspace configuration and installed manager version.

What you get

  • A dependency declaration in the correct consumer and the corresponding install state.
  • An import/build check that distinguishes linking problems from export or artifact problems.

Suggested workflow

  1. Identify which package imports which local provider and confirm both belong to the workspace.
  2. Read the manager/version and select its workspace syntax; do not mix recipes from different managers.
  3. Apply the dependency change to the intended consumer and review manifest and lockfile differences.
  4. Verify resolution using the active linker, then run the affected project’s existing checks.

Limits and checks

  • A similarly named registry package is not necessarily the local provider.
  • Do not require node_modules when Yarn PnP is active.
  • Check package exports and build outputs if linking succeeds but imports still fail.
  • This is dependency wiring; nx-import moves code/history and nx-plugins adds Nx integrations.

Common questions

Does this Skill require Nx?

Its reviewed instructions use package-manager workspaces and do not declare Nx or an Nx MCP server as a prerequisite. A compatible coding agent and the repository context are still needed.

Is the copy in nrwl/nx a different capability?

At the two pinned revisions reviewed here, the Skill directories are identical. This page covers the nx-ai-agents-config distribution; choose the source already used by your setup rather than expecting a second capability.

Has the workflow been independently executed here?

No. This explanation is based on the pinned Skill and official package-manager documentation, not a test of your repository.

Install this skill

Use the Skills CLI to add this skill from its verified GitHub source.

npx skills add https://github.com/nrwl/nx-ai-agents-config --skill link-workspace-packages

Source information

Original skill document

Rendered from the source repository. Headings, examples, code, tables, links, and referenced images are preserved.

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 → pnpm
  • yarn.lock → yarn
  • bun.lock / bun.lockb → bun
  • package-lock.json → npm

Workflow

  1. Identify consumer package (the one importing)
  2. Identify provider package(s) (being imported)
  3. Add dependency using package manager's workspace syntax
  4. Verify symlinks created in consumer's node_modules/

pnpm

Uses workspace: protocol - symlinks only created when explicitly declared.

bash
# From consumer directory
pnpm add @org/ui --workspace

# Or with --filter from anywhere
pnpm add @org/ui --filter @org/app --workspace

Result in package.json:

json
{ "dependencies": { "@org/ui": "workspace:*" } }

yarn (v2+/berry)

Also uses workspace: protocol.

bash
yarn workspace @org/app add @org/ui

Result in package.json:

json
{ "dependencies": { "@org/ui": "workspace:^" } }

npm

No workspace: protocol. npm auto-symlinks workspace packages.

bash
npm install @org/ui --workspace @org/app

Result in package.json:

json
{ "dependencies": { "@org/ui": "*" } }

npm resolves to local workspace automatically during install.


bun

Supports workspace: protocol (pnpm-compatible).

bash
cd packages/app && bun add @org/ui

Result in package.json:

json
{ "dependencies": { "@org/ui": "workspace:*" } }

Examples

Example 1: pnpm - link ui lib to app

bash
pnpm add @org/ui --filter @org/app --workspace

Example 2: npm - link multiple packages

bash
npm install @org/data-access @org/ui --workspace @org/dashboard

Example 3: Debug "Cannot find module"

  1. Check if dependency is declared in consumer's package.json
  2. If not, add it using appropriate command above
  3. Run install (pnpm install, npm install, etc.)

Notes

  • Symlinks appear in <consumer>/node_modules/@org/<package>
  • Hoisting differs by manager:
  • npm/bun: hoist shared deps to root node_modules
  • pnpm: no hoisting (strict isolation, prevents phantom deps)
  • yarn berry: uses Plug'n'Play by default (no node_modules)
  • Root package.json should have "private": true to prevent accidental publish

Related by task

from this repository

More skills

All skills
nrwl
Community

nx-workspace

Explore and understand Nx workspaces. USE WHEN answering questions about the workspace, projects, or tasks. ALSO USE WHEN an nx command fails or you need to check available targets/configuration before running a task. EXAMPLES: 'What projects are in this workspace?', 'How is project X configured?', 'What depends on library Y?', 'What targets can I run?', 'Cannot find configuration for task', 'debug nx task failure'.

Total installs
100.6K
GitHub stars
29
Updated
Nov 20
nrwl
Community

nx-import

Import, merge, or combine repositories into an Nx workspace using nx import. USE WHEN the user asks to adopt Nx across repos, move projects into a monorepo, or bring code/history from another repository.

1h installs
1
GitHub stars
29
Updated
Nov 20
nrwl
Community

nx-plugins

Find and add Nx plugins. USE WHEN user wants to discover available plugins, install a new plugin, or add support for a specific framework or technology to the workspace.

1h installs
1
GitHub stars
29
Updated
Nov 20
nrwl
Community

nx-generate

Generate code using nx generators. INVOKE IMMEDIATELY when user mentions scaffolding, setup, structure, creating apps/libs, or setting up project structure. Trigger words - scaffold, setup, create a new app, create a new lib, project structure, generate, add a new project. ALWAYS use this BEFORE calling nxdocs or exploring - this skill handles discovery internally.

1h installs
7
GitHub stars
28
Updated
Oct 7