# AI Changelog Drafting

## Objective

Turn merged work into a changelog draft written for customers, not for engineers.

A grouped, customer-facing changelog draft generated from merged work items or release notes for a nominated release, held for review before publishing.

## Before You Begin

This feature is being added to an application that already exists and already
works. Do not scaffold a new project, and do not assume a blank slate.

Inspect the codebase first and establish:

- The existing application structure and where code of this kind already lives.
- The framework and version in use.
- The existing design system — colours, spacing, typography, and component conventions.
- Existing UI components you can reuse instead of writing new ones.
- The existing database structure, if this feature needs to persist anything.
- The existing authentication and authorization system, if this feature is user-scoped.
- Dependencies already installed, so you don't add a library that duplicates one.
- The existing test setup and conventions.

Only start writing code once you understand the above. If the application
already implements part of this feature, extend it rather than replacing it.

## Implementation Instructions

1. Take the set of work items belonging to one nominated release as input, and require each item to carry a shipped marker before it is eligible. Unreleased and reverted work must be excluded at the input stage, not filtered out of the prose afterwards.
2. Rewrite each item as the outcome a customer notices rather than the change that was made, and keep a link from every drafted line back to the underlying item so a reviewer can check it.
3. Group related items under headings the reader would recognise, and keep fixes as their own visible section rather than absorbing them into a feature summary.
4. Pass the app's current product and feature names in as fixed terms the draft must reproduce exactly, and flag any name in the draft that does not match the product's own vocabulary.
5. Create the changelog in draft state within the app's existing publishing workflow, with no automatic publish. This brief drafts release notes only; the public changelog page, its feed, and its notifications belong to whatever already renders them.

## UI and UX Requirements

Match the application's existing design system exactly. Reuse its components,
spacing, and typography. This feature should look like it was always there.

## Responsive Requirements

Works on mobile, tablet, and desktop. Touch targets are large enough to hit on a
phone, and nothing overflows horizontally at 320px.

## Accessibility Requirements

- Fully keyboard navigable.
- Correct semantic elements and ARIA roles.
- Visible focus states.
- Meets WCAG AA contrast.
- Dynamic changes are announced to screen readers.
- Respects prefers-reduced-motion.

## Edge Cases

- Security work must be summarised at the level the company has agreed to disclose and never in detail that describes the vulnerability or how it was reached. Exclude the underlying items from the input rather than trusting the draft to be discreet.
- Grouping is where important fixes disappear. A data-loss or billing fix must appear as its own line, however small the change was, and never be rolled into a sentence about a feature.
- Implementation language is meaningless to customers. A line that names a migration, a service, or a refactor without saying what changed for the reader must be dropped or rewritten.
- Product names must survive verbatim. A draft that renames a feature, expands an abbreviation, or corrects capitalisation creates a name that does not exist in the interface.
- Nothing publishes without review. A drafted changelog is customer communication and requires a person to read it and press publish.
- Work items are written by engineers for engineers and may contain internal customer names, ticket references, or partner details. Strip these before generation.
- A refusal, timeout, or truncated response must leave the previous draft intact rather than replacing it with a partial one.
- Regenerating a draft must not silently discard edits a human has already made. Offer the new version alongside rather than overwriting.

## Testing

Exercise the feature end to end in the running application. Cover every edge case
above, then run the existing test suite and confirm nothing regressed.

## Acceptance Criteria

- [ ] Only items marked as shipped in the nominated release are eligible inputs.
- [ ] Every drafted line links back to the underlying work item.
- [ ] Each entry describes a customer-visible outcome rather than an implementation detail.
- [ ] Fixes appear as their own visible section and are never absorbed into feature summaries.
- [ ] Product and feature names in the draft match the product exactly, with mismatches flagged.
- [ ] Internal, security-sensitive, and unreleased detail is excluded before generation.
- [ ] The changelog stays in draft until a person publishes it, and regeneration never overwrites human edits.
- [ ] The feature matches the existing design system.
- [ ] No existing functionality is broken.

## Adaptation Rules

- Match the existing design system. Do not introduce a new colour palette,
  spacing scale, or component library.
- Reuse existing components and utilities wherever they fit.
- Follow the naming, file layout, and code style already present.
- Do not upgrade, replace, or remove existing dependencies to make this
  feature fit. Adapt the feature to the app, not the app to the feature.
- Do not break existing functionality. If a change is genuinely required in
  existing code, make the smallest one that works and say so.
- If something in these instructions conflicts with how the application is
  built, follow the application and explain the deviation.

## Final Verification

Before you report the work as done:

1. Re-read the acceptance criteria above and check each one against what you
   actually built.
2. Run the application and exercise the feature end to end.
3. Run the existing test suite and confirm you have broken nothing.
4. Check the feature on mobile, tablet, and desktop widths.
5. Check keyboard navigation and focus handling.
6. Summarize what changed: files added, files modified, and anything you
   deliberately did differently because of how this application is built.

If any acceptance criterion is unmet, fix it before reporting completion.
