ProcessWire
Recipes_

commit-generator

Overview

Automates the creation of semantic git commits by analyzing file changes, grouping them by context, and applying conventional commit standards.

Workflow

1. Trigger Check

Activate only if the user request contains:

  • “generate commit message”
  • “COMMIT”

2. Analysis & Grouping

Inspect repo state via git diff --cached --name-status and git status --porcelain. Group files by logic:

Path/TypeCategoryGrouping Logic
src/components/UIFeature/Component name
src/pages/PagesRoute name
src/content/ContentCollection type
src/styles/StylesGlobal or Tailwind config
public/AssetsStatic assets
*.config.*ConfigConfiguration updates
package*.jsonDepsPackage management
README.mdDocsDocumentation

3. Message Formatting

Format: type(scope): subject (lowercase, concise).

PrefixUse CaseExample
feat:New featuresfeat(header): add mobile navigation
fix:Bug fixesfix(auth): resolve login timeout
perf:Performanceperf(image): optimize hero banner
docs:Documentationdocs: update installation guide
style:Formattingstyle: fix indentation
refactor:Code structurerefactor: simplify data fetching
test:Teststest: add unit tests for user
chore:Maintenancechore: update dependencies

4. Interactive Confirmation

Present the plan to the user:

Proposed Commits:

  1. feat(blog): add new post layout
    • src/pages/blog/[slug].astro
    • src/styles/blog.css
  2. chore: update tailwind
    • package.json
    • pnpm-lock.yaml

“Would you like to proceed with these commits? [y/n/edit]“

5. Execution Strategy

Handle user response:

  • [n]: Stop and ask for clarification.
  • [edit]: Allow modification of groups or messages.
  • [y]: Execute sequentially for each group:
    1. git add [specific_files]
    2. git commit -m "[message]"
    3. Output: ” Committed: [message]”

Final Output: ”🎉 All changes committed successfully.”