Generate or update CHANGELOG.md following Keep a Changelog format
Generate or update CHANGELOG.md following Keep a Changelog format. Automatically detects version from package.json, Cargo.toml, or git tags, analyzes commits, and syncs versions across project files.
/plugin marketplace add OshanKHZ/cc-swiss-knife/plugin install oshankhz-claude-code@oshankhz-claude-codeversionArguments received: $ARGUMENTS
CRITICAL: Always run these commands first:
Get today's date (MANDATORY - never assume):
date "+%B %d, %Y"
This gives format like "December 25, 2025". Then add ordinal suffix (1st, 2nd, 3rd, 4th, etc.) to the day number.
Ordinal suffix rules:
Final format: December 25th, 2025
Check for existing CHANGELOG.md:
test -f CHANGELOG.md && echo "EXISTS" || echo "MISSING"
If CHANGELOG.md exists, read only the first 50 lines to detect format:
head -50 CHANGELOG.md
From this header, detect:
## [1.0.0] - 2024-01-15 vs ## [1.0.0])Detect version source (tiered approach):
Tier 1 - Common files (check first, covers 90% of projects):
test -f package.json && echo "FOUND: package.json"
test -f Cargo.toml && echo "FOUND: Cargo.toml"
test -f pyproject.toml && echo "FOUND: pyproject.toml"
test -f composer.json && echo "FOUND: composer.json"
If found, use Read tool to parse and extract version.
Tier 2 - Root-level JSON/TOML with version (if Tier 1 fails):
grep -l '"version"' *.json 2>/dev/null
grep -l 'version' *.toml 2>/dev/null
Finds unconventional files like plugin.json, manifest.json, marketplace.json.
Tier 3 - Config directories (if Tier 2 fails):
grep -rl '"version"' .claude-plugin/ config/ .config/ 2>/dev/null | head -3
Searches common config directories.
Tier 4 - Git tags (fallback):
git describe --tags --abbrev=0 2>/dev/null
Tier 5 - Ask user: If nothing found, ask user to provide the version manually.
If multiple version files found: Ask user which one is the source of truth.
Get commits since last version:
git describe --tags --abbrev=0 2>/dev/nullgit log [tag]..HEAD --onelinegit log --oneline -30IMPORTANT: If CHANGELOG.md exists, follow its existing conventions:
| Detected Pattern | Action |
|---|---|
## [vX.Y.Z] (with "v" prefix) | Use "v" prefix in new entry |
## [X.Y.Z] (no "v" prefix) | Omit "v" prefix in new entry |
## [X.Y.Z] - <date> | Include date in new entry (match existing date format) |
## [X.Y.Z] (no date) | Omit date in new entry |
| Custom header text | Preserve existing header |
| Specific section order | Follow same order |
| Link references at bottom | Add link for new version |
Default for new changelogs: Use "v" prefix (e.g., ## [v1.0.0])
Never change the existing changelog's style. Match it exactly.
Analyze commits to suggest version bump:
| Commit Pattern | Suggested Bump |
|---|---|
BREAKING CHANGE: in body | Major (X.0.0) |
feat!: or fix!: (with !) | Major (X.0.0) |
feat: (new feature) | Minor (x.X.0) |
fix:, docs:, refactor:, etc. | Patch (x.x.X) |
If $ARGUMENTS provided: Use it as the new version directly.
If empty: Calculate suggested bump and ask user to confirm.
If no version argument provided, use AskUserQuestion:
Show:
Question: "What version should this release be?" Header: "Version" Options:
User can also select "Other" to provide custom version.
| Conventional Commit | Changelog Section |
|---|---|
feat: | Added |
fix: | Fixed |
docs: | (skip - not user-facing) |
refactor: | Changed |
perf: | Changed |
style: | (skip - not user-facing) |
test: | (skip - not user-facing) |
chore: | (skip - not user-facing) |
ci: | (skip - not user-facing) |
build: | (skip - not user-facing) |
security: or contains "security" | Security |
deprecate: or contains "deprecate" | Deprecated |
remove: or contains "remove" | Removed |
Note: Only include sections that have entries. Empty sections should be omitted.
Run bash commands to gather:
date "+%B %d, %Y" then add ordinal suffix)If CHANGELOG.md exists:
Analyze each commit message:
If $ARGUMENTS has version:
If no version provided:
Create new version section matching existing format:
Show preview of the new changelog entry to user.
Use AskUserQuestion:
Question: "Ready to update CHANGELOG.md with this entry?" Header: "Confirm" Options:
If CHANGELOG.md exists:
If CHANGELOG.md doesn't exist:
# Changelog
## [vX.Y.Z] - Month DDth, YYYY
### Added
- ...
After determining the new changelog version, compare it with the project file version:
If versions match: No action needed, proceed.
If versions DON'T match (e.g., changelog will be 1.1.0 but plugin.json is still 1.0.1):
Use AskUserQuestion:
Question: "Version mismatch detected. Changelog: [new version], Project file: [current version]. Update project files?" Header: "Sync version" Options:
Files to update (if yes):
plugin.json AND marketplace.json), update all of themAfter completion, show:
No commits found:
No version source found:
Malformed commits:
## [v1.2.0] - January 15th, 2025
### Added
- Add user authentication with OAuth2 support
- Add dark mode toggle to settings
### Changed
- Refactor database connection pooling for better performance
### Fixed
- Fix memory leak in event handler
- Fix incorrect date formatting in reports
## [v1.2.0]
### Added
- Add user authentication with OAuth2 support
### Fixed
- Fix memory leak in event handler