|
| 1 | +# Claude Command: Commit |
| 2 | + |
| 3 | +This command helps you create well-formatted commits with conventional commit messages and emoji. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +To create a commit, just type: |
| 8 | +``` |
| 9 | +/commit |
| 10 | +``` |
| 11 | + |
| 12 | +Or with options: |
| 13 | +``` |
| 14 | +/commit --no-verify |
| 15 | +``` |
| 16 | + |
| 17 | +## What This Command Does |
| 18 | + |
| 19 | +1. Unless specified with `--no-verify`, automatically runs pre-commit checks: |
| 20 | + - `cargo clippy` to ensure code quality |
| 21 | + - `cargo check` to verify the build succeeds |
| 22 | + - `cargo fmt --check` to ensure consistent code formatting |
| 23 | +2. Checks which files are staged with `git status` |
| 24 | +3. If 0 files are staged, automatically adds all modified and new files with `git add` |
| 25 | +4. Performs a `git diff` to understand what changes are being committed |
| 26 | +5. Analyzes the diff to determine if multiple distinct logical changes are present |
| 27 | +6. If multiple distinct changes are detected, suggests breaking the commit into multiple smaller commits |
| 28 | +7. For each commit (or the single commit if not split), creates a commit message using emoji conventional commit format |
| 29 | + |
| 30 | +## Best Practices for Commits |
| 31 | + |
| 32 | +- **Verify before committing**: Ensure code is linted, builds correctly, and documentation is updated |
| 33 | +- **Atomic commits**: Each commit should contain related changes that serve a single purpose |
| 34 | +- **Split large changes**: If changes touch multiple concerns, split them into separate commits |
| 35 | +- **Conventional commit format**: Use the format `<type>: <description>` where type is one of: |
| 36 | + - `feat`: A new feature |
| 37 | + - `fix`: A bug fix |
| 38 | + - `docs`: Documentation changes |
| 39 | + - `style`: Code style changes (formatting, etc) |
| 40 | + - `refactor`: Code changes that neither fix bugs nor add features |
| 41 | + - `perf`: Performance improvements |
| 42 | + - `test`: Adding or fixing tests |
| 43 | + - `chore`: Changes to the build process, tools, etc. |
| 44 | +- **Present tense, imperative mood**: Write commit messages as commands (e.g., "add feature" not "added feature") |
| 45 | +- **Concise first line**: Keep the first line under 72 characters |
| 46 | +- **Emoji**: Each commit type is paired with an appropriate emoji: |
| 47 | + - `feat`: ✨ New feature |
| 48 | + - `fix`: 🐛 Bug fix |
| 49 | + - `docs`: 📝 Documentation |
| 50 | + - `style`: 💄 Formatting/style |
| 51 | + - `refactor`: ♻️ Code refactoring |
| 52 | + - `perf`: ⚡️ Performance improvements |
| 53 | + - `test`: ✅ Tests |
| 54 | + - `chore`: 🔧 Tooling, configuration |
| 55 | + - `ci`: 🚀 CI/CD improvements |
| 56 | + - `revert`: 🗑️ Reverting changes |
| 57 | + - `test`: 🧪 Add a failing test |
| 58 | + - `fix`: 🚨 Fix compiler/linter warnings |
| 59 | + - `fix`: 🔒️ Fix security issues |
| 60 | + - `chore`: 👥 Add or update contributors |
| 61 | + - `refactor`: 🚚 Move or rename resources |
| 62 | + - `refactor`: 🏗️ Make architectural changes |
| 63 | + - `chore`: 🔀 Merge branches |
| 64 | + - `chore`: 📦️ Add or update compiled files or packages |
| 65 | + - `chore`: ➕ Add a dependency |
| 66 | + - `chore`: ➖ Remove a dependency |
| 67 | + - `chore`: 🌱 Add or update seed files |
| 68 | + - `chore`: 🧑💻 Improve developer experience |
| 69 | + - `feat`: 🧵 Add or update code related to multithreading or concurrency |
| 70 | + - `feat`: 🔍️ Improve SEO |
| 71 | + - `feat`: 🏷️ Add or update types |
| 72 | + - `feat`: 💬 Add or update text and literals |
| 73 | + - `feat`: 🌐 Internationalization and localization |
| 74 | + - `feat`: 👔 Add or update business logic |
| 75 | + - `feat`: 📱 Work on responsive design |
| 76 | + - `feat`: 🚸 Improve user experience / usability |
| 77 | + - `fix`: 🩹 Simple fix for a non-critical issue |
| 78 | + - `fix`: 🥅 Catch errors |
| 79 | + - `fix`: 👽️ Update code due to external API changes |
| 80 | + - `fix`: 🔥 Remove code or files |
| 81 | + - `style`: 🎨 Improve structure/format of the code |
| 82 | + - `fix`: 🚑️ Critical hotfix |
| 83 | + - `chore`: 🎉 Begin a project |
| 84 | + - `chore`: 🔖 Release/Version tags |
| 85 | + - `wip`: 🚧 Work in progress |
| 86 | + - `fix`: 💚 Fix CI build |
| 87 | + - `chore`: 📌 Pin dependencies to specific versions |
| 88 | + - `ci`: 👷 Add or update CI build system |
| 89 | + - `feat`: 📈 Add or update analytics or tracking code |
| 90 | + - `fix`: ✏️ Fix typos |
| 91 | + - `revert`: ⏪️ Revert changes |
| 92 | + - `chore`: 📄 Add or update license |
| 93 | + - `feat`: 💥 Introduce breaking changes |
| 94 | + - `assets`: 🍱 Add or update assets |
| 95 | + - `feat`: ♿️ Improve accessibility |
| 96 | + - `docs`: 💡 Add or update comments in source code |
| 97 | + - `db`: 🗃️ Perform database related changes |
| 98 | + - `feat`: 🔊 Add or update logs |
| 99 | + - `fix`: 🔇 Remove logs |
| 100 | + - `test`: 🤡 Mock things |
| 101 | + - `feat`: 🥚 Add or update an easter egg |
| 102 | + - `chore`: 🙈 Add or update .gitignore file |
| 103 | + - `test`: 📸 Add or update snapshots |
| 104 | + - `experiment`: ⚗️ Perform experiments |
| 105 | + - `feat`: 🚩 Add, update, or remove feature flags |
| 106 | + - `ui`: 💫 Add or update animations and transitions |
| 107 | + - `refactor`: ⚰️ Remove dead code |
| 108 | + - `feat`: 🦺 Add or update code related to validation |
| 109 | + - `feat`: ✈️ Improve offline support |
| 110 | + |
| 111 | +## Guidelines for Splitting Commits |
| 112 | + |
| 113 | +When analyzing the diff, consider splitting commits based on these criteria: |
| 114 | + |
| 115 | +1. **Different concerns**: Changes to unrelated parts of the codebase |
| 116 | +2. **Different types of changes**: Mixing features, fixes, refactoring, etc. |
| 117 | +3. **File patterns**: Changes to different types of files (e.g., source code vs documentation) |
| 118 | +4. **Logical grouping**: Changes that would be easier to understand or review separately |
| 119 | +5. **Size**: Very large changes that would be clearer if broken down |
| 120 | + |
| 121 | +## Examples |
| 122 | + |
| 123 | +Good commit messages: |
| 124 | +- feat: ✨ add user authentication system |
| 125 | +- fix: 🐛 resolve memory leak in rendering process |
| 126 | +- docs: 📝 update API documentation with new endpoints |
| 127 | +- refactor: ♻️ simplify error handling logic in parser |
| 128 | +- fix: 🚨 resolve linter warnings in component files |
| 129 | +- chore: 🧑💻 improve developer tooling setup process |
| 130 | +- feat: 👔 implement business logic for transaction validation |
| 131 | +- fix: 🩹 address minor styling inconsistency in header |
| 132 | +- fix: 🚑️ patch critical security vulnerability in auth flow |
| 133 | +- style: 🎨 reorganize component structure for better readability |
| 134 | +- fix: 🔥 remove deprecated legacy code |
| 135 | +- feat: 🦺 add input validation for user registration form |
| 136 | +- fix: 💚 resolve failing CI pipeline tests |
| 137 | +- feat: 📈 implement analytics tracking for user engagement |
| 138 | +- fix: 🔒️ strengthen authentication password requirements |
| 139 | +- feat: ♿️ improve form accessibility for screen readers |
| 140 | + |
| 141 | +Example of splitting commits: |
| 142 | +- First commit: ✨ feat: add new solc version type definitions |
| 143 | +- Second commit: 📝 docs: update documentation for new solc versions |
| 144 | +- Third commit: 🔧 chore: update package.json dependencies |
| 145 | +- Fourth commit: 🏷️ feat: add type definitions for new API endpoints |
| 146 | +- Fifth commit: 🧵 feat: improve concurrency handling in worker threads |
| 147 | +- Sixth commit: 🚨 fix: resolve linting issues in new code |
| 148 | +- Seventh commit: ✅ test: add unit tests for new solc version features |
| 149 | +- Eighth commit: 🔒️ fix: update dependencies with security vulnerabilities |
| 150 | + |
| 151 | +## Command Options |
| 152 | + |
| 153 | +- `--no-verify`: Skip running the pre-commit checks (`cargo check`, `cargo clippy`, `cargo fmt --check`) |
| 154 | + |
| 155 | +## Important Notes |
| 156 | + |
| 157 | +- By default, pre-commit checks (`cargo check`, `cargo clippy`, `cargo fmt --check`) will run to ensure code quality |
| 158 | +- If these checks fail, you'll be asked if you want to proceed with the commit anyway or fix the issues first |
| 159 | +- If specific files are already staged, the command will only commit those files |
| 160 | +- If no files are staged, it will automatically stage all modified and new files |
| 161 | +- The commit message will be constructed based on the changes detected |
| 162 | +- Before committing, the command will review the diff to identify if multiple commits would be more appropriate |
| 163 | +- If suggesting multiple commits, it will help you stage and commit the changes separately |
| 164 | +- Always reviews the commit diff to ensure the message matches the changes |
0 commit comments