|
| 1 | +--- |
| 2 | +name: changelog-generator |
| 3 | +description: Create, maintain, and validate human-readable changelog files that follow Keep a Changelog 1.1.0 using the local dev-tools changelog commands. Use when an agent needs to bootstrap a repository's first changelog, add categorized entries to Unreleased or a published version, check whether a branch added changelog content, infer the next version from Unreleased, promote Unreleased into a released version, or export release notes for publishing workflows. |
| 4 | +--- |
| 5 | + |
| 6 | +# Changelog Generator |
| 7 | + |
| 8 | +Maintain changelog files for humans first while keeping them deterministic enough for release automation. |
| 9 | + |
| 10 | +## Workflow |
| 11 | + |
| 12 | +1. Establish current state. |
| 13 | +- Resolve the target file path first. Default to `CHANGELOG.md`, but respect any caller-provided `--file` path. |
| 14 | +- Check whether the changelog file exists. |
| 15 | +- Record whether `Unreleased` already has entries and whether any published releases already exist. |
| 16 | +- If the file does not exist yet, or if Git tags exist that are not documented yet, treat the task as a historical backfill before switching to incremental maintenance. |
| 17 | + |
| 18 | +2. Backfill missing release history when needed. |
| 19 | +- If the repository has no changelog, or if some Git tags are still undocumented, walk the Git tags until the changelog is complete. |
| 20 | +- Inspect tags in chronological order so each documented version can be derived from the diff against the previous tag. |
| 21 | +- Treat version ordering as semantic version ordering, never plain string ordering. For example, `1.11.0` MUST sort after `1.10.0`, and `1.10.0` MUST sort after `1.9.0`. |
| 22 | +- Capture the creation date for each tag and use it as the release date recorded in the changelog. |
| 23 | +- For each missing released version: |
| 24 | + 1. compare the previous tag to the current tag; |
| 25 | + 2. record the current tag date; |
| 26 | + 3. extract the notable user-facing, maintainer-facing, or automation-facing changes from that diff; |
| 27 | + 4. resolve any associated pull request numbers from merge commits, squash commit titles, or release history; |
| 28 | + 5. classify them with the standard Keep a Changelog categories; |
| 29 | + 6. add them to the matching released section with `changelog:entry --release=<version> --date=<YYYY-MM-DD>`. |
| 30 | +- Only after all historical tags are represented should new work continue in `Unreleased`. |
| 31 | +- If a tag exists but the diff does not justify a notable entry, keep the release section minimal rather than inventing noise. |
| 32 | + |
| 33 | +3. Choose the right local command. |
| 34 | +- To add one new entry to `Unreleased`: |
| 35 | + |
| 36 | +```bash |
| 37 | +composer dev-tools changelog:entry -- --type=added "Add example workflow" |
| 38 | +composer dev-tools changelog:entry -- --type=fixed "Fix release note validation" |
| 39 | +``` |
| 40 | + |
| 41 | +- To add or amend an entry in a published section: |
| 42 | + |
| 43 | +```bash |
| 44 | +composer dev-tools changelog:entry -- --type=changed --release=1.2.0 "Adjust published note" |
| 45 | +composer dev-tools changelog:entry -- --type=fixed --release=1.1.0 --date=2026-04-09 "Correct release metadata handling" |
| 46 | +``` |
| 47 | + |
| 48 | +- To validate that a branch added changelog content: |
| 49 | + |
| 50 | +```bash |
| 51 | +composer dev-tools changelog:check |
| 52 | +composer dev-tools changelog:check -- --against=refs/remotes/origin/main |
| 53 | +composer dev-tools changelog:check -- --file=docs/CHANGELOG.md --against=origin/main |
| 54 | +``` |
| 55 | + |
| 56 | +- To infer the next semantic version from `Unreleased`: |
| 57 | + |
| 58 | +```bash |
| 59 | +composer dev-tools changelog:next-version |
| 60 | +composer dev-tools changelog:next-version -- --file=docs/CHANGELOG.md |
| 61 | +``` |
| 62 | + |
| 63 | +- To promote `Unreleased` into a release: |
| 64 | + |
| 65 | +```bash |
| 66 | +composer dev-tools changelog:promote 1.2.0 -- --date=2026-04-19 |
| 67 | +composer dev-tools changelog:promote 1.2.0 -- --file=docs/CHANGELOG.md |
| 68 | +``` |
| 69 | + |
| 70 | +- To export release notes from one published section: |
| 71 | + |
| 72 | +```bash |
| 73 | +composer dev-tools changelog:show 1.2.0 |
| 74 | +composer dev-tools changelog:show 1.2.0 -- --file=docs/CHANGELOG.md |
| 75 | +``` |
| 76 | + |
| 77 | +4. Write human-readable entries. |
| 78 | +- Keep each entry to one line. |
| 79 | +- Prefer the user-visible effect over the implementation detail. |
| 80 | +- Name the concrete surface when that helps: command, option, workflow, configuration, integration, or output. |
| 81 | +- Avoid vague filler such as `misc improvements`, `cleanup`, or `refactorings`. |
| 82 | +- When a change can be tied to a specific pull request, append that PR reference like `(#123)` to the entry. |
| 83 | +- During tag backfill, actively look for PR numbers in merge commits, squash merge titles, or related release metadata before writing the final message. |
| 84 | + |
| 85 | +5. Respect the managed format. |
| 86 | +- Keep `Unreleased` first. |
| 87 | +- Keep released versions in reverse semantic version order unless the repository has an explicit non-semver release policy. |
| 88 | +- Do not use lexical ordering for versions. `1.10.0` and `1.11.0` MUST remain above `1.9.0`, `1.8.0`, and `1.1.0`. |
| 89 | +- Keep section order as: |
| 90 | + 1. `Added` |
| 91 | + 2. `Changed` |
| 92 | + 3. `Deprecated` |
| 93 | + 4. `Removed` |
| 94 | + 5. `Fixed` |
| 95 | + 6. `Security` |
| 96 | +- Omit empty sections. |
| 97 | +- Preserve the official introduction and footer-reference style from Keep a Changelog 1.1.0. |
| 98 | +- Build compare links from the semantically previous published version, not from the previous string-sorted heading. |
| 99 | + |
| 100 | +6. Verify the result. |
| 101 | +- For branch validation, prefer running: |
| 102 | + |
| 103 | +```bash |
| 104 | +composer dev-tools changelog:check -- --against=refs/remotes/origin/main |
| 105 | +``` |
| 106 | + |
| 107 | +- For release preparation, also inspect: |
| 108 | + |
| 109 | +```bash |
| 110 | +composer dev-tools changelog:next-version |
| 111 | +composer dev-tools changelog:show -- <version> |
| 112 | +``` |
| 113 | + |
| 114 | +## Output Contract |
| 115 | + |
| 116 | +- When the task is to add a changelog record, produce one or more command invocations that create the exact entries needed. |
| 117 | +- When the repository has no changelog yet, or has undocumented tags, reconstruct the missing release history from Git tags before treating the work as ordinary `Unreleased` maintenance. |
| 118 | +- When a changelog entry can be traced to a specific pull request, include that PR reference in the rendered entry. |
| 119 | +- When the task is to validate a PR or branch, use `changelog:check` and report whether the branch has meaningful unreleased changes. |
| 120 | +- When the task is to prepare a release, use `changelog:next-version`, `changelog:promote`, and `changelog:show` in that order unless the caller asks for only one step. |
| 121 | +- When a repository has no changelog yet, bootstrap it through `changelog:entry` rather than hand-writing the initial file. |
| 122 | + |
| 123 | +## Consumer Repository Notes |
| 124 | + |
| 125 | +- Repositories using Fast Forward DevTools may not have a changelog yet. In that case, the first `changelog:entry` call SHOULD create the managed file automatically. |
| 126 | +- Do not assume a consumer repository already has historical sections. |
| 127 | +- Do not assume published Git tags are already documented. Compare the tags to the changelog and backfill any missing released sections. |
| 128 | +- When a consumer repository has no previous release, `changelog:next-version` may infer `0.1.0` from the first meaningful `Unreleased` section. |
| 129 | +- Do not assume the managed file lives at `CHANGELOG.md`; respect alternate paths when the caller or repository uses them. |
| 130 | + |
| 131 | +## Reference Files |
| 132 | + |
| 133 | +- Read [references/keep-a-changelog-format.md](references/keep-a-changelog-format.md) for the expected file structure. |
| 134 | +- Read [references/official-example-template.md](references/official-example-template.md) for a concrete template. |
| 135 | +- Read [references/change-categories.md](references/change-categories.md) when classifying entries. |
| 136 | +- Read [references/description-patterns.md](references/description-patterns.md) when polishing wording. |
0 commit comments