$npx -y skills add DevelopersGlobal/ai-agent-skills --skill git-workflowTrunk-based development with atomic commits, clean history, and meaningful commit messages. Every commit should be deployable.
| 1 | ## Overview |
| 2 | |
| 3 | Git is not just a backup system — it's a communication tool. Clean git history enables fast debugging (git bisect), clear attribution, and safe reverts. This skill enforces atomic commits, meaningful messages, and trunk-based development. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - Before making any commit |
| 8 | - When reviewing a PR's git history |
| 9 | - When setting up a new project |
| 10 | |
| 11 | ## Process |
| 12 | |
| 13 | ### Step 1: Atomic Commits |
| 14 | |
| 15 | 1. Each commit should represent ONE logical change — not a day's worth of work. |
| 16 | 2. A commit should be: independently deployable, independently revertable. |
| 17 | 3. Never commit "WIP" or partial implementations. |
| 18 | |
| 19 | **Verify:** You could revert this commit without affecting adjacent functionality. |
| 20 | |
| 21 | ### Step 2: Commit Message Format |
| 22 | |
| 23 | 4. Follow Conventional Commits: |
| 24 | ``` |
| 25 | type(scope): short summary (max 72 chars) |
| 26 | |
| 27 | Body: what changed and WHY (not how — the diff shows how). |
| 28 | |
| 29 | Closes: #issue-number |
| 30 | ``` |
| 31 | 5. Types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore` |
| 32 | 6. The summary is imperative mood: "Add feature" not "Added feature" |
| 33 | |
| 34 | **Verify:** Message passes: `feat|fix|docs|...(<scope>): <summary>` format. |
| 35 | |
| 36 | ### Step 3: Trunk-Based Development |
| 37 | |
| 38 | 7. Work directly on `main` for small changes (<1 day of work). |
| 39 | 8. For larger features: short-lived feature branches (max 2 days), frequent merges to main. |
| 40 | 9. Never let a branch live more than 3 days without merging or rebasing. |
| 41 | 10. Use feature flags for incomplete features, not long-lived branches. |
| 42 | |
| 43 | **Verify:** No branch is more than 2 days old without a merge/rebase plan. |
| 44 | |
| 45 | ### Step 4: Pre-Commit Gates |
| 46 | |
| 47 | 11. Before every commit: tests pass, linter passes, no secrets in diff. |
| 48 | 12. Use pre-commit hooks to enforce automatically. |
| 49 | |
| 50 | ## Common Rationalizations (and Rebuttals) |
| 51 | |
| 52 | | Excuse | Rebuttal | |
| 53 | |--------|----------| |
| 54 | | "I'll clean up the commits later" | You won't. Clean as you go. | |
| 55 | | "The commit message doesn't matter" | It matters in 6 months when you're bisecting a production bug. | |
| 56 | | "Feature branches protect main" | Long-lived branches cause merge nightmares. Trunk-based is safer. | |
| 57 | |
| 58 | ## Verification |
| 59 | |
| 60 | - [ ] Commits are atomic and independently deployable |
| 61 | - [ ] Commit messages follow Conventional Commits format |
| 62 | - [ ] No long-lived branches (> 3 days) |
| 63 | - [ ] Pre-commit hooks in place |
| 64 | |
| 65 | ## References |
| 66 | |
| 67 | - [ci-cd-pipelines skill](../ci-cd-pipelines/SKILL.md) |
| 68 | - [Conventional Commits](https://www.conventionalcommits.org/) |