skillfed

lerna

Master Lerna monorepo setup and management with this comprehensive skill. Learn to initialize projects, configure workspaces, and orchestrate builds across multiple packages efficiently. Ideal for teams scaling JavaScript and TypeScript codebases.

Lerna simplifies monorepo initialization by providing scaffolding and configuration tools. Start by installing Lerna globally or as a dev dependency, then run `lerna init` to create a lerna.json configuration file and packages directory. Configure your workspace settings, choose between fixed or independent versioning modes, and set up your package.json scripts. Lerna will guide you through connecting your packages and establishing the monorepo structure needed for coordinated development across multiple projects.

AI-generated summary based on this skill's SKILL.md

202 30 Apache-2.0 updated by Mindrally

Install

Mindrally/skills/lerna

CLI (skillfed)coming soon
git clone https://github.com/Mindrally/skills
cp -r skills/lerna ~/.claude/skills/lerna

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How do I set up a Lerna monorepo from scratch?

Lerna simplifies monorepo initialization by providing scaffolding and configuration tools. Start by installing Lerna globally or as a dev dependency, then run `lerna init` to create a lerna.json configuration file and packages directory. Configure your workspace settings, choose between fixed or independent versioning modes, and set up your package.json scripts. Lerna will guide you through connecting your packages and establishing the monorepo structure needed for coordinated development across multiple projects.

What is the difference between Lerna independent and fixed versioning?

Lerna offers two versioning strategies. Fixed versioning maintains a single version number across all packages—when you publish, all packages increment together regardless of individual changes. Independent versioning allows each package to have its own version number and changelog, incrementing only when that specific package changes. Choose fixed versioning for tightly coupled packages that release as a unit, and independent versioning for loosely coupled packages with separate release cycles. Your choice affects how Lerna handles publishing and changelog generation.

How can Lerna run scripts across packages efficiently?

Lerna's `run` command executes npm scripts across multiple packages with built-in parallelization and streaming output. Use `lerna run <script>` to run a script in all packages, or add `--scope` to target specific packages. Lerna respects dependency order by default, ensuring packages build in the correct sequence. The `--stream` flag provides real-time output, while `--parallel` maximizes concurrency. This task execution model is central to Lerna's ability to orchestrate complex build systems across TypeScript and JavaScript packages in your monorepo.

How does Lerna automate versioning and publishing across multiple packages?

Lerna automates the entire release workflow by detecting changes, updating versions, generating changelogs, and publishing packages. When you run `lerna publish`, Lerna identifies which packages have changed since the last release, prompts you to select new versions, and automatically updates package.json files and changelogs. Lerna integrates with conventional commits to automate version bumping and changelog generation. You can also publish from git tags, configure scoped package publishing, and customize the publishing process to fit your CI/CD pipeline, making versioning and publishing across multiple packages seamless.

How do I integrate Lerna with workspaces and CI/CD pipelines?

Lerna integrates seamlessly with npm workspaces and yarn workspaces to optimize dependency hoisting and installation. Configure your lerna.json to use workspaces, which reduces disk space and improves install times. In CI/CD pipelines, use `lerna run` with the `--since` flag to detect and build only affected packages, reducing build time. Lerna's change detection identifies which packages have been modified since the last release, allowing your pipeline to run tests and builds only on changed packages. This integration enables scalable development workflows where large monorepos remain efficient even as they grow.

How can I detect changes between package versions using Lerna?

Lerna's change detection capabilities help identify which packages have been modified in your monorepo. The `--since` flag compares the current state against a previous git ref, allowing you to run tasks only on affected packages. Use `lerna changed` to list packages with changes since the last release, and `lerna diff` to view the actual code differences. This feature is essential for CI/CD optimization, enabling you to run builds, tests, and publishing workflows only on packages that have actually changed, reducing unnecessary work and accelerating your development pipeline.

SKILL.md

rendered from the published skill — quoted content, verbatim

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:

{
  "$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:

{
  "workspaces": ["packages/*"],
  "private": true
}
  • Let the

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 1 file
lerna/SKILL.md

Related skills

Tags

monorepo-orchestration multi-package-publishing version-automation workspace-management ci-cd-tooling dependency-hoisting task-runner release-management