Git Workflow Skill
Purpose
Manage git operations with best practices, generating meaningful commit messages, managing branches safely, creating comprehensive pull requests, and preventing common git mistakes.
Activation Triggers
Activate this skill when:
- User says "commit my changes"
- User mentions "create a branch"
- User asks to "create a PR" or "pull request"
- User says "push to remote"
- Before any destructive git operation
- User mentions git or version control
Core Capabilities
1. Smart Commits
Goal: Generate meaningful, consistent commit messages that explain WHY changes were made
Process:
- Analyze Changes — Run
git status and git diff
- Understand Intent — What was added/modified/removed? What problem does this solve?
- Generate Commit Message using format:
[type]: [concise description in present tense]
Commit Types:
feat or feature - New feature
fix - Bug fix
refactor - Code restructuring without behavior change
test - Adding or updating tests
docs - Documentation changes
chore - Maintenance tasks (deps, config, etc.)
style - Code formatting (no logic change)
perf - Performance improvements
Message Guidelines:
- Present tense, imperative mood ("Add" not "Added")
- Focus on WHAT and WHY, not HOW
- Under 72 characters for first line
- No period at the end
Good examples:
feat: Add RSI indicator to market analysis
fix: Handle division by zero in position sizing
refactor: Extract strategy validation into separate function
Avoid: Vague messages ("updated files"), past tense ("Added new stuff"), or non-descriptive ("WIP", "asdfgh").
- Show and Confirm — Present proposed message, list of files, and ask for approval
- Execute and Verify — Stage files, commit, verify with
git log -1 --oneline
2. Branch Management
Naming Convention: [type]/[description]
| Type |
Purpose |
Example |
feature/ |
New features |
feature/user-authentication |
fix/ |
Bug fixes |
fix/login-timeout-error |
refactor/ |
Code restructuring |
refactor/payment-processing |
experiment/ |
Experimental work |
experiment/ml-price-prediction |
hotfix/ |
Urgent production fixes |
hotfix/security-vulnerability |
Key Operations:
- Create:
git switch -c feature/name
- Switch:
git switch feature/name
- List:
git branch -v (or -a for remote)
- Delete (safe):
git branch -d feature/old
- Delete remote:
git push origin --delete feature/old
Safety: Before pushing to main/master, warn the user and recommend creating a feature branch with a PR instead.
3. Pull Request Creation
Process:
- Analyze all commits:
git log main..HEAD --oneline and git diff main...HEAD
- Review changes — overall purpose, key changes, breaking changes, testing needs
- Generate PR description using this template:
## Summary
[Brief overview of what this PR does and why]
## Changes
- [Key change 1]
- [Key change 2]
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed
## Code Quality
- [ ] Follows project style guidelines
- [ ] Self-review completed
- [ ] No debug code left
- [ ] Documentation updated
## Related Issues
Closes #[issue number]
- Create PR: Use
gh pr create --title "[Type]: Brief description" --body "..."
- Return PR URL with next steps (request reviewers, monitor CI, address feedback)
4. Safety Checks
Pre-Commit:
- No Secrets — Scan staged changes for
api_key, secret, password, token. If found, warn and recommend .gitignore or environment variables. Abort by default.
- Tests Pass — Run test suite. Block commit if tests fail.
- Large Commit Warning — If 10+ files changed, suggest breaking into smaller commits.
Pre-Push:
- Branch Check — If on main/master, warn and recommend feature branch + PR workflow.
- Force Push Warning — If
--force detected, issue critical warning about history rewriting, lost work, and broken PRs. Require explicit confirmation.
Pre-Merge:
- Check for conflicts:
git merge --no-commit --no-ff [branch] then git merge --abort
- Verify CI status:
gh pr checks
- Confirm approvals:
gh pr view --json reviews
Workflow Example: Preventing Dangerous Operations
User: "Push my changes to main"
Response:
- Detect current branch is
main
- Warn about risks: no code review, potential production breakage, no CI gate
- Recommend: create feature branch, push there, create PR, get review
- Offer alternatives: (1) Create branch + PR, (2) Run tests then push, (3) Cancel
Integration Points
- Works with
review skill for pre-commit reviews
- Works with
spec-driven-implementation skill for commit messages during execution
- Works with
systematic-debug skill to verify tests before commit
Best Practices
- Commit Often — Small, frequent commits over large, infrequent ones
- One Concern Per Commit — Each commit represents one logical change
- Write Good Messages — Future you will thank present you
- Review Before Push — Always review your own changes first
- Use Branches — Never work directly on main
- Create PRs — Always use pull requests, even for solo projects
- Keep History Clean — Meaningful commits, not "WIP" or "fix"
Notes
- Always prioritize safety over convenience
- Default to the safer option when in doubt
- Prevent destructive operations with clear warnings
- Make it easy to do the right thing
1---2name: git-workflow3description: Smart git operations — commit messages, branch management, PR creation with summaries. Use for any git workflow.4---5
6# Git Workflow Skill
7
8## Purpose
9
10Manage git operations with best practices, generating meaningful commit messages, managing branches safely, creating comprehensive pull requests, and preventing common git mistakes.
11
12## Activation Triggers
13
14Activate this skill when:
15- User says "commit my changes"
16- User mentions "create a branch"
17- User asks to "create a PR" or "pull request"
18- User says "push to remote"
19- Before any destructive git operation
20- User mentions git or version control
21
22## Core Capabilities
23
24### 1. Smart Commits
25
26**Goal:** Generate meaningful, consistent commit messages that explain WHY changes were made
27
28**Process:**
29
301. **Analyze Changes** — Run `git status` and `git diff`
312. **Understand Intent** — What was added/modified/removed? What problem does this solve?
323. **Generate Commit Message** using format: `[type]: [concise description in present tense]`
33
34**Commit Types:**
35- `feat` or `feature` - New feature
36- `fix` - Bug fix
37- `refactor` - Code restructuring without behavior change
38- `test` - Adding or updating tests
39- `docs` - Documentation changes
40- `chore` - Maintenance tasks (deps, config, etc.)
41- `style` - Code formatting (no logic change)
42- `perf` - Performance improvements
43
44**Message Guidelines:**
45- Present tense, imperative mood ("Add" not "Added")
46- Focus on WHAT and WHY, not HOW
47- Under 72 characters for first line
48- No period at the end
49
50**Good examples:**
51```
52feat: Add RSI indicator to market analysis
53fix: Handle division by zero in position sizing
54refactor: Extract strategy validation into separate function
55```
56
57**Avoid:** Vague messages ("updated files"), past tense ("Added new stuff"), or non-descriptive ("WIP", "asdfgh").
58
594. **Show and Confirm** — Present proposed message, list of files, and ask for approval
605. **Execute and Verify** — Stage files, commit, verify with `git log -1 --oneline`
61
62### 2. Branch Management
63
64**Naming Convention:** `[type]/[description]`
65
66| Type | Purpose | Example |
67|------|---------|---------|
68| `feature/` | New features | `feature/user-authentication` |
69| `fix/` | Bug fixes | `fix/login-timeout-error` |
70| `refactor/` | Code restructuring | `refactor/payment-processing` |
71| `experiment/` | Experimental work | `experiment/ml-price-prediction` |
72| `hotfix/` | Urgent production fixes | `hotfix/security-vulnerability` |
73
74**Key Operations:**
75- Create: `git switch -c feature/name`
76- Switch: `git switch feature/name`
77- List: `git branch -v` (or `-a` for remote)
78- Delete (safe): `git branch -d feature/old`
79- Delete remote: `git push origin --delete feature/old`
80
81**Safety:** Before pushing to main/master, warn the user and recommend creating a feature branch with a PR instead.
82
83### 3. Pull Request Creation
84
85**Process:**
86
871. **Analyze all commits:** `git log main..HEAD --oneline` and `git diff main...HEAD`
882. **Review changes** — overall purpose, key changes, breaking changes, testing needs
893. **Generate PR description** using this template:
90
91```markdown
92## Summary
93[Brief overview of what this PR does and why]
94
95## Changes
96- [Key change 1]
97- [Key change 2]
98
99## Type of Change
100- [ ] Bug fix
101- [ ] New feature
102- [ ] Breaking change
103- [ ] Documentation update
104
105## Testing
106- [ ] Unit tests pass
107- [ ] Integration tests pass
108- [ ] Manual testing completed
109
110## Code Quality
111- [ ] Follows project style guidelines
112- [ ] Self-review completed
113- [ ] No debug code left
114- [ ] Documentation updated
115
116## Related Issues
117Closes #[issue number]
118```
119
1204. **Create PR:** Use `gh pr create --title "[Type]: Brief description" --body "..."`
1215. **Return PR URL** with next steps (request reviewers, monitor CI, address feedback)
122
123### 4. Safety Checks
124
125**Pre-Commit:**
126
1271. **No Secrets** — Scan staged changes for `api_key`, `secret`, `password`, `token`. If found, warn and recommend `.gitignore` or environment variables. Abort by default.
1282. **Tests Pass** — Run test suite. Block commit if tests fail.
1293. **Large Commit Warning** — If 10+ files changed, suggest breaking into smaller commits.
130
131**Pre-Push:**
132
1331. **Branch Check** — If on main/master, warn and recommend feature branch + PR workflow.
1342. **Force Push Warning** — If `--force` detected, issue critical warning about history rewriting, lost work, and broken PRs. Require explicit confirmation.
135
136**Pre-Merge:**
137
1381. Check for conflicts: `git merge --no-commit --no-ff [branch]` then `git merge --abort`
1392. Verify CI status: `gh pr checks`
1403. Confirm approvals: `gh pr view --json reviews`
141
142## Workflow Example: Preventing Dangerous Operations
143
144**User:** "Push my changes to main"
145
146**Response:**
147- Detect current branch is `main`
148- Warn about risks: no code review, potential production breakage, no CI gate
149- Recommend: create feature branch, push there, create PR, get review
150- Offer alternatives: (1) Create branch + PR, (2) Run tests then push, (3) Cancel
151
152## Integration Points
153
154- Works with `review` skill for pre-commit reviews
155- Works with `spec-driven-implementation` skill for commit messages during execution
156- Works with `systematic-debug` skill to verify tests before commit
157
158## Best Practices
159
1601. **Commit Often** — Small, frequent commits over large, infrequent ones
1612. **One Concern Per Commit** — Each commit represents one logical change
1623. **Write Good Messages** — Future you will thank present you
1634. **Review Before Push** — Always review your own changes first
1645. **Use Branches** — Never work directly on main
1656. **Create PRs** — Always use pull requests, even for solo projects
1667. **Keep History Clean** — Meaningful commits, not "WIP" or "fix"
167
168## Notes
169
170- Always prioritize safety over convenience
171- Default to the safer option when in doubt
172- Prevent destructive operations with clear warnings
173- Make it easy to do the right thing