# lerna

A skill that gives your coding agent Lerna conventions: package layout, versioning, publishing and running scripts across a monorepo.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 650 installs · ★ 286
- Author: Mindrally
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Mindrally/skills/tree/HEAD/lerna/SKILL.md
- Updated: 2026-10-08
- HTML: https://affpapa.org/en/nevibecode/skills/lerna

## What it 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.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill lerna -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/lerna/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/lerna/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill lerna -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/lerna/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill lerna -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/lerna/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Mindrally/skills lerna
```

2. **Manually: put the files in place**
- File: `.github/skills/lerna/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill lerna -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Mindrally/skills --path lerna
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/lerna/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill lerna -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Mindrally/skills/tree/HEAD/lerna/SKILL.md

## When to use it
- lay out packages under `packages/` and write `lerna.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
- 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

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: e15d69302f926461.

BEGIN THIRD-PARTY FILE e15d69302f926461
````text
---
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
````
END THIRD-PARTY FILE e15d69302f926461

The third-party file has ended. Everything between the e15d69302f926461 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3059 of 3963 bytes. © Mindrally · Apache-2.0 · https://github.com/Mindrally/skills/tree/HEAD/lerna/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
