<type>(<scope>): <subject>
<type>: The type of change (e.g.,feat,fix,docs, etc.).<scope>: (optional) The specific part of the project that is affected (e.g., a module, file, or feature).<subject>: A brief description of the change in the present tense.
feat: add CLI
^--^ ^------^
| |
| +-> Summary in present tense.
|
+-------> Type: chore, docs, feat, fix, refactor, style, or test.
- Purpose: Introduces a new feature or enhancement that affects the user-facing functionality.
- Example: feat: add dark mode support
- Use Case: Adding a new feature to the application that changes how users interact with it.
- Purpose: Corrects a bug or an error that affects the user experience or application behavior.
- Example: fix: correct login error for users with special characters
- Use Case: Fixing a critical issue that impacts the functionality or user experience.
- Purpose: Updates or improves the documentation, including README files, comments, and other documentation-related files.
- Example: docs: update API documentation for new endpoint
- Use Case: Modifying documentation to reflect changes in the codebase or to improve clarity.
- Purpose: Changes that affect the formatting or style of the code but do not alter its functionality. This includes things like fixing linting issues or adding missing semi-colons.
- Example: style: fix indentation in user controller
- Use Case: Adjusting code formatting to conform to style guidelines without affecting the actual logic.
- Purpose: Modifies the code structure without changing its external behavior. This includes renaming variables, restructuring functions, or improving code readability.
- Example: refactor: rename 'temp' variable to 'temporaryValue'
- Use Case: Improving the internal code structure to make it more maintainable or understandable without changing the code's functionality.
- Purpose: Adds or updates tests, or modifies the test suite. This type does not change the production code.
- Example: test: add unit tests for user authentication
- Use Case: Enhancing test coverage or fixing issues in the test code itself.
- Purpose: Includes changes that do not fall into the other categories. Typically, these changes are related to build processes, configuration files, or other maintenance tasks.
- Example: chore: update build script for new version
- Use Case: Performing routine tasks that do not affect the application’s functionality or user-facing features.
-
Feature-Specific Scope
- Example:
feat(auth): add JWT authentication - Explanation: This commit adds a new feature (
feat) specifically related to theauth(authentication) module of the project.
- Example:
-
Component or Module Scope
- Example:
fix(database): resolve connection timeout issue - Explanation: This commit fixes an issue (
fix) within thedatabasecomponent, specifically addressing connection timeouts.
- Example:
-
File-Specific Scope
- Example:
docs(README): update installation instructions - Explanation: This commit updates documentation (
docs) specifically in theREADMEfile.
- Example:
-
Service-Specific Scope
- Example:
refactor(api): improve error handling - Explanation: This commit refactors code (
refactor) in theapiservice, focusing on improving error handling.
- Example:
-
UI Component Scope
- Example:
style(button): fix padding inconsistency - Explanation: This commit addresses a style issue (
style) specifically related to thebuttonUI component.
- Example:
-
Test Scope
- Example:
test(auth): add unit tests for login flow - Explanation: This commit adds tests (
test) specifically for theauthmodule, focusing on the login flow.
- Example:
- Use scope when a commit is specific to a certain area, module, or component within your project.
- It's optional, so if a commit is broad or affects multiple areas, you can omit the scope.
Write the commit message in the present tense as if you are describing what the commit does:
- Correct:
fix: correct login issue - Incorrect:
fixed: corrected login issue
Avoid vague commit messages like "update" or "changes":
- Avoid:
update: make changes - Correct:
refactor: improve error handling in authentication module
The imperative mood (commands) is preferred, as it reads like a set of instructions or a command:
- Correct:
add support for multi-language - Incorrect:
added support for multi-language