lerna — Claude Code skill: monorepo rules for your agent
A skill that gives your coding agent Lerna conventions: package layout, versioning, publishing and running scripts across a monorepo.
npx skills add Mindrally/skills --skill lerna -a claude-codeWhat lerna does
The skill spells out how to run a Lerna monorepo: where packages live, what goes into lerna.json, how Lerna pairs with package manager workspaces. Your agent stops guessing and follows the same conventions every session.
It covers project structure, configuration, task execution, versioning and publishing. Versioning modes get their own section — independent for per-package versions, fixed mode when everything shares one number. There is a block on conventional commits and how commit types drive version bumps, plus --since for running tasks only in packages that changed.
Useful when you already have a Lerna repo or are moving packages into one. Without Lerna installed and a lerna.json in place, the skill is just a set of conventions: the agent will suggest lerna version and lerna publish, but there is nothing to run them with. Publishing needs npm authentication, and the CI section says so.
What it helps with
- lay out packages under
packages/and writelerna.json - pick between independent and fixed versioning
- run build and tests only in changed packages
- wire conventional commits to automatic version bumps
- publish packages from CI without interactive prompts
Example prompts for the agent
- set up lerna.json for a monorepo with packages in packages/*
- add conventional commits so versions bump from commit types
- show me how to publish only changed packages with lerna publish
How to install lerna
1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill lerna -a claude-code2Manually: put the files in place
~/.claude/skills/lerna/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/lerna/
1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill lerna -a codex2Manually: put the files in place
.agents/skills/lerna/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill lerna -a cursor2Manually: put the files in place
.cursor/skills/lerna/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install Mindrally/skills lerna2Manually: put the files in place
.github/skills/lerna/SKILL.md1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill lerna -a gemini-cli2Platform CLI
gemini skills install https://github.com/Mindrally/skills --path lernaManually: put the files in place
.devin/skills/lerna/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add Mindrally/skills --skill lerna -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about lerna
How do I install the lerna skill in Claude?
Run npx skills add Mindrally/skills --skill lerna -a claude-code. The skill file lands at ~/.claude/skills/lerna/SKILL.md.
What does the lerna skill do?
It gives the agent Lerna conventions for a monorepo: package structure, configuration, versioning, publishing and script execution. It is a reference, not a standalone tool.
Does the skill publish packages to npm by itself?
No. It describes the commands and the order to run them. Publishing happens through lerna publish, and it requires npm authentication.
Source text
SKILL.md · Apache-2.0
---
name: lerna
description: Best practices for Lerna monorepo management, versioning, and publishing
metadata:
maintainer: Mindrally
source: https://github.com/Mindrally/skills
---
# 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:
- `packages/` - All package directories (default)
- 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:
```json
{
"$schema": "https://json.schemastore.org/lerna.json",
"version": "independent",
"npmClient": "npm",
"packages": ["packages/*"],
"useWorkspaces": true
}
```
- Choose versioning mode:
- `"version": "independent"` - Each package versioned separately
- `"version": "1.0.0"` - Fixed/locked mode, all packages same version
- Enable workspaces integration with `useWorkspaces: true`
## Workspaces Integration
Configure npm/yarn/pnpm workspaces in root `package.json`:
```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:
- `lerna run build` - Run build in all packages
- `lerna run test --scope=@org/package` - Run in specific package
- `lerna run lint --since main` - Run only in changed packages
- Use `--stream` for real-time output
- Use `--parallel` for concurrent execution
## Versioning Workflow
- Update versions with `lerna version`:
- `lerna version patch` - Bump patch version
- `lerna version minor` - Bump minor version
- `lerna version major` - Bump major version
- `lerna version` - Interactive version selection
- Lerna automatically:
- Updates package.json versions
- Updates internal dependency versions
- Creates git tags
- Pushes to remote
## Publishing Packages
- Publish with `lerna publish`:
- `lerna publish` - Publish packages changed since last release
- `lerna publish from-git` - Publish packages tagged in git
- `lerna publish from-package` - Publish packages with unpublished versions
- Configure npm registry in `.npmrc` or `lerna.json`
- Use `--dist-tag` for pre-release versions
## Change Detection
- Use `--since` flag for changed packages:
- `lerna run test --since main`
- `lerna changed` - List packages changed since last tag
- `lerna diff` - Show diff since last release
- Leverage affected commands in CI for efficiency
## Conventional Commits
Enable conventional commits for automated versioning:
```json
{
"command": {
"version": {
"conventionalCommits": true,
"message": "chore(release): publish"
}
}
}
```
- Commits determine version bumps:
- `fix:` - Patch version
- `feat:` - Minor version
- `BREAKING CHANGE:` - Major version
- Automatic changelog generation
## Dependency Management
- Use internal package references:
```json
{
"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 `lerna run` with `--since` for efficient CI
- Publish from CI with proper npm authentication
- Use `--yes` flag for non-interactive publishing
## 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
© Mindrally · Apache-2.0 · Mindrally/skills