Changelog Generator
Generates or updates CHANGELOG.md by extracting and categorizing commits between
two git branches or tags. Follows the Keep a Changelog style
used by the current repository.
Inputs
Collect from the user (or infer from context):
| Parameter |
Description |
Example |
folder_path |
Path to the repository root or to a folder inside the repository; a subfolder automatically scopes commit extraction to that path |
/path/to/repo, microservices/time-series-analytics, ./my-project |
base_ref |
Starting branch, tag, or commit |
release-2026.0.0, v1.0.0, main, commit SHA |
target_ref |
Ending branch, tag, or commit |
release-2026.1.0, v2.0.0, develop |
version_label |
Version string for CHANGELOG entry |
2026.1.0, v1.2.0 |
release_date |
Release month and year (optional) |
June 2026, January 2024 |
changelog_path |
Output path for CHANGELOG.md |
<folder_path>/CHANGELOG.md (default) |
Path Semantics
- If
folder_path points to the repository root, changelog generation covers the entire repository unless a narrower scope is supplied.
- If
folder_path points to a subfolder inside the repository, that subfolder becomes the default commit scope automatically.
- If the user wants to write
CHANGELOG.md in one location but scope commits to another path, call extract_commits.sh with the repository root as the first argument and the scope path as the optional fourth argument.
Folder Path Resolution
If folder_path is not fully specified:
Search by name: If user says "time-series-analytics" but relative path isn't found, search the workspace recursively for a matching folder name.
find <workspace_root> -type d -name "*time-series-analytics*" 2>/dev/null | head -1
Resolve relative paths: If a relative path is given, resolve it from current working directory:
cd <workspace_root> && realpath <relative_path>
Validate: Confirm the folder is a git repository:
git -C <folder_path> rev-parse --is-inside-work-tree
Determine commit scope:
- If
<folder_path> is the repository root, the default scope is the full repository.
- If
<folder_path> is a repository subfolder, use that subfolder as the default scope.
- If needed, keep both values:
repo_root for git operations and scope_path for path-limited history queries.
Version Label Inference
If version_label is not provided, attempt to infer from target_ref:
From branch name: Extract version from naming patterns:
release-2026.1.0 → 2026.1
release-2026.1.0 → 2026.1.0
v1.2.0 → 1.2.0
v2.0.0-rc1 → 2.0.0-rc1
From git tag: If target_ref is a tag like v2.1.0, strip the v prefix.
Fallback: If inference fails, ask the user:
"I couldn't infer a version from <target_ref>. What version label should I use? (e.g., 2026.1.0, v1.2.0)"
If release_date is not provided, use the commit date of the target commit.
GitHub/Remote URL Detection
git -C <folder_path> remote get-url origin
Strip .git suffix. Supports GitHub, GitLab, Gitea, and other hosting platforms.
Workflow
Step 1 – Resolve folder path and validate
If folder_path is incomplete or ambiguous, use the folder path resolution logic from the Inputs section.
Validate the path is inside a git repository:
git -C <folder_path> rev-parse --is-inside-work-tree
If this fails, inform the user the path is not a git repository or repository subfolder.
Resolve the repository root and the effective commit scope:
repo_root=$(git -C <folder_path> rev-parse --show-toplevel)
Treat <folder_path> as the scope when it is a subfolder. If <folder_path> equals repo_root, use the full repository unless the user supplied a narrower scope.
Verify both base_ref and target_ref exist:
git -C "$repo_root" rev-parse <base_ref> >/dev/null 2>&1
git -C "$repo_root" rev-parse <target_ref> >/dev/null 2>&1
If either fails, list available branches and tags:
git -C "$repo_root" branch -a && git -C "$repo_root" tag
Step 2 – Infer version and release date
- If
version_label is missing, apply the version inference logic from the Inputs section.
- If
release_date is missing, extract the commit date of target_ref:git -C "$repo_root" log -1 --format=%cs <target_ref>
Format as "Month Year" (e.g., "June 2026").
Step 3 – Detect existing CHANGELOG format
Before categorizing commits, read the existing CHANGELOG.md (if present):
Check if <folder_path>/CHANGELOG.md exists.
If it exists, analyze its structure:
If no CHANGELOG.md exists or it has no clear structure, use the default keyword-based categorization (described in Step 4).
Step 4 – Extract and categorize commits
Get the commit list between base and target refs:
bash .github/skills/generate-changelog/scripts/extract_commits.sh \
<folder_path> <base_ref> <target_ref> [scope_path]
Usage notes:
- Use
<folder_path> only for full-repository changelogs when it points to the repo root.
- Use a repository subfolder as
<folder_path> for folder-specific changelogs.
- Use
[scope_path] only when <folder_path> is the repo root but commit extraction should be narrowed to a different path.
For each commit, classify into a section based on the detected format from Step 3.
If using default keyword-based categorization, apply these rules in order (first match wins):
| Section |
Keywords / patterns (case-insensitive) |
| Security |
security, cve, vulnerability, bump, trivy, patch, upgrade (dependency) |
| Fixed |
fix, fixed, repair, resolve, hotfix, revert |
| Added |
add, added, new, introduce, enable, support, feature, implement |
| Removed |
remove, removed, delete, deleted, drop, deprecat |
| Documentation |
doc, docs, documentation, readme, changelog, typo, spelling |
| Changed |
everything else |
Tip: If a commit is ambiguous, prefer the section that better serves the reader. Merge commits and automated bot commits (e.g., Dependabot) should go in Security or Changed as appropriate.
Also collect PR numbers referenced in commit messages (pattern (#\d+) or #\d+).
Step 5 – Format the entry
Format reference: See references/changelog-format.md for the exact CHANGELOG structure and style template used by this repository.
Format the new version block using the detected CHANGELOG style from Step 3:
If Keep a Changelog or similar style:
## [<version>] - <release_date>
### Added
- Feature one ([#123])
- Feature two ([abc1234])
### Changed
- Behavior updated ([#124])
### Fixed
- Bug resolved ([#125])
### Security
- Vulnerability patched ([#126])
[#123]: <repo_url>/pull/123
[#124]: <repo_url>/pull/124
[#125]: <repo_url>/pull/125
[#126]: <repo_url>/pull/126
[abc1234]: <repo_url>/commit/abc1234
If custom sections detected: Match the detected sections and order.
Formatting rules:
- Write each bullet in past tense, sentence case.
- Append PR/commit reference at the end:
([#NN]) for PRs, ([hash]) for commits.
- Omit sections with no entries.
- Include reference links at the bottom of the block.
Step 6 – Write or update CHANGELOG.md
If CHANGELOG.md does not exist: Create it with a header + new version block:
# Changelog
All notable changes to this project will be documented in this file.
## [<version>] - <release_date>
...
If CHANGELOG.md exists: Insert the new version block immediately after the introductory paragraph (or after # Changelog header) and before any existing ## [...] sections. Preserve all existing content exactly.
If version already exists in CHANGELOG.md: Ask the user whether to replace or skip:
"Version <version> already exists in CHANGELOG.md. Replace it, append a new entry, or skip?"
Write to <folder_path>/CHANGELOG.md (or custom changelog_path if provided).
Step 7 – Confirm output
Print a summary:
Changelog generated: <folder_path>/CHANGELOG.md
Version: <version> (<release_date>)
Commits processed: <count>
Added: N | Changed: N | Fixed: N | Security: N | Documentation: N | Removed: N
Comparison: <base_ref>...<target_ref>
Repository: <repo_url>
Edge cases
Folder path not found: If searching for a folder name returns multiple matches or no matches, list results and ask the user to clarify which one to use.
Repo root vs scoped folder: If the user asks for a folder-specific changelog but gives the repository root, either resolve a narrower folder path or call extract_commits.sh <repo_root> <base_ref> <target_ref> <scope_path> explicitly.
Detached HEAD or missing refs: If base_ref or target_ref don't exist, list available branches and tags:
git -C "$repo_root" branch -a && git -C "$repo_root" tag
Ask the user to provide valid refs.
No commits found: If git log <base_ref>..<target_ref> returns nothing, the refs may be identical or in the wrong order. Suggest:
- Running
git fetch --all to ensure all remote branches are available
- Reversing the ref order if needed
- Confirming the refs point to different commits
Shallow clone: If the repository is a shallow clone, commit history may be incomplete. Suggest running:
git -C "$repo_root" fetch --unshallow
Duplicate version in CHANGELOG.md: If the version already exists, ask the user:
"Version <version> is already in CHANGELOG.md. Should I replace it, append a new entry, or skip?"
Empty or malformed existing CHANGELOG.md: If the existing CHANGELOG.md has no clear structure, treat it as a new file and use the default keyword-based categorization. Warn the user that the new entry may not match the existing format.
No GitHub/remote URL: If git remote get-url origin fails or returns a non-standard URL (e.g., SSH, local path), skip reference links or ask the user for the repository URL.
Script reference
The helper script supports both repository-wide and folder-scoped extraction:
bash .github/skills/generate-changelog/scripts/extract_commits.sh <repo_or_folder_path> <base_ref> <target_ref> [scope_path]
<repo_or_folder_path> may be the repository root or a subfolder inside the repository.
- When
<repo_or_folder_path> is a subfolder, that subfolder is used as the commit scope automatically.
[scope_path] is optional and is only needed when the first argument is the repository root but a narrower commit scope is desired.
1---2name: generate-changelog3description: Generates or updates CHANGELOG.md by analyzing git commit history between two branches, tags, or revisions in ANY git repository or folder. Use this skill whenever the user asks to create, update, generate changelog, draft release notes from git history, or compare branches/tags (e.g., "generate changelog comparing release-2026.0.0 and release-2026.1.0", "update CHANGELOG.md for the time-series-analytics folder", "what changed between v1.0.0 and main", "create release notes for this project"). The skill auto-detects folder paths, infers version numbers from branch/tag names, detects existing CHANGELOG format, and produces well-categorized entries (Added, Changed, Removed, Fixed, Security, Documentation) matching the repository's established style. Works with ANY folder structure or repository.4license: Apache-2.05---678# Changelog Generator910Generates or updates `CHANGELOG.md` by extracting and categorizing commits between11two git branches or tags. Follows the [Keep a Changelog](https://keepachangelog.com/) style12used by the current repository.1314## Inputs1516Collect from the user (or infer from context):1718| Parameter | Description | Example |19|-----------|-------------|---------|20| `folder_path` | Path to the repository root or to a folder inside the repository; a subfolder automatically scopes commit extraction to that path | `/path/to/repo`, `microservices/time-series-analytics`, `./my-project` |21| `base_ref` | Starting branch, tag, or commit | `release-2026.0.0`, `v1.0.0`, `main`, commit SHA |22| `target_ref` | Ending branch, tag, or commit | `release-2026.1.0`, `v2.0.0`, `develop` |23| `version_label` | Version string for CHANGELOG entry | `2026.1.0`, `v1.2.0` |24| `release_date` | Release month and year (optional) | `June 2026`, `January 2024` |25| `changelog_path` | Output path for CHANGELOG.md | `<folder_path>/CHANGELOG.md` (default) |2627### Path Semantics2829- If `folder_path` points to the repository root, changelog generation covers the entire repository unless a narrower scope is supplied.30- If `folder_path` points to a subfolder inside the repository, that subfolder becomes the default commit scope automatically.31- If the user wants to write `CHANGELOG.md` in one location but scope commits to another path, call `extract_commits.sh` with the repository root as the first argument and the scope path as the optional fourth argument.3233### Folder Path Resolution3435If `folder_path` is not fully specified:36371. **Search by name:** If user says "time-series-analytics" but relative path isn't found, search the workspace recursively for a matching folder name.38 ```bash39 find <workspace_root> -type d -name "*time-series-analytics*" 2>/dev/null | head -140 ```41422. **Resolve relative paths:** If a relative path is given, resolve it from current working directory:43 ```bash44 cd <workspace_root> && realpath <relative_path>45 ```46473. **Validate:** Confirm the folder is a git repository:48 ```bash49 git -C <folder_path> rev-parse --is-inside-work-tree50 ```51524. **Determine commit scope:**53 - If `<folder_path>` is the repository root, the default scope is the full repository.54 - If `<folder_path>` is a repository subfolder, use that subfolder as the default scope.55 - If needed, keep both values: `repo_root` for git operations and `scope_path` for path-limited history queries.5657### Version Label Inference5859If `version_label` is not provided, attempt to infer from `target_ref`:60611. **From branch name:** Extract version from naming patterns:62 - `release-2026.1.0` → `2026.1`63 - `release-2026.1.0` → `2026.1.0`64 - `v1.2.0` → `1.2.0`65 - `v2.0.0-rc1` → `2.0.0-rc1`66672. **From git tag:** If `target_ref` is a tag like `v2.1.0`, strip the `v` prefix.68693. **Fallback:** If inference fails, ask the user:70 > "I couldn't infer a version from `<target_ref>`. What version label should I use? (e.g., 2026.1.0, v1.2.0)"7172If `release_date` is not provided, use the commit date of the target commit.7374### GitHub/Remote URL Detection7576```bash77git -C <folder_path> remote get-url origin78```7980Strip `.git` suffix. Supports GitHub, GitLab, Gitea, and other hosting platforms.818283## Workflow8485### Step 1 – Resolve folder path and validate86871. If `folder_path` is incomplete or ambiguous, use the folder path resolution logic from the Inputs section.882. Validate the path is inside a git repository:89 ```bash90 git -C <folder_path> rev-parse --is-inside-work-tree91 ```92 If this fails, inform the user the path is not a git repository or repository subfolder.93943. Resolve the repository root and the effective commit scope:95 ```bash96 repo_root=$(git -C <folder_path> rev-parse --show-toplevel)97 ```98 Treat `<folder_path>` as the scope when it is a subfolder. If `<folder_path>` equals `repo_root`, use the full repository unless the user supplied a narrower scope.991004. Verify both `base_ref` and `target_ref` exist:101 ```bash102 git -C "$repo_root" rev-parse <base_ref> >/dev/null 2>&1103 git -C "$repo_root" rev-parse <target_ref> >/dev/null 2>&1104 ```105 If either fails, list available branches and tags:106 ```bash107 git -C "$repo_root" branch -a && git -C "$repo_root" tag108 ```109110### Step 2 – Infer version and release date1111121. If `version_label` is missing, apply the version inference logic from the Inputs section.1132. If `release_date` is missing, extract the commit date of `target_ref`:114 ```bash115 git -C "$repo_root" log -1 --format=%cs <target_ref>116 ```117 Format as "Month Year" (e.g., "June 2026").118119### Step 3 – Detect existing CHANGELOG format120121Before categorizing commits, read the existing `CHANGELOG.md` (if present):1221231. Check if `<folder_path>/CHANGELOG.md` exists.1242. If it exists, analyze its structure:125 - **Look for section headers:** Scan for patterns like `## [Version]`, `### Added`, `### Fixed`, etc.126 - **Infer category order:** Note which sections appear and in what order.127 - **Detect categorization style:** Is it Keep a Changelog style? Custom sections? Hybrid?128 - **Example inference:**129 ```130 # Changelog131 ## [2.0.0]132 ### Added133 ### Changed134 ### Fixed135 ```136 → Infer: Use `Added`, `Changed`, `Fixed` (no Security, Documentation, Removed)1371383. If no CHANGELOG.md exists or it has no clear structure, use the **default keyword-based categorization** (described in Step 4).139140### Step 4 – Extract and categorize commits1411421. Get the commit list between base and target refs:143 ```bash144 bash .github/skills/generate-changelog/scripts/extract_commits.sh \145 <folder_path> <base_ref> <target_ref> [scope_path]146 ```147148 Usage notes:149 - Use `<folder_path>` only for full-repository changelogs when it points to the repo root.150 - Use a repository subfolder as `<folder_path>` for folder-specific changelogs.151 - Use `[scope_path]` only when `<folder_path>` is the repo root but commit extraction should be narrowed to a different path.1521532. For each commit, classify into a section based on the **detected format** from Step 3.1541553. **If using default keyword-based categorization**, apply these rules in order (first match wins):156157 | Section | Keywords / patterns (case-insensitive) |158 |---------|----------------------------------------|159 | **Security** | `security`, `cve`, `vulnerability`, `bump`, `trivy`, `patch`, `upgrade` (dependency) |160 | **Fixed** | `fix`, `fixed`, `repair`, `resolve`, `hotfix`, `revert` |161 | **Added** | `add`, `added`, `new`, `introduce`, `enable`, `support`, `feature`, `implement` |162 | **Removed** | `remove`, `removed`, `delete`, `deleted`, `drop`, `deprecat` |163 | **Documentation** | `doc`, `docs`, `documentation`, `readme`, `changelog`, `typo`, `spelling` |164 | **Changed** | everything else |165166 > **Tip:** If a commit is ambiguous, prefer the section that better serves the reader. Merge commits and automated bot commits (e.g., Dependabot) should go in **Security** or **Changed** as appropriate.1671684. Also collect PR numbers referenced in commit messages (pattern `(#\d+)` or `#\d+`).169170### Step 5 – Format the entry171172> **Format reference:** See [`references/changelog-format.md`](references/changelog-format.md) for the exact CHANGELOG structure and style template used by this repository.173174Format the new version block using the **detected CHANGELOG style** from Step 3:175176**If Keep a Changelog or similar style:**177```markdown178## [<version>] - <release_date>179180### Added181- Feature one ([#123])182- Feature two ([abc1234])183184### Changed185- Behavior updated ([#124])186187### Fixed188- Bug resolved ([#125])189190### Security191- Vulnerability patched ([#126])192193[#123]: <repo_url>/pull/123194[#124]: <repo_url>/pull/124195[#125]: <repo_url>/pull/125196[#126]: <repo_url>/pull/126197[abc1234]: <repo_url>/commit/abc1234198```199200**If custom sections detected:** Match the detected sections and order.201202**Formatting rules:**203- Write each bullet in past tense, sentence case.204- Append PR/commit reference at the end: `([#NN])` for PRs, `([hash])` for commits.205- Omit sections with no entries.206- Include reference links at the bottom of the block.207208### Step 6 – Write or update CHANGELOG.md2092101. **If CHANGELOG.md does not exist:** Create it with a header + new version block:211 ```markdown212 # Changelog213214 All notable changes to this project will be documented in this file.215216 ## [<version>] - <release_date>217 ...218 ```2192202. **If CHANGELOG.md exists:** Insert the new version block immediately after the introductory paragraph (or after `# Changelog` header) and *before* any existing `## [...]` sections. Preserve all existing content exactly.2212223. **If version already exists in CHANGELOG.md:** Ask the user whether to replace or skip:223 > "Version `<version>` already exists in CHANGELOG.md. Replace it, append a new entry, or skip?"2242254. Write to `<folder_path>/CHANGELOG.md` (or custom `changelog_path` if provided).226227### Step 7 – Confirm output228229Print a summary:230```231Changelog generated: <folder_path>/CHANGELOG.md232Version: <version> (<release_date>)233Commits processed: <count>234 Added: N | Changed: N | Fixed: N | Security: N | Documentation: N | Removed: N235236Comparison: <base_ref>...<target_ref>237Repository: <repo_url>238```239240## Edge cases241242- **Folder path not found:** If searching for a folder name returns multiple matches or no matches, list results and ask the user to clarify which one to use.243244- **Repo root vs scoped folder:** If the user asks for a folder-specific changelog but gives the repository root, either resolve a narrower folder path or call `extract_commits.sh <repo_root> <base_ref> <target_ref> <scope_path>` explicitly.245246- **Detached HEAD or missing refs:** If `base_ref` or `target_ref` don't exist, list available branches and tags:247 ```bash248 git -C "$repo_root" branch -a && git -C "$repo_root" tag249 ```250 Ask the user to provide valid refs.251252- **No commits found:** If `git log <base_ref>..<target_ref>` returns nothing, the refs may be identical or in the wrong order. Suggest:253 - Running `git fetch --all` to ensure all remote branches are available254 - Reversing the ref order if needed255 - Confirming the refs point to different commits256257- **Shallow clone:** If the repository is a shallow clone, commit history may be incomplete. Suggest running:258 ```bash259 git -C "$repo_root" fetch --unshallow260 ```261262- **Duplicate version in CHANGELOG.md:** If the version already exists, ask the user:263 > "Version `<version>` is already in CHANGELOG.md. Should I replace it, append a new entry, or skip?"264265- **Empty or malformed existing CHANGELOG.md:** If the existing CHANGELOG.md has no clear structure, treat it as a new file and use the default keyword-based categorization. Warn the user that the new entry may not match the existing format.266267- **No GitHub/remote URL:** If `git remote get-url origin` fails or returns a non-standard URL (e.g., SSH, local path), skip reference links or ask the user for the repository URL.268269## Script reference270271The helper script supports both repository-wide and folder-scoped extraction:272273```bash274bash .github/skills/generate-changelog/scripts/extract_commits.sh <repo_or_folder_path> <base_ref> <target_ref> [scope_path]275```276277- `<repo_or_folder_path>` may be the repository root or a subfolder inside the repository.278- When `<repo_or_folder_path>` is a subfolder, that subfolder is used as the commit scope automatically.279- `[scope_path]` is optional and is only needed when the first argument is the repository root but a narrower commit scope is desired.