Provides best practices and guidance for working with Rush monorepos. Use when the user is working in a Rush-based repository, asks about Rush commands (install, update, build, rebuild), needs help with project selection, dependency management, build caching, subspace configuration, or troubleshooting Rush-specific issues.
This skill provides essential best practices for working with Rush monorepos. Following these guidelines ensures efficient dependency management, optimal build performance, and proper command usage.
When encountering unclear issues or questions:
When running commands like install, update, build, rebuild, etc., by default all projects under the entire repository are processed. Use these selection flags to improve efficiency:
Select specified project and all its dependencies.
rush build --to @my-company/my-project
rush build --to my-project # If project name is unique
rush build --to . # Use current directory's project
Select all dependencies of specified project, but not the project itself.
rush build --to-except @my-company/my-project
Select specified project and all its downstream dependencies.
rush build --from @my-company/my-library
Select projects that might be affected by specified project changes, excluding dependencies.
rush build --impacted-by @my-company/my-library
Similar to --impacted-by, but excludes specified project itself.
rush build --impacted-by-except @my-company/my-library
Only select specified project, completely ignore dependency relationships.
rush build --only @my-company/my-project
rush build --impacted-by projectA --only projectB
Choose the correct command tool based on different scenarios:
rush command - Execute operations affecting the entire repository or multiple projects
rushx command - Execute specific scripts for a single project
npm run or pnpm runrush-pnpm command - Replace direct use of pnpm in Rush repository
| Command | Behavior | When to Use |
|---|---|---|
rush update | Updates shrinkwrap, installs new dependencies | After cloning, after git pull, after modifying package.json |
rush install | Read-only install from existing shrinkwrap | CI/CD pipelines, ensuring version consistency |
| Command | Behavior | When to Use |
|---|---|---|
rush build | Incremental build, only changed projects | Daily development, quick validation |
rush rebuild | Clean build all projects | Complete rebuild needed, investigating issues |
Choose in rush.json:
{
"pnpmVersion": "8.x.x" // Preferred - efficient, strict
// "npmVersion": "8.x.x" // Alternative
// "yarnVersion": "1.x.x" // Alternative
}
Configure in common/config/subspaces/<subspace>/common-versions.json:
{
"preferredVersions": {
"react": "17.0.2",
"typescript": "~4.5.0"
},
"implicitlyPreferredVersions": true,
"allowedAlternativeVersions": {
"typescript": ["~4.5.0", "~4.6.0"]
}
}
Always use Rush commands, not npm/pnpm directly:
rush add -p lodash --dev # Add dev dependency
rush add -p react --exact # Add exact version
rush remove -p lodash # Remove dependency
Configure in <project>/config/rush-project.json:
{
"operationSettings": [
{
"operationName": "build",
"outputFolderNames": ["lib", "dist"],
"disableBuildCacheForOperation": false,
"dependsOnEnvVars": ["MY_ENV_VAR"]
}
]
}
Cache Behavior:
common/temp/build-cacheenableParallelismnpm, pnpm, yarn - use Rush commandsrush purge to clean environmentrush update --recheck to force dependency checkrush rebuild to skip cacherushx build output for specific errors--verbose for detailed logs--to, --from, etc.) to reduce scopeWhat is Subspace:
When to Use:
Official Websites:
Search Existing Issues:
Search these resources first when:
Ask the user for clarification when:
For expanded information on specific domains, see:
references/core-commands.md - Detailed command referencereferences/project-configuration.md - Configuration file specificationsreferences/dependency-management.md - Advanced dependency patternsreferences/build-system.md - Build optimization and cachingreferences/subspace.md - Subspace setup and usage