🚀 Clean Commit Messages: Why & How



This content originally appeared on DEV Community and was authored by Mhammed Talhaouy

Writing clear, structured commit messages makes collaboration smoother, code reviews easier, and project history understandable. Here’s a simple guide I follow:⁣

Commit Message Structure


<type>(<scope>): <short description>⁣



  • type → the kind of change⁣
  • scope → optional, the affected module⁣
  • description → concise summary (imperative mood)⁣ ⁣ ### Common Types⁣ ⁣
  • feat: → new features⁣
  • fix: → bug fixes⁣
  • chore: → maintenance, build updates, configs⁣
  • docs: → documentation⁣
  • refactor: → code improvements without changing behavior⁣
  • style: → formatting, linting, whitespace⁣
  • test: → adding/updating tests⁣ ⁣ Example:⁣ ⁣
feat(auth): add login with Google⁣
fix(api): handle null pointer on user fetch⁣
chore: update dependencies⁣



Best Practices

  1. Imperative tone – describe what the commit does:⁣ ✅ fix(ui): remove extra padding on button❌ fixed padding issue⁣ ⁣
  2. Keep subject short – ≤ 50 characters⁣ ⁣
  3. Use body for details – explain why, not just what:⁣ ⁣
   feat(auth): add password reset⁣
⁣
   - Added endpoint /auth/reset-password⁣
   - Updated email templates⁣
   - Closes #123⁣




✅ Clean commits = better teamwork & smoother code history! 🛠💡


This content originally appeared on DEV Community and was authored by Mhammed Talhaouy