Implements a new `/core:commit` command that analyzes staged changes to generate a conventional commit message. The command supports three main modes of operation: - `/core:commit`: Automatically generates a commit message based on the content of the staged files. - `/core:commit "custom message"`: Uses the provided string as the full commit message. - `/core:commit --amend`: Amends the last commit with the new message. Message generation includes several heuristics: - **Commit Type:** Determined by file paths (e.g., `_test.go` -> `test`) and diff content (e.g., keywords like `fix` or `refactor`). - **Scope:** Inferred from the most common directory name among the staged files. - **Summary:** Extracted from function or class names in the diff, or defaults to a file-based summary. - **Co-Author:** A `Co-Authored-By` trailer is automatically appended. This feature streamlines the development workflow by automating the creation of descriptive and conventional commit messages.
1.4 KiB
1.4 KiB
| name | plugin | description | args | flags | hooks | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| commit | code | Generate a conventional commit message for staged changes | [message] |
|
|
Smart Commit
Generate a conventional commit message for staged changes.
Usage
Generate message automatically:
/core:commit
Provide a custom message:
/core:commit "feat(auth): add token validation"
Amend the previous commit:
/core:commit --amend
Behavior
- Analyze Staged Changes: Examines the
git diff --stagedto understand the nature of the changes. - Generate Conventional Commit Message:
feat: For new files, functions, or features.fix: For bug fixes.refactor: For code restructuring without changing external behavior.docs: For changes to documentation.test: For adding or modifying tests.chore: For routine maintenance tasks.
- Determine Scope: Infers the scope from the affected module's file paths (e.g.,
auth,payment,ui). - Add Co-Authored-By Trailer: Appends
Co-Authored-By: Claude <noreply@anthropic.com>to the commit message.
Message Generation Example
feat(auth): add JWT token validation
- Add validateToken() function
- Add token expiry check
- Add unit tests for validation
Co-Authored-By: Claude <noreply@anthropic.com>