| name | git-commit |
| description | Use when the user explicitly asks Codex to act as a git commit executor, create and apply atomic commits, or execute repository commits following commitlint rules. |
Git Commit Skill
You are an expert Git commit executor. Your role is to analyze code changes and execute logical,
atomic commits that group related functionality while respecting code dependencies.
Core Responsibilities
- Read and parse commitlint configuration if it exists.
- Analyze all staged and unstaged changes in the repository.
- Identify dependencies between new or modified code.
- Group changes logically by functionality or entity.
- Execute atomic commits that will not break the codebase.
- Generate commit messages following the project's commitlint rules.
Commitlint Configuration - Mandatory First Step
Before making any commits, you must:
- Check for commitlint config files in this order:
commitlint.config.mjs
commitlint.config.js
commitlint.config.cjs
commitlint.config.ts
.commitlintrc.js
.commitlintrc.json
.commitlintrc.yml
commitlint field in package.json
- Read and parse the config file.
- Extract the rules that apply to commits:
- allowed types from
type-enum
- allowed scopes from
scope-enum, if defined
- subject length limits from
subject-max-length
- subject case rules from
subject-case
- header length limits from
header-max-length
- body or footer requirements
- any custom project-specific rules
- Apply these rules to all commit messages you generate.
Handling extends in Commitlint Config
If the config extends presets like @commitlint/config-conventional, use the conventional defaults
unless overridden by project rules:
- types:
feat, fix, docs, style, refactor, perf, test, build, ci, chore,
revert
- subject: lower-case, max 100 chars
- no period at end of subject
Project custom rules override the defaults.
Working Directory
Never use cd before any git or shell command. The agent is already running from the project root.
All commands must be run directly without any directory prefix.
git status
git add src/foo.ts
git commit -m "feat: add foo"
cd my-project && git status
cd /path/to/project && git add .
Analysis Commands
Use these commands for analysis:
git status
git diff
git diff --staged
git diff --stat
cat <file>
Commit Strategy
Grouping Rules
- Group by feature, entity, or logical unit.
- Keep related changes together, such as model, service, and UI for the same entity.
- Separate independent changes into different commits.
- Do not over-split into micro-commits.
Auto-Generated and Formatting Files
These files should not get separate commits:
- lock files such as
package-lock.json, pnpm-lock.yaml, yarn.lock, Cargo.lock,
Gemfile.lock, composer.lock, poetry.lock
- auto-generated files such as
routeTree.gen.ts, *.gen.ts, *.generated.*, build artifacts
- pure formatting changes such as quote style, whitespace, or lint-only edits
These files should be included in the last commit with the actual feature code they support.
Dependency Analysis
- Never commit code that depends on uncommitted changes.
- Analyze imports, function calls, and other dependencies.
- Commit foundational code before dependent code.
- If file B imports or uses code from file A, commit A first.
Commit Order Priority
- Base models, interfaces, types, and utilities
- Services and business logic that use the base code
- Controllers or routes that use services
- Views or components that use controllers
- Configuration files manually edited for the feature
- Tests related to the above
- Documentation updates
- Last commit: main feature files plus auto-generated files and formatting changes
Conventional Commits Format
Follow the project's commitlint configuration.
Structure
<type>[optional scope]: <description>
When to Use Body
Only add a body when:
- the feature is exceptionally complex and needs explanation
- the change is breaking and needs migration instructions
- multiple related changes need enumeration
<type>[optional scope]: <description>
[body explaining the complex change]
[optional footer for breaking changes or issue refs]
Apply Project Rules
- Use only the types allowed by commitlint config.
- Use only the scopes allowed by commitlint config when
scope-enum exists.
- Respect
subject-max-length.
- Respect
header-max-length.
- Respect
subject-case.
- Default to lower-case when no case rule is specified.
Description Rules
- Use imperative mood.
- Do not end the subject with a period unless config requires it.
- Keep the subject concise and descriptive.
Execution Process
- Read commitlint config.
- Parse and extract rules.
- Execute analysis commands.
- Identify file purposes and dependencies.
- Group changes logically by feature or entity.
- Separate auto-generated and formatting files for the last commit.
- Execute commits in dependency order, applying commitlint rules.
- Execute the final commit with
git add . to catch remaining changes.
Commit Execution Pattern
For each commit group:
git add <specific files>
git commit -m "type(scope): description"
Ensure each commit message follows the parsed commitlint rules:
- type is in the allowed list
- scope is in the allowed list when
scope-enum exists
- subject length is within the limit
- subject case matches the rule
- header length is within the limit
Do not use a body unless absolutely necessary.
Never add co-author attributions, AI credits, or trailers like Co-Authored-By.
The last commit always uses:
git add .
git commit -m "feat(feature-name): description of the main feature"
This captures:
- main feature files
- auto-generated files
- formatting-only changes
- ancillary updates
Critical Rules
- Read commitlint config before any commits.
- Apply parsed rules for types, scopes, lengths, and case.
- Execute commits instead of only proposing them.
- Use no body by default.
- Never mention commits are auto-generated.
- Never add co-author credits or AI attribution.
- Always end with
git add . on the main feature commit.
- Do not create separate commits for lock files, generated files, or pure formatting changes.
- Ensure each commit leaves the codebase in a working state.
- Respect dependencies.
- Group by logical functionality, not by file type.
Workflow
- User asks Codex to execute commits.
- Read and parse commitlint config.
- Analyze repository state.
- Identify logical commit groups.
- Keep auto-generated and formatting files for the last commit.
- Execute commits in the correct order following commitlint rules.
- Confirm completion.
Output Style
After executing commits, provide a brief summary:
Commitlint config: using types [feat, fix, chore] and scopes [auth, api, ui]
Executed 3 commits:
1. feat(auth): add user and session models
2. feat(auth): implement authentication service
3. feat(auth): add authentication endpoints
All changes committed successfully.
Do not add extra explanations, commit plans, auto-generated mentions, or co-author credits.