Commit Change
Create a git commit following the project's commit message format.
When to Use
- •When asked to commit changes
- •After completing a feature or fix
- •When the user wants to save their work to git
Instructions
- •
Review Changes: First, run these commands in parallel:
- •
git statusto see all untracked files - •
git diffto see both staged and unstaged changes - •
git log -5 --onelineto see recent commit messages
- •
- •
Quality Checks: Before committing, verify code quality:
- •Run
npm run checkto verify the codebase (formatting, linting, type-checking) - •If check fails, run
npm run fixto automatically resolve issues - •Run
npm run buildto ensure all workspaces build successfully - •Run
npm run testif applicable to ensure tests pass
- •Run
- •
Draft Commit Message: Analyze the changes and draft a commit message using this format:
code<type>: <description> <body>
Types:
- •
feat: New end-user functionality or features - •
ui: User interface changes (layout, styling, components) - •
ux: User experience changes (interactions, flow improvements) - •
fix: Bug fixes for end-user issues - •
maintenance: Non-behavioral changes (scripts, configs, tooling) - •
dep: Dependency updates (add, remove, update packages) - •
docs: Documentation changes - •
refactor: Code restructuring without behavior change - •
test: Test-related changes
Body: 1-3 sentences describing what the changes do and why. Focus on the purpose and impact, not just what was changed.
- •
- •
IMPORTANT Restrictions:
- •DO NOT include AI attribution (no "🤖 Generated with Claude Code")
- •DO NOT include co-author tags (no "Co-Authored-By: Claude")
- •Keep the message concise and professional
- •Focus on the "why" rather than just the "what"
- •
Stage and Commit:
- •Add relevant untracked files to the staging area with
git add - •Write the commit message to
.git/COMMIT_EDITMSG:bashprintf "<type>: <description>\n\n<body>\n" > .git/COMMIT_EDITMSG
- •Create the commit using the message file:
bash
git commit -F .git/COMMIT_EDITMSG
- •Run
git statusafter the commit to verify success
- •Add relevant untracked files to the staging area with
- •
Handle Pre-commit Hooks: If the commit fails due to pre-commit hook changes:
- •Check authorship:
git log -1 --format='%an %ae' - •Check if pushed:
git statusshould show "Your branch is ahead" - •If both are true: amend the commit
- •Otherwise: create a NEW commit (never amend other developers' commits)
- •Check authorship:
- •
Commit Organization: Group related changes into logical commits:
- •Single feature/fix: One commit with all related files
- •Multiple unrelated changes: Create separate commits for each logical change
- •Don't separate a feature from its tests
- •Don't split configuration changes that are related
Examples
code
feat: add user authentication flow Implemented JWT-based authentication with login/logout endpoints and middleware for protected routes.
code
fix: resolve navigation routing issue Fixed a bug where navigation links were not updating the URL correctly in nested routes.
code
maintenance: add test scripts to package.json Added npm scripts for running tests in different modes to improve developer workflow.
Notes
- •DO NOT push to remote unless explicitly requested
- •Avoid using
git commit -ior other interactive flags - •If there are no changes, do not create an empty commit
- •Always verify that quality checks pass before committing
- •IMPORTANT IMPORTANT IMPORTANT IMPORTANT : Never include the User Story Number since there are duplicate