Skip to content

feat: draft chart changelogs with Claude Code#98

Draft
llewellyn-sl wants to merge 1 commit intomasterfrom
claude-changelog-hook-master
Draft

feat: draft chart changelogs with Claude Code#98
llewellyn-sl wants to merge 1 commit intomasterfrom
claude-changelog-hook-master

Conversation

@llewellyn-sl
Copy link
Copy Markdown
Contributor

Summary

This PR adds a local pre-commit hook that uses Claude Code to draft missing chart CHANGELOG.md entries before the existing changelog validation hook runs.

How it works

  • Adds a new local hook, draft-changelog-with-claude, ahead of check-changelog-updated in .pre-commit-config.yaml
  • The new hook inspects staged chart changes under charts/
  • For each chart with staged non-doc changes and no staged CHANGELOG.md update yet, it:
    • reads the chart version from Chart.yaml
    • collects the staged diff for that chart
    • sends the existing changelog context plus the staged diff to Claude Code in non-interactive mode
    • expects strict JSON output containing Keep a Changelog entries
    • inserts the generated entries into the current chart version block, or creates one if needed
    • stages the updated CHANGELOG.md
  • The existing check-changelog-updated.py hook remains the source of truth and still fails the commit if a required changelog update is missing

Behavior notes

  • The Claude hook only runs for changes under charts/
  • It skips charts that already have a staged CHANGELOG.md update
  • It is configured with require_serial: true so it runs deterministically before the validator
  • If the hook rewrites a changelog file, contributors should review the generated entry and rerun git commit
  • If Claude Code is unavailable or returns invalid output, the hook fails with an error instead of silently bypassing changelog generation

Docs

  • Updates CONTRIBUTING.md to mention the new draft-then-validate flow

Validation

  • python3 -m py_compile .github/scripts/draft_changelog_with_claude.py .github/scripts/check_changelog_updated.py
  • End-to-end dry run with a stub Claude command to verify that the draft hook stages CHANGELOG.md and the existing validator then passes

Comment thread .pre-commit-config.yaml

- repo: local
hooks:
- id: draft-changelog-with-claude
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I tried it and it works fine!

Maybe the only comment I'd make would be to move the new block in the precommit config file below the check-changelog-updated section, so that the check fails first, then Claude updates the changelog files, so the user is reminded to check what Claude produced? otherwise the check below would be useless
I'd like to test it for a few days with and without the changes and I'll let you know, thanks! 🙂

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.

2 participants