Skip to content

fix(validate): allow numeric-prefixed change names - #1435

Merged
clay-good merged 4 commits into
mainfrom
fix/allow-numeric-prefixed-change-names
Jul 23, 2026
Merged

fix(validate): allow numeric-prefixed change names#1435
clay-good merged 4 commits into
mainfrom
fix/allow-numeric-prefixed-change-names

Conversation

@clay-good

@clay-good clay-good commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Status: LGTM — surgical, backward-compatible, all 2,238 tests pass.

What was wrong

openspec new change 100-add-feature (or 00001-add-auth) failed with:

✖ Error: Change name must start with a letter

validateChangeName required change names to begin with a letter. But the rest of OpenSpec already treats a leading digit as legitimate:

So OpenSpec shipped archive support for a naming convention its own creation gate refused to create. Users wanting ordering/tiering (100-audit, 200-implement, 00001-add-auth) had to fork the CLI or create directories by hand.

How it was fixed

validateChangeName now reuses the canonical isKebabId grammar instead of its own stricter regex, and the now-unreachable "must start with a letter" branch is removed. The tailored error messages for every other case (uppercase, spaces, underscores, leading/trailing hyphens, consecutive hyphens, invalid characters) are unchanged.

One import + one predicate swap + dead-branch removal — no new options, no schema/config surface, no workflow changes.

Proof it works

Before, 100-add-feature errored. After (real CLI output):

$ openspec new change 100-add-feature
Created change '100-add-feature' at openspec/changes/100-add-feature/

$ openspec new change 00001-add-auth
Created change '00001-add-auth' at openspec/changes/00001-add-auth/

# still correctly rejected:
$ openspec new change add--auth   → ✖ Change name cannot contain consecutive hyphens
$ openspec new change Add-Auth    → ✖ Change name must be lowercase (use kebab-case)

Backward compatibility is guaranteed: [a-z][a-z0-9], so every previously valid name still validates. Added tests cover 100-add-feature, 00001-add-auth, 101-01-fix-auth, and an end-to-end createChange for a numeric-prefixed directory. Full suite: 2,238 passing.

Notes

Closes #850
Closes #1169

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • openspec new change now accepts change names that begin with digits (including zero-padded and digit-only formats).
  • Tests

    • Expanded validation and parsing tests for numeric-prefixed naming patterns.
    • Added coverage to ensure numeric-prefixed names create the expected change directory.
  • Documentation

    • Updated CLI documentation to remove the “must start with a lowercase letter” restriction and add new examples.
  • Bug Fixes

    • Improved change-name validation to follow the shared kebab-case grammar and provide consistent diagnostics for invalid formats.

`validateChangeName` required a leading letter, so `openspec new change
100-add-feature` or `00001-add-auth` failed with "Change name must start
with a letter". This contradicted the rest of OpenSpec: the shared kebab-id
grammar in src/core/id.ts (store ids, workset names, change metadata ids)
already allows a leading digit, and archive explicitly supports
`YYYY-MM-DD-` prefixed change names as a convention (#1309).

Reuse the canonical `isKebabId` grammar for change names so numeric prefixes
work, keeping the tailored error messages for the other failure cases. Fully
backward-compatible: every previously valid name still validates
(`[a-z]` ⊂ `[a-z0-9]`), and consecutive/leading/trailing hyphens, uppercase,
spaces, underscores and other characters are still rejected.

Closes #850
Closes #1169

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@clay-good
clay-good requested a review from TabishB as a code owner July 23, 2026 18:28
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c8d63bd9-8866-406c-b6f1-aae6f8f18845

📥 Commits

Reviewing files that changed from the base of the PR and between fcc522b and 3e84d5b.

📒 Files selected for processing (1)
  • test/utils/change-utils.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/utils/change-utils.test.ts

📝 Walkthrough

Walkthrough

validateChangeName now uses OpenSpec’s shared isKebabId grammar, allowing valid digit-leading names. Tests cover numeric-prefixed validation and creation of matching change directories, while CLI documentation and release metadata describe the updated rules.

Changes

Numeric-prefixed change names

Layer / File(s) Summary
Adopt shared change-name grammar
src/utils/change-utils.ts
validateChangeName uses isKebabId, documents the expanded rules, and removes the digit-specific rejection.
Test numeric-prefixed names
test/utils/change-utils.test.ts
Validation tests cover numeric-prefixed and digit-only names, while createChange verifies the matching directory is created.
Document accepted naming rules
docs/cli.md, .changeset/allow-numeric-prefixed-change-names.md
CLI guidance and release metadata describe numeric-prefixed names and retained invalid-name restrictions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: tabishb

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: allowing numeric-prefixed change names.
Linked Issues check ✅ Passed The code and tests implement the requested numeric-prefix validation change while preserving existing valid names.
Out of Scope Changes check ✅ Passed The docs and changeset support the feature and no unrelated changes are evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/allow-numeric-prefixed-change-names

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/utils/change-utils.test.ts`:
- Around line 44-47: Update the test case around validateChangeName to use an
all-numeric-and-hyphen fixture such as 101-01, preserving the expected valid
result; ensure the test title accurately describes that coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 797bd081-bc7a-4e37-888a-e1dd97f34d48

📥 Commits

Reviewing files that changed from the base of the PR and between 26f009d and 46f794d.

📒 Files selected for processing (2)
  • src/utils/change-utils.ts
  • test/utils/change-utils.test.ts

Comment thread test/utils/change-utils.test.ts Outdated
Address review of the numeric-prefix change:
- add the required changeset (patch)
- fix docs/cli.md which still said names "cannot start with a number"
  and advised prefixing ticket IDs with a word (website copy regenerates
  from this file at build time)
- pin the all-numeric case (`100`) so accepting it is a conscious decision

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploying openspec-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 37f7217
Status: ✅  Deploy successful!
Preview URL: https://fc186505.openspec-docs.pages.dev
Branch Preview URL: https://fix-allow-numeric-prefixed-c.openspec-docs.pages.dev

View logs

CodeRabbit noted the 101-01-fix-auth fixture contains letters, so the old
title 'all digits and hyphens' was inaccurate. Rename it to describe the
tiered numeric-prefix case (#850); the dedicated all-numeric case is the
separate '100' test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@clay-good

Copy link
Copy Markdown
Collaborator Author

Merge-coordination note for whoever lands this (no action needed on the code itself):

Two open PRs edit the same validateChangeName:

Simplest path is to merge this small PR first.

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, backward-compatible validator alignment. I verified numeric-prefixed changes through create, status, list, and archive, and the full 2,239-test suite passes at head 37f7217.

@clay-good
clay-good added this pull request to the merge queue Jul 23, 2026
Merged via the queue into main with commit 6a5171e Jul 23, 2026
17 checks passed
@clay-good
clay-good deleted the fix/allow-numeric-prefixed-change-names branch July 23, 2026 20:09
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.

Support numbered change names (NNNNN-slug) for sequencing feat(validation): allow numeric-prefixed change names for ordered/tiered workflows

2 participants