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.
This skill guides an agent through importing, merging, or combining repositories into an Nx workspace using the `nx import` command while preserving git commit history. It solves the practical and error-prone problem of adopting Nx across multiple repos or moving projects into a monorepo, where naive imports produce directory conflicts, broken workspace globs, missing root dependencies, and unmerged Nx configuration.
The skill documents two import strategies (subdirectory-at-a-time for monorepo sources, whole-repo for single-project sources) with their trade-offs, directory-convention rules, and application-versus-library detection heuristics across JS/TS, JVM (Maven/Gradle), and .NET projects. It calls out common failure modes — pnpm workspace globs pointing at the wrong directory, root dependencies and nx.json targetDefaults/namedInputs not being merged, rewritten test scripts — and prescribes fixes. Deep dives in reference files cover Gradle wrapper placement, Jest and Vitest integration (presets, tsconfig.spec.json, plugin registration, CI atomization), Next.js, Vite, ESLint, and Turborepo migration specifics.
Target users are developers and platform engineers adopting Nx, consolidating multiple repositories into a monorepo, or bringing external code with its history into an existing Nx workspace. All guidance centers on the safe, standard `nx` and package-manager CLIs (nx import, nx add, pnpm install) and configuration edits; there are no destructive or remote-execution operations.
Yes. The skill's core premise is that nx import brings code from a source repository or folder into the current workspace while preserving commit history, and it links to the Nx docs on preserving git histories.
nx import adds the imported directory itself (e.g. 'apps') to pnpm-workspace.yaml rather than proper glob patterns. The fix is to replace it with correct globs such as apps/* or libs/shared/* and run pnpm install.
No, and this is called out as critical. It does not merge dependencies/devDependencies from package.json or targetDefaults, namedInputs, and plugin configs from nx.json. You must diff source and destination and add the missing pieces manually.
The skill provides application-versus-library detection heuristics (build entrypoints, exports fields, packaging types across JS, JVM, and .NET). Applications go to apps/<name>; libraries follow the destination's existing convention such as packages/ or libs/.
Yes. After nx 22.6.0 nx import responds with .ndjson output and follow-up questions; for earlier versions the skill recommends running with --no-interactive and specifying all flags directly.
Quick Setup:
.claude/skills/Repository
nrwl/nx-ai-agents-config