| name | git-workflow-standards |
| description | Automatically applies when working with git. Ensures conventional commits, branch naming, PR templates, release workflow, and version control best practices. |
| category | velocity |
Git Workflow Standards
When working with git, follow these patterns for consistent, professional version control.
Trigger Keywords: git, commit, branch, pull request, PR, merge, release, version control, conventional commits, semantic versioning
Agent Integration: Used by backend-architect, devops-engineer, release-manager
✅ Correct Pattern: Conventional Commits
feat(auth): add JWT authentication
feat(api): add user profile endpoint
feat: implement password reset flow
fix(database): resolve connection pool leak
fix(api): correct status code for validation errors
fix: handle null values in user input
docs(readme): update installation instructions
docs: add API documentation
docs(contributing): add code review guidelines
perf(query): optimize user search query
perf: reduce memory usage in data processing
refactor(models): simplify user model structure
refactor: extract common validation logic
feat(api)!: change response format to JSON:API spec
fix(auth)!: remove deprecated login endpoint
feat(payments): add Stripe integration
Implement Stripe payment processing with webhooks
for subscription management.
BREAKING CHANGE: Payment API now requires Stripe account
Closes
Branch Naming Convention
git checkout -b feature/user-authentication
git checkout -b feature/add-search-endpoint
git checkout -b feature/implement-caching
git checkout -b bugfix/fix-login-redirect
git checkout -b bugfix/resolve-memory-leak
git checkout -b bugfix/correct-email-validation
git checkout -b hotfix/critical-security-patch
git checkout -b hotfix/fix-payment-processing
git checkout -b release/v1.2.0
git checkout -b release/v2.0.0-beta.1
git checkout -b docs/update-api-reference
git checkout -b docs/add-deployment-guide
git checkout -b feature/123-user-profile
git checkout -b bugfix/456-fix-crash
Pull Request Template
# .github/pull_request_template.md
## Description
Brief description of what this PR does.
Fixes #(issue)
## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring
## Changes Made
- Change 1: Description
- Change 2: Description
- Change 3: Description
## Testing
### Test Plan
Describe how you tested these changes:
1. Step 1
2. Step 2
3. Step 3
### Test Results
- [ ] All existing tests pass
- [ ] New tests added and passing
- [ ] Manual testing completed
## Checklist
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published
## Screenshots (if applicable)
Add screenshots here if UI changes were made.
## Additional Notes
Any additional information that reviewers should know.
## Breaking Changes
If this PR introduces breaking changes, describe them here and update CHANGELOG.md.
Commit Message Template
Release Workflow
git checkout -b release/v1.2.0
cat >> CHANGELOG.md << EOF
## [1.2.0] - 2025-01-15
### Added
- New feature 1
- New feature 2
### Changed
- Modified behavior 1
### Fixed
- Bug fix 1
- Bug fix 2
### Security
- Security fix 1
EOF
git add .
git commit -m "chore(release): bump version to 1.2.0"
git checkout main
git merge release/v1.2.0
git tag -a v1.2.0 -m "Release version 1.2.0"
git push origin v1.2.0
git branch -d release/v1.2.0
git push origin --delete release/v1.2.0
GitHub Actions for Release
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install build twine
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details.
draft: false
prerelease: false
CHANGELOG Format
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Features added but not yet released
### Changed
- Changes in existing functionality
### Deprecated
- Soon-to-be removed features
### Removed
- Removed features
### Fixed
- Bug fixes
### Security
- Vulnerability fixes
## [1.2.0] - 2025-01-15
### Added
- JWT authentication for API endpoints
- User profile endpoint with avatar support
- Rate limiting middleware
### Changed
- Updated Pydantic to v2.5.0
- Improved error messages in validation
### Fixed
- Fixed memory leak in database connection pool
- Corrected timezone handling in timestamps
### Security
- Updated dependencies to fix CVE-2024-1234
## [1.1.0] - 2025-01-01
### Added
- Initial API implementation
- Database migrations with Alembic
- User authentication
[Unreleased]: https://github.com/user/repo/compare/v1.2.0...HEAD
[1.2.0]: https://github.com/user/repo/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/user/repo/releases/tag/v1.1.0
Git Hooks
echo "Running pre-commit checks..."
echo "Running ruff..."
ruff check .
if [ $? -ne 0 ]; then
echo "Ruff checks failed. Please fix linting errors."
exit 1
fi
echo "Running black..."
black --check .
if [ $? -ne 0 ]; then
echo "Code formatting issues found. Run: black ."
exit 1
fi
echo "Running mypy..."
mypy .
if [ $? -ne 0 ]; then
echo "Type checking failed. Please fix type errors."
exit 1
fi
echo "Running tests..."
pytest tests/ -v
if [ $? -ne 0 ]; then
echo "Tests failed. Please fix failing tests."
exit 1
fi
echo "All pre-commit checks passed!"
exit 0
Pre-commit Configuration
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: 24.1.0
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: [types-all]
GitIgnore Template
# .gitignore for Python projects
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# Virtual environments
venv/
env/
ENV/
.venv
# IDE
.vscode/
.idea/
*.swp
*.swo
*~
# Testing
.pytest_cache/
.coverage
htmlcov/
.tox/
# Environment
.env
.env.local
.env.*.local
# Logs
*.log
# Database
*.db
*.sqlite3
# OS
.DS_Store
Thumbs.db
# Project specific
/data/
/tmp/
❌ Anti-Patterns
git commit -m "fix stuff"
git commit -m "update code"
git commit -m "changes"
git commit -m "fix(auth): resolve JWT token expiration issue"
git commit -m "feat(api): add pagination to user list endpoint"
git checkout main
git commit -m "quick fix"
git checkout -b bugfix/fix-issue
git commit -m "fix: resolve issue"
git add .
git commit -m "add feature and fix bugs and update docs"
git add feature.py
git commit -m "feat: add new feature"
git add bugfix.py
git commit -m "fix: resolve bug"
git add docs/
git commit -m "docs: update documentation"
git checkout -b my-changes
git checkout -b fix
git checkout -b update-stuff
git checkout -b feature/add-authentication
git checkout -b bugfix/fix-validation-error
Best Practices Checklist
- ✅ Use conventional commit format
- ✅ Follow branch naming convention
- ✅ Create descriptive PR descriptions
- ✅ Keep commits small and focused
- ✅ Write commits in imperative mood
- ✅ Reference issues in commits
- ✅ Use semantic versioning
- ✅ Maintain CHANGELOG.md
- ✅ Set up pre-commit hooks
- ✅ Review your own code before requesting review
- ✅ Keep PR size manageable (<400 lines)
- ✅ Squash/rebase before merging
Auto-Apply
When working with git:
- Use conventional commit format:
type(scope): description
- Create branch with type prefix:
feature/, bugfix/
- Write descriptive PR descriptions with checklist
- Update CHANGELOG.md for releases
- Tag releases with semantic versions
- Set up pre-commit hooks
- Keep commits focused and atomic
Related Skills
code-review-framework - For PR reviews
python-packaging - For releases
dependency-management - For version management