This document describes the commit message style used in this project. It's based on Conventional Commits but simplified for clarity and ease of use.
<type>: <description>
[optional body]
[optional footer]
Use these prefixes to categorize your commits:
Introduces new functionality or capabilities.
feat: Add diagram caching system
feat: Implement watch mode for auto-regeneration
feat: Add support for custom Mermaid themes
Fixes a bug or resolves an issue.
fix: Correct line number tracking in extractor
fix: Handle unicode characters in filenames
fix: Prevent crash when output directory is read-only
Changes to documentation only (README, comments, guides).
docs: Add comprehensive README
docs: Update installation instructions
docs: Add API documentation for file_handler module
Changes that don't affect code behavior (formatting, whitespace, etc.).
style: Format code with Black
style: Fix indentation in generator.py
style: Reorganize imports alphabetically
Restructuring code without changing functionality.
refactor: Extract validation logic into separate function
refactor: Simplify error handling in generator
refactor: Rename variables for clarity
Adding, modifying, or fixing tests.
test: Add integration tests for core functionality
test: Add edge case tests for extractor
test: Fix mocking in generator tests
Routine tasks, dependency updates, build configuration, etc.
chore: Add .gitignore for Python/UV project
chore: Add project dependencies
chore: Update requirements.txt versions
chore: Add pre-commit hooks
Changes that improve performance.
perf: Optimize markdown file scanning
perf: Add caching for repeated extractions
perf: Use multiprocessing for batch generation
Changes to build configuration or dependencies.
build: Update build script for production
build: Add Docker configuration
build: Configure CI/CD pipeline
Changes to CI/CD configuration.
ci: Add GitHub Actions workflow
ci: Configure automated testing
ci: Add code coverage reporting
- Aim for 50 characters or less
- Be concise but descriptive
- Use imperative mood: "Add feature" not "Added feature"
✅ Good:
feat: Add SVG output support
❌ Bad:
feat: I added support for generating diagrams in SVG format which allows for scalable vector graphics
Write as if giving a command or instruction.
✅ Good:
fix: Correct timezone handling
refactor: Extract helper function
docs: Update README with examples
❌ Bad:
fix: Corrected timezone handling
refactor: Extracted helper function
docs: Updated README with examples
The subject line is a title, not a sentence.
✅ Good:
feat: Add configuration file support
❌ Bad:
feat: Add configuration file support.
Use the body to explain why and what, not how.
feat: Add diagram caching system
Implements a caching mechanism to skip regeneration of unchanged
diagrams. This significantly improves performance for large
documentation projects where only a few files change.
The cache uses file modification timestamps and content hashes
to detect changes.
If introducing breaking changes, explain them clearly.
refactor: Change CLI argument format
BREAKING CHANGE: The --output flag now requires a directory path
instead of a filename pattern. Update your scripts accordingly.
Old: --output "diagrams/*.png"
New: --output "diagrams" --format png
Here are real commits from MermaidVisualizer:
feat: Implement core modules (extractor, generator, file_handler, cli) and comprehensive test suite
- Clear type
- Describes what was added
- Mentions all major components
docs: Add comprehensive README
- Simple and clear
- Type matches content perfectly
style: Format code with Black
- Specific tool mentioned
- Action is clear
test: Add integration tests for core functionality
- Specifies test type (integration)
- Clear scope
chore: Add .gitignore for Python/UV project
- Maintenance task
- Mentions project type for context
Update stuff
- No type prefix
- Vague description
- Not helpful for history
fix: fixed the bug
- Wrong mood (past tense)
- Doesn't describe what bug
- Not actionable
feat: Add the ability to generate diagrams from markdown files and also update the documentation and fix some bugs
- Too long
- Multiple concerns in one commit
- Should be split into separate commits
WIP
- Not descriptive
- Doesn't follow format
- Avoid committing WIP when possible
Not sure which type to use? Follow this tree:
Does it add new functionality?
├─ Yes → feat
└─ No
└─ Does it fix a bug?
├─ Yes → fix
└─ No
└─ Is it documentation only?
├─ Yes → docs
└─ No
└─ Is it formatting/style only?
├─ Yes → style
└─ No
└─ Does it change code structure?
├─ Yes → refactor
└─ No
└─ Is it tests?
├─ Yes → test
└─ No → chore
If changes span multiple files but serve one purpose, use one commit:
feat: Add user authentication
- Add login endpoint
- Create user model
- Add JWT token generation
- Update documentation
If changes must go together, keep them in one commit:
refactor: Rename function for clarity
Updated all call sites and tests to use new name.
chore: Update project configuration
- Add prettier config
- Update tsconfig.json
- Add ESLint rules
Update files
Fix things
Changes
feat: Add feature X, fix bug Y, update docs, refactor module Z
Fix: Split into 4 commits with appropriate types
feat: Fix typo in README
Fix: Should be docs: Fix typo in README
feat: Add new feature and fix bugs
Fix: Separate into feat and fix commits
WIP
wip: trying something
temp commit
Fix: Finish the work or use branches
- Scannable History: Quickly understand what changed
- Automated Changelogs: Tools can generate release notes automatically
- Semantic Versioning: Types map to version bumps (feat→minor, fix→patch)
- Better Collaboration: Team members understand changes at a glance
- Git Tools: Many tools parse these formats for enhanced features
Helps write conventional commits interactively:
npm install -g commitizen
git cz # Instead of git commitValidates commit messages:
npm install --save-dev @commitlint/cli @commitlint/config-conventionalEnforce style automatically:
# .git/hooks/commit-msg
#!/bin/bash
commit_msg=$(cat $1)
pattern='^(feat|fix|docs|style|refactor|test|chore|perf|build|ci):.+$'
if ! echo "$commit_msg" | grep -qE "$pattern"; then
echo "Error: Commit message doesn't follow conventional format"
echo "Format: <type>: <description>"
echo "Types: feat, fix, docs, style, refactor, test, chore, perf, build, ci"
exit 1
fi| Type | Description | Example |
|---|---|---|
feat |
New feature | feat: Add dark mode |
fix |
Bug fix | fix: Resolve memory leak |
docs |
Documentation | docs: Update API guide |
style |
Formatting | style: Format with Black |
refactor |
Code restructuring | refactor: Extract helper |
test |
Tests | test: Add unit tests |
chore |
Maintenance | chore: Update dependencies |
perf |
Performance | perf: Optimize queries |
build |
Build system | build: Update webpack |
ci |
CI/CD | ci: Add GitHub Actions |
Save this as .gitmessage and configure Git to use it:
# <type>: <subject> (Max 50 chars)
# <body> (Wrap at 72 chars)
# <footer>
# Type can be:
# feat: New feature
# fix: Bug fix
# docs: Documentation changes
# style: Code style/formatting
# refactor: Code refactoring
# test: Tests
# chore: Maintenance
# perf: Performance improvements
# build: Build system changes
# ci: CI/CD changes
#
# Subject line: Use imperative mood ("Add" not "Added")
# Body: Explain what and why vs. how
# Footer: Reference issues, breaking changes
Configure Git to use it:
git config --global commit.template ~/.gitmessageThe Golden Rules:
- Use a type prefix
- Keep subject under 50 chars
- Use imperative mood
- Don't end with period
- Add body for complex changes
- One logical change per commit
Following this style makes your Git history a powerful tool for understanding project evolution, debugging issues, and collaborating effectively.