Claude-skill-registry lerna
Best practices for Lerna monorepo management, versioning, and publishing
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/lerna" ~/.claude/skills/majiayu000-claude-skill-registry-lerna && rm -rf "$T"
manifest:
skills/data/lerna/SKILL.mdsource content
Lerna Monorepo Development
You are an expert in Lerna, the fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages.
Project Structure
- Organize packages following Lerna conventions:
- All package directories (default)packages/- Can customize with multiple directories in
lerna.json
- Each package should be self-contained with its own:
package.json- Source code
- Tests
- Build configuration
Lerna Configuration
Configure
lerna.json at the root:
{ "$schema": "https://json.schemastore.org/lerna.json", "version": "independent", "npmClient": "npm", "packages": ["packages/*"], "useWorkspaces": true }
- Choose versioning mode:
- Each package versioned separately"version": "independent"
- Fixed/locked mode, all packages same version"version": "1.0.0"
- Enable workspaces integration with
useWorkspaces: true
Workspaces Integration
Configure npm/yarn/pnpm workspaces in root
package.json:
{ "workspaces": ["packages/*"], "private": true }
- Let the package manager handle hoisting and linking
- Use Lerna for versioning, publishing, and running scripts
Task Execution
- Run scripts across packages:
- Run build in all packageslerna run build
- Run in specific packagelerna run test --scope=@org/package
- Run only in changed packageslerna run lint --since main
- Use
for real-time output--stream - Use
for concurrent execution--parallel
Versioning Workflow
- Update versions with
:lerna version
- Bump patch versionlerna version patch
- Bump minor versionlerna version minor
- Bump major versionlerna version major
- Interactive version selectionlerna version
- Lerna automatically:
- Updates package.json versions
- Updates internal dependency versions
- Creates git tags
- Pushes to remote
Publishing Packages
- Publish with
:lerna publish
- Publish packages changed since last releaselerna publish
- Publish packages tagged in gitlerna publish from-git
- Publish packages with unpublished versionslerna publish from-package
- Configure npm registry in
or.npmrclerna.json - Use
for pre-release versions--dist-tag
Change Detection
- Use
flag for changed packages:--sincelerna run test --since main
- List packages changed since last taglerna changed
- Show diff since last releaselerna diff
- Leverage affected commands in CI for efficiency
Conventional Commits
Enable conventional commits for automated versioning:
{ "command": { "version": { "conventionalCommits": true, "message": "chore(release): publish" } } }
- Commits determine version bumps:
- Patch versionfix:
- Minor versionfeat:
- Major versionBREAKING CHANGE:
- Automatic changelog generation
Dependency Management
- Use internal package references:
{ "dependencies": { "@org/shared-utils": "^1.0.0" } } - Lerna keeps internal dependencies in sync during versioning
- Hoist common dependencies to root with workspaces
CI/CD Integration
- Install dependencies once at root level
- Use
withlerna run
for efficient CI--since - Publish from CI with proper npm authentication
- Use
flag for non-interactive publishing--yes
Best Practices
- Keep packages focused and single-purpose
- Use consistent package naming:
@org/package-name - Maintain clear dependency boundaries between packages
- Document package APIs and usage
- Use TypeScript with project references for type checking
- Implement proper testing at package and integration levels
- Consider Nx integration for advanced caching and task execution