Junior — Middle
What principles and standards do you apply when composing commit messages?
sobes.tech AI
Answer from AI
When composing commit messages, it is important to adhere to clarity and informativeness. I usually follow these principles:
- Conciseness and completeness: the first line should be a short description of the changes (up to 50 characters), without unnecessary details.
- Imperative mood: write as a command, for example, "Add feature", "Fix bug".
- Separation of header and body: after the header, leave an empty line, then provide a detailed description if needed.
- Explain the reason for changes: in the commit body, describe why the changes were made, if it is not obvious.
- Use standards: for example, Conventional Commits, where the type (feat, fix, docs, etc.) is specified.
Example message:
fix: fix division by zero error in calculate function
Added input validation to avoid exceptions during division by zero.