git-best-practices
Skill3 starsChanged 8 months agoCC0-1.0View on GitHub
Enforces Git workflow best practices including trunk-based development, conventional commits, atomic commits, small pull requests, and Git hooks. Use when choosing a branching strategy, writing commit messages, structuring pull requests, configuring Git hooks and CI pipelines, managing feature flags, or setting up semantic versioning automation.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- aksuharun/skillstheir own version, first seen May 28, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- aksuharun/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository48 other files it gives its agents.
- 3d-printingSkill
- app-securitySkill
- architecture-designSkill
- aws-genai-lensSkill
- aws-well-architected-frameworkSkill
- aws-well-architectedSkill
- azure-well-architectedSkill
- blog-post-with-diagramsSkill
- clean-architectureSkill
- clean-codeSkill
- databricks-genie-spaces-best-practicesSkill
- data-visualization-guideSkill
- design-an-interfaceSkill
- design-patternsSkill
- domain-driven-designSkill
- dry-principleSkill
- edit-articleSkill
- event-driven-designSkill
- git-guardrails-claude-codeSkill
- grill-meSkill
- hexagonal-architectureSkill
- improve-codebase-architectureSkill
- language-conventions-source-en-docs-brSkill
- learn-electronicsSkill
- linked-dataSkill
- microservices-skillSkill
- object-oriented-programmingSkill
- oop-design-patternsSkill
- oreilly-design-referenceSkill
- organize-docs-from-zipSkill
- prd-to-issuesSkill
- prd-to-planSkill
- project-context-syncSkill
- request-refactor-planSkill
- rfc2119Skill
- scaffold-exercisesSkill
- semverSkill
- setup-pre-commitSkill
- solid-principlesSkill
- tddSkill
- todoSkill
- triage-issueSkill
- ts-otp-awsSkill
- ubiquitous-languageSkill
- ux-design-principlesSkill
- write-a-prdSkill
- write-a-skillSkill
- yagni-principleSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 18 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈18
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
All developers collaborate on a single branch (trunk/main).
- Distinctive: line 32
SHOULD default to trunk-based development — DORA research confirms higher-performing organizations are more likely to use TBD
- Distinctive: line 33
MUST keep feature branches to 1–2 days maximum.
- Distinctive: line 34
MUST use feature flags to decouple deployment from release when features span multiple days
- Distinctive: line 56
MUST remove release toggles promptly after the feature is fully launched
- Distinctive: line 57
SHOULD track all active flags and assign cleanup owners
- Distinctive: line 95
Do not end the subject with a period
- Distinctive: line 102
MUST use imperative mood in subject: the commit message completes the sentence *"If applied, this commit will..."*
- Distinctive: line 103
MUST make each commit atomic — one logical change that compiles and passes tests independently
- Distinctive: line 104
MUST NOT mix unrelated changes in a single commit (formatting + feature + bug fix)
- Distinctive: line 105
SHOULD use Conventional Commits format for automated changelog and versioning
- Distinctive: line 106
SHOULD include a body for non-trivial changes explaining WHY, not WHAT
- Distinctive: line 123
SHOULD keep PRs under 200 lines of changed code
- Distinctive: line 124
MUST include a clear description: context, what changed, why, how to test
- Distinctive: line 125
SHOULD use PR templates to ensure consistent descriptions
- Distinctive: line 126
MUST NOT submit PRs with failing CI checks
- Distinctive: line 127
SHOULD separate refactoring from feature changes — refactoring PRs reviewed differently than feature PRs
- Distinctive: line 204
When setting up or reviewing Git workflows, verify:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Git Best Practices
Reference: Pro Git (Chacon & Straub), Continuous Delivery (Humble & Farley), Accelerate (Forsgren et al.)
When to Apply
- Choosing or evaluating a branching strategy for a team or project
- Writing commit messages or reviewing them in pull requests
- Structuring pull requests for effective code review
- Setting up Git hooks and commit validation tooling
- Implementing automated versioning and changelog generation
- Improving DORA metrics (lead time, deployment frequency, change failure rate)
Branching Strategy
Trunk-Based Development (Recommended Default)
All developers collaborate on a single branch (trunk/main). Two variants:
| Variant | Team Size | Branch Lifetime | Merge Method |
| Direct to trunk | Small (≤5 developers) | No branches | Direct push |
| Short-lived feature branches | Any size | 1–2 days maximum | PR + merge |
- SHOULD default to trunk-based development — DORA research confirms higher-performing organizations are more likely to use TBD
- MUST keep feature branches to 1–2 days maximum; MUST NOT let branches live longer than a week
- MUST use feature flags to decouple deployment from release when features span multiple days
Branching Strategies Compared
| Strategy | Best For | Avoid When |
| Trunk-Based | SaaS, continuous deployment, high-cadence teams | N/A — suitable for most teams |
| GitHub Flow | Simple — main + short-lived branches + PRs | Multiple supported release versions |
| GitLab Flow | Teams needing environment branches (staging, production) | Teams doing continuous deployment |
| GitFlow | Versioned software with multiple supported releases | Continuous delivery — Driessen himself (2020): "adopt a simpler workflow" |
Feature Flags
Feature flags decouple deployment from release. MUST use them when incomplete features need to ship to production.
| Flag Type | Purpose | Lifetime |
| Release Toggle | Hide incomplete features in production | Days to weeks — remove after launch |
| Ops Toggle | Runtime circuit breakers and operational controls | Permanent or long-lived |
| Experiment Toggle | A/B testing and gradual rollout | Days to weeks — remove after decision |
| Permission Toggle | Feature access by user segment (beta, premium) | Long-lived |
- MUST remove release toggles promptly after the feature is fully launched
- SHOULD track all active flags and assign cleanup owners
Commit Messages
Conventional Commits Format
<type>(scope): description
[optional body]
[optional footer(s)]Core types and their SemVer mapping:
| Type | SemVer | Purpose |
feat | MINOR | New user-facing functionality |
fix | PATCH | Bug fix |
feat! or BREAKING CHANGE: footer | MAJOR | Breaking API change |
docs | — | Documentation only |
style | — | Formatting, whitespace (no logic change) |
refactor | — | Code restructuring (no behavior change) |
perf | PATCH | Performance improvement |
test | — | Adding or correcting tests |
build | — | Build system or dependency changes |
ci | — | CI configuration changes |
chore | — | Other maintenance (no production code) |
revert | — | Reverts a previous commit |
Chris Beams' 7 Rules
- Separate subject from body with a blank line
- Limit subject to 50 characters
- Capitalize the subject line
- Do not end the subject with a period
- Use imperative mood — "Add feature" not "Added feature" or "Adds feature"
- Wrap body at 72 characters
- Body explains what and why, not how
Rules
- MUST use imperative mood in subject: the commit message completes the sentence "If applied, this commit will..."
- MUST make each commit atomic — one logical change that compiles and passes tests independently
- MUST NOT mix unrelated changes in a single commit (formatting + feature + bug fix)
- SHOULD use Conventional Commits format for automated changelog and versioning
- SHOULD include a body for non-trivial changes explaining WHY, not WHAT
Pull Requests
Size Matters
| PR Size | Review Time | Defect Detection | Recommendation |
| < 200 lines | Fast (~30 min) | Highest (~40% more defects found) | Ideal |
| 200–400 lines | Moderate | Good | Acceptable |
| 400–1000 lines | Slow | Declining | Split if possible |
| > 1000 lines | Very slow | Drops by ~70% | MUST split |
Rules
- SHOULD keep PRs under 200 lines of changed code
- MUST include a clear description: context, what changed, why, how to test
- SHOULD use PR templates to ensure consistent descriptions
- MUST NOT submit PRs with failing CI checks
- SHOULD separate refactoring from feature changes — refactoring PRs reviewed differently than feature PRs
Stacked PRs
For features too large for a single small PR, use stacked PRs — a chain of small dependent PRs that build on each other.
- Break the feature into sequential, independently reviewable increments
- Each PR in the stack targets the previous PR's branch (or main for the first)
- Review and merge bottom-up
- Tools: Graphite, ghstack, git-branchless
Git Hooks
Client-Side Hooks
| Hook | Stage | Purpose | Tooling |
pre-commit | Before commit is created | Lint, format, type-check staged files | lint-staged, prettier, eslint |
commit-msg | After message is entered | Validate conventional commit format | commitlint |
pre-push | Before push to remote | Run tests, check for secrets | jest, detect-secrets |
prepare-commit-msg | Before editor opens | Pre-populate commit template | commitizen |
Hook Management Tools
| Tool | Ecosystem | Key Feature |
| Husky | Node.js | Simple setup with package.json scripts |
| pre-commit | Python (language-agnostic) | Large plugin ecosystem, runs hooks in isolation |
| Lefthook | Go binary (no runtime dependency) | Parallel execution, fast, no Node required |
Typical Hook Pipeline
pre-commit:
1. lint-staged (format + lint only changed files)
2. type-check (TypeScript, mypy)
3. detect-secrets (prevent accidental credential commits)
commit-msg:
1. commitlint (validate Conventional Commits format)
pre-push:
1. test suite (unit tests, fast integration tests)Automated Versioning and Release
Conventional Commits enable fully automated semantic versioning:
| Tool | Approach | Best For |
| semantic-release | Fully automated: version, changelog, publish on merge | CI/CD pipelines with continuous release |
| release-please (Google) | Creates and maintains release PRs; merge to release | Teams wanting human approval before release; monorepo support |
| changesets | Developers describe changes; bot creates release PR | Monorepos with multiple packages |
| commitizen | Interactive CLI for crafting conventional commits | Teams onboarding to conventional commits |
DORA Metrics Connection
The Accelerate research (Forsgren, Humble, Kim) shows four key metrics that distinguish high-performing teams:
| Metric | Elite Performance | Connection to Git Practices |
| Lead Time for Changes | < 1 hour | Small PRs, trunk-based development, CI/CD |
| Deployment Frequency | Multiple per day | Feature flags, automated release |
| Change Failure Rate | 0–15% | Atomic commits, comprehensive tests, small PRs |
| Time to Restore Service | < 1 hour | Fast rollback via revert commits, feature flag kill switches |
Checklist
When setting up or reviewing Git workflows, verify:
- Branching strategy matches team size and deployment model (TBD preferred)
- Feature branches live no longer than 1–2 days
- Feature flags are used for incomplete features deployed to production
- Commit messages follow Conventional Commits format with imperative mood
- Each commit is atomic — one logical change, compiles, passes tests
- PRs are under 200 lines; larger changes are stacked
- PR descriptions include context, rationale, and testing instructions
- Git hooks validate formatting, linting, and commit message format
- Automated versioning is connected to Conventional Commits
- Release toggles are tracked and removed after launch
Key References
| Book | Author(s) | Publisher | Year |
| Pro Git (2nd ed.) | Scott Chacon, Ben Straub | Apress | 2014 |
| Head First Git | Raju Gandhi | O'Reilly | 2022 |
| Continuous Delivery | Jez Humble, David Farley | Addison-Wesley | 2010 |
| The DevOps Handbook (2nd ed.) | Kim, Humble, Debois, Willis, Forsgren | IT Revolution | 2021 |
| Accelerate | Forsgren, Humble, Kim | IT Revolution | 2018 |
| Software Engineering at Google | Winters, Manshreck, Wright | O'Reilly | 2020 |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

