Skip to content

Have OpenAI's Codex suggest commit messages#1984

Merged
Stephan202 merged 14 commits intomasterfrom
sschroevers/automate-commit-message-suggestions
Nov 22, 2025
Merged

Have OpenAI's Codex suggest commit messages#1984
Stephan202 merged 14 commits intomasterfrom
sschroevers/automate-commit-message-suggestions

Conversation

@Stephan202
Copy link
Member

@Stephan202 Stephan202 commented Nov 15, 2025

Suggested commit message:

Have OpenAI's Codex suggest commit messages (#1984)

This new GitHub Actions workflow upserts a pull request comment any time
the PR is updated, to suggest an appropriate commit message for the 
squash-and-merge workflow.

The workflow can also be triggered manually to simplify testing.

I tested part of this PR by temporarily changing the default branch (necessary because the new workflow doesn't exist on master yet) and running e.g.:

gh workflow run suggest-commit-message.yml --ref 'sschroevers/automate-commit-message-suggestions' -f pr_number=1963

Examples of generated commit messages:

This PR was largely created using Windsurf with the GPT-5-Codex model, with tweaks from my side.

@Stephan202 Stephan202 added the chore A task not related to code (build, formatting, process, ...) label Nov 15, 2025
@Stephan202 Stephan202 marked this pull request as draft November 15, 2025 21:55
@github-actions
Copy link

github-actions bot commented Nov 15, 2025

Suggested commit message:

Add workflow to suggest PR commit messages (#1984)

Introduce `.github/workflows/suggest-commit-message.yml` to resolve PR
metadata, run the Codex action, and post the formatted suggestion as a
pull request comment.

Automate commit message suggestions to reduce manual editing and keep
messaging consistent across pull requests.

Edit by Stephan: This comment was posted before I updated the marker string. Hence the second bot-generated comment further down. As you can see, that one has been edited by the bot quite a number of times.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

github-actions bot commented Nov 16, 2025

Suggested commit message:

Have OpenAI's Codex suggest commit messages (#1984)

Introduce a workflow that upserts a Codex-suggested commit message
comment when a pull request changes. It also allows manual runs to ease
testing for new changes.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202 Stephan202 force-pushed the sschroevers/automate-commit-message-suggestions branch from 9183931 to 68d7834 Compare November 16, 2025 13:02
@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

4 similar comments
@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link
Collaborator

@mohamedsamehsalah mohamedsamehsalah left a comment

Choose a reason for hiding this comment

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

🤖 🤖 🤖 🤖 🤖

Left some suggestions 🙌

(Am I a prompt engineer now? 👀)

image

6. For dependency upgrades in particular, *very precisely* follow the pattern of past commit messages: reuse the summary wording (only adjust version numbers) and list updated changelog, release note, and diff URLs in the body.
7. Don't hallucinate URLs, version numbers, or other factual information.
8. Never split URLs across multiple lines, even if they exceed 72 characters.
9. If the pull request description already contains a suitable commit message, prefer using that as-is.
Copy link
Collaborator

@mohamedsamehsalah mohamedsamehsalah Nov 17, 2025

Choose a reason for hiding this comment

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

Suggested change
9. If the pull request description already contains a suitable commit message, prefer using that as-is.
9. If the pull request description already contains a suitable commit message, consider using that as-is or as an inspiration for your generated message.

7. Don't hallucinate URLs, version numbers, or other factual information.
8. Never split URLs across multiple lines, even if they exceed 72 characters.
9. If the pull request description already contains a suitable commit message, prefer using that as-is.

Copy link
Collaborator

@mohamedsamehsalah mohamedsamehsalah Nov 17, 2025

Choose a reason for hiding this comment

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

Suggested change
11. Finally, consider adding a small description of work that is not relevant to the main PR changes, on a separate line as part of the commit message body, starting with "While here, " phrase. (i.e, "While here, fixed a typo in variable name.")

Copy link
Member Author

Choose a reason for hiding this comment

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

I fear that this will yield very low signal to noise; already I found the non-upgrade commit summaries "okay, not great". I'll think of a different way of phrasing this, but may leave it out; TBD.

Requirements:
1. Write the summary line in the imperative mood. Try not to exceed 80 characters.
2. End the summary line with the PR number in parentheses, i.e., " (#${prNumber})".
2. Wrap each body paragraph at 72 characters. Focus on the "what" and "why" rather than implementation details.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
2. Wrap each body paragraph at 72 characters. Focus on the "what" and "why" rather than implementation details.
2. Wrap each body paragraph at 72 characters. Focus on the "what" and "why" rather than implementation details. Unlike summary lines, message bodies are complete sentences that should end with a full stop.

Comment on lines +128 to +129
2. End the summary line with the PR number in parentheses, i.e., " (#${prNumber})".
2. Wrap each body paragraph at 72 characters. Focus on the "what" and "why" rather than implementation details.
Copy link
Collaborator

Choose a reason for hiding this comment

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

😄

Suggested change
2. End the summary line with the PR number in parentheses, i.e., " (#${prNumber})".
2. Wrap each body paragraph at 72 characters. Focus on the "what" and "why" rather than implementation details.
2. End the summary line with the PR number in parentheses, i.e., " (#${prNumber})".
3. Wrap each body paragraph at 72 characters. Focus on the "what" and "why" rather than implementation details.

Copy link
Member Author

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

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

Tnx for the review @mohamedsamehsalah! I'll circle back to this later, when I combine your suggestions and do some more tests.

7. Don't hallucinate URLs, version numbers, or other factual information.
8. Never split URLs across multiple lines, even if they exceed 72 characters.
9. If the pull request description already contains a suitable commit message, prefer using that as-is.

Copy link
Member Author

Choose a reason for hiding this comment

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

I fear that this will yield very low signal to noise; already I found the non-upgrade commit summaries "okay, not great". I'll think of a different way of phrasing this, but may leave it out; TBD.

Copy link
Member

@rickie rickie left a comment

Choose a reason for hiding this comment

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

Already saw some nice feedback from @mohamedsamehsalah . This looks really nice. Amazing way to use AI to automate some of the things we have to do!

Some further guidelines to help you craft good upgrade commit messages:
- Unless highly salient, don't summarize code changes made as part of the upgrade.
- Don't bother linking to anchors within changelogs or release notes; just link to the main page.
- For GitHub-hosted projects, always link to all relevant GitHub release pages, including those for intermediate versions.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- For GitHub-hosted projects, always link to all relevant GitHub release pages, including those for intermediate versions.
- For GitHub-hosted projects, always link to all relevant GitHub release pages, including those for intermediate versions, like milestones.

I know we mean that with intermediate versions, but noticed that the milestones from Spring were not added 🤔. So maybe we nudge it slightly more?

Copy link
Member Author

Choose a reason for hiding this comment

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

See the sentence below... 🙃. This doesn't help, apparently.

Copy link
Member

Choose a reason for hiding this comment

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

Lol, my bad 😂.

id: prompt
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
env:
PR_NUMBER: ${{ steps.pr-details.outputs.number }}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
PR_NUMBER: ${{ steps.pr-details.outputs.number }}
REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ steps.pr-details.outputs.number }}

return `${truncated}\n... (${limit} of ${lines.length} lines shown)`;
};

const env = process.env;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const env = process.env;
const env = process.env;
const repository = env.REPOSITORY;

const cleanedBody = (body || '').trim() || '<no pull request description>';

const instructions = `
You are an experienced maintainer helping to craft the squash commit message for PR #${prNumber} in the PicnicSupermarket/error-prone-support repository.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
You are an experienced maintainer helping to craft the squash commit message for PR #${prNumber} in the PicnicSupermarket/error-prone-support repository.
You are an experienced maintainer helping to craft the squash commit message for PR #${prNumber} in the ${repository} repository.

This new GitHub Actions workflow upserts a pull request comment any time
the PR is updated, to suggest an appropriate commit message for the
squash-and-merge workflow.

The workflow can also be triggered manually to simplify testing.
@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@sonarqubecloud
Copy link

@Stephan202
Copy link
Member Author

I tweaked a few things. Some aspects are still hit-or-miss. But will merge now to officially wrap this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore A task not related to code (build, formatting, process, ...)

Development

Successfully merging this pull request may close these issues.

4 participants