Skip to content

feat(cli): add changeset check command to validate changesets before release - #2293

Open
philibea wants to merge 1 commit into
changesets:mainfrom
philibea:feature-check
Open

philibea wants to merge 1 commit into
changesets:mainfrom
philibea:feature-check

Conversation

@philibea

@philibea philibea commented Sep 8, 2026

Copy link
Copy Markdown

Summary

Adds a new changeset check command that validates every changeset in .changeset/ is well-formed and only references packages that still exist in the workspace. Designed to run in CI on main (or on PRs) to catch malformed or stale changesets before they break changeset version during a release.

Problem

When changesets are created or edited by hand (or by an AI tool), they can end up:

  • malformed — missing/invalid frontmatter, bad YAML, invalid version types, etc.
  • stale — referencing packages that were since deleted from the workspace

These errors currently surface during changeset version on the release branch, blocking the release. changeset status catches them too, but it also runs git (diffing against baseBranch/--since) and exits 1 when there are changed packages without changesets — which makes it unsuitable as a pure validation check on main.

Solution

changeset check reuses the existing readChangesets + assembleReleasePlan pipeline:

  • readChangesets parses each .changeset/*.md file → throws on malformed format (missing frontmatter, invalid YAML, bad version type, etc.)
  • assembleReleasePlan validates that every referenced package exists in the workspace → throws Found changeset X for package Y which is not in the workspace

It reads only the working tree (no --since, no git diff), so it works in shallow CI clones and merge-commit checkouts without depending on git history.

# .github/workflows/release.yml
- run: changeset check
- run: changeset version

What it does NOT do

  • Does not use git (unlike status, which calls git diff against baseBranch/--since)
  • Does not fail when there are changed packages without changesets (that is status's job, and intentionally not recommended for CI)
  • Does not check only changesets added in the current PR — it validates all changesets present on disk in the current checkout
  • Stops at the first invalid changeset (error message names the file + reason — good enough; a collect-all-errors mode can be added later if needed)

Files

  • packages/cli/src/commands/check/index.ts — the command (~45 lines, reuses readChangesets + assembleReleasePlan)
  • packages/cli/src/cli.ts — registers the check command
  • packages/cli/src/commands/check/__tests__/check.test.ts — 7 tests (valid, empty --empty changeset, no changesets, stale package ref, malformed frontmatter, invalid version type, no-fail-when-changed-packages-have-no-changeset)
  • packages/cli/src/cli.test.ts — CLI wiring test
  • docs/command-line-options.md + docs/checking-for-changesets.md — docs

Test plan

  • pnpm types:check
  • pnpm lint
  • pnpm format
  • pnpm test run packages/cli/src/cli.test.ts (30 passed)
  • pnpm test run packages/cli/src/commands/check (7 passed)
  • Manual: node packages/cli/bin.js check on this repo → All 2 changeset(s) are valid.
  • Manual: malformed changeset → exits 1 with file + reason
  • Manual: stale package reference → exits 1 with Found changeset X for package Y which is not in the workspace

Signed-off-by: Alexandre Philibeaux <aphilibeaux@scaleway.com>
@netlify

netlify Bot commented Sep 8, 2026

Copy link
Copy Markdown

Deploy Preview for changesets ready!

Name Link
🔨 Latest commit 7ffc907
🔍 Latest deploy log https://app.netlify.com/projects/changesets/deploys/6a9fe8f63e8fe70009aa939c
😎 Deploy Preview https://deploy-preview-2293--changesets.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot

changeset-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7ffc907

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@changesets/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.68%. Comparing base (5e54cd9) to head (7ffc907).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2293      +/-   ##
==========================================
+ Coverage   84.57%   84.68%   +0.10%     
==========================================
  Files          80       81       +1     
  Lines        3177     3199      +22     
  Branches      896      897       +1     
==========================================
+ Hits         2687     2709      +22     
  Misses        433      433              
  Partials       57       57              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant