一键导入
dev-git-workflow
Team Git patterns for branching, PRs, commits, and code review. Use when choosing a branching model or hardening repo collaboration.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Team Git patterns for branching, PRs, commits, and code review. Use when choosing a branching model or hardening repo collaboration.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Builds multi-repo context hubs and compiled markdown knowledge maps. Use when profiling repo portfolios or assembling LLM-ready cross-repo knowledge bases.
Builds per-repo code graphs in JSON and markdown-ready derived artifacts. Use when you need blast radius, symbol-level maps, import graphs, inheritance, or test links.
Context-driven AI development with AGENTS.md, repo knowledge bases, Claude Code, Codex, and Copilot. Use when adopting repo-native AI workflows or multi-repo setups.
Technical writing for READMEs, ADRs, API docs, and changelogs. Use when revising or consolidating a repo documentation folder.
Design, implement, and troubleshoot NUKE-based CI/CD pipelines for .NET services with fast local-to-CI feedback loops. Use when creating or refactoring `nuke/Build.cs` target graphs, tuning `DependsOn`/`After`/`Triggers`/`OnlyWhenDynamic` behavior, orchestrating unit/API/DB test categories, merging and publishing coverage and test reports, building and pushing Docker images with traceable tags and digests, producing artifact contracts such as `deploy.env`, and diagnosing flaky or slow pipeline execution. For service code changes use $software-csharp-backend, for NUnit fixture design use $qa-testing-nunit, and for safe logging rewrites use $dev-structured-logs.
Systematic debugging for crashes, regressions, flakes, and production bugs. Use when diagnosing stack traces, logs, traces, or profiling data.
| name | dev-git-workflow |
| description | Team Git patterns for branching, PRs, commits, and code review. Use when choosing a branching model or hardening repo collaboration. |
Use modern Git collaboration patterns: GitHub Flow for continuous deploy, trunk-based for scale, Conventional Commits for automation, stacked diffs for large features.
Use this skill to choose a branching model, standardize PR discipline, enforce commit conventions, and harden repository settings for safe collaboration.
data/sources.json as a starting source list.| Task | Tool/Command | When to Use | Reference |
|---|---|---|---|
| Create feature branch | git switch -c feat/name main | Start new work | Branching Strategies |
| Create feature worktree | git worktree add .worktrees/feature -b feature/name | Isolate one feature per agent/branch | AI Agent Worktrees |
| Squash WIP commits | git rebase -i HEAD~3 | Clean up before PR | Interactive Rebase |
| Conventional commit | git commit -m "feat: add feature" | All commits | Commit Conventions |
| Force push safely | git push --force-with-lease | After rebase | Common Mistakes |
| Resolve conflicts | git mergetool | Merge conflicts | Conflict Resolution |
| Create stacked PRs | gt create stack-name (Graphite) | Large features | Stacked Diffs |
| Auto-generate changelog | npx standard-version | Before release | Release Management |
| Run quality gates | GitHub Actions / GitLab CI | Every PR | Automated Quality Gates |
AI Agent Worktrees Reference — Full guide to worktree isolation for Claude Code, Codex, Aider, and other AI coding agents.
flowchart LR
A[Plan] --> B[Create worktree<br>per agent/feature]
B --> C[Verify .gitignore<br>+ install deps]
C --> D[Agent works<br>scoped commits]
D --> E[Quality gates]
E -->|pass| F[PR + merge]
E -->|fail| D
F --> G[Cleanup worktree<br>+ delete branch]
style D fill:#fff3cd,stroke:#d4a017
style F fill:#d4edda,stroke:#28a745
For AI-assisted engineering, prefer this default loop:
git worktree add .worktrees/<feature> -b feature/<name>)..gitignore (git check-ignore -q .worktrees).git worktree remove + git branch -d.Parallel agents: One worktree per agent, disjoint file ownership, orchestrator merges from main. See AI Agent Worktrees for setup, safety patterns, and cleanup.
If repository scripts exist (for example scripts/git/feature-workflow.sh), use them to enforce this loop.
Use this quick sequence to avoid common local Git blockers during agent-driven work.
git status --porcelainindex.lock, check running Git processes first:
test -f .git/index.lock && ps aux | rg "[g]it"checkout/switch when local changes would be overwritten.Use this decision tree to select the optimal branching strategy for your team based on team size, release cadence, and CI/CD maturity.
Team characteristics -> What's your situation?
├─ Small team (1-5 devs) + Continuous deployment + High CI/CD maturity?
│ └─ GitHub Flow (main + feature branches)
│
├─ Medium team (5-15 devs) + Continuous deployment + High CI/CD maturity?
│ └─ Trunk-Based Development (main + short-lived branches)
│
├─ Large team (15+ devs) + Continuous deployment + Very high CI/CD maturity?
│ └─ Trunk-Based + Feature Flags (progressive rollout)
│
├─ Scheduled releases + Medium CI/CD maturity?
│ └─ GitFlow (main + develop + release branches)
│
└─ Multiple versions + Low-Medium CI/CD maturity?
└─ GitFlow (long-lived release branches)
Branching Strategies Comparison - Comprehensive guide to choosing and implementing branching strategies
PR Best Practices Guide - Effective code reviews and fast PR cycles
Conventional Commits Standard - Commit message formats and semantic versioning integration
type(scope): descriptionStacked Diffs Implementation - Platform-specific workflows and team adoption
Interactive Rebase & History Cleanup - Maintain clean commit history
fixup! and squash! commitsConflict Resolution Techniques - Merge strategies and conflict handling
--ours, --theirs, manual merge<<<<<<<, =======, >>>>>>>Automated Quality Gates - CI/CD pipelines and quality enforcement
Validation Checklists - Pre-PR, pre-merge, pre-release checklists
Release Management - Versioning and deployment workflows
AI Agent Worktrees - Worktree isolation patterns for AI coding agents
.worktrees/, global paths, .gitignore)Monorepo Workflows - Git patterns for monorepo repositories
Git Hooks Automation - Pre-commit, commit-msg, pre-push hooks
Git Bisect Debugging - Regression hunting with git bisect
Common Mistakes & Fixes - Learn from common pitfalls
--force-with-lease| Requirement | GitHub Flow | Trunk-Based | GitFlow |
|---|---|---|---|
| Continuous deployment | [OK] Best | [OK] Best | [FAIL] Poor |
| Scheduled releases | [WARNING] OK | [WARNING] OK | [OK] Best |
| Multiple versions | [FAIL] Poor | [FAIL] Poor | [OK] Best |
| Small team (< 5) | [OK] Best | [WARNING] OK | [FAIL] Overkill |
| Large team (> 15) | [WARNING] OK | [OK] Best | [WARNING] OK |
| Fast iteration | [OK] Best | [OK] Best | [FAIL] Poor |
| LOC | Review Time | Bug Detection | Recommendation |
|---|---|---|---|
| < 50 | < 10 min | High | [OK] Ideal for hotfixes |
| 50-200 | 10-30 min | High | [OK] Ideal for features |
| 200-400 | 30-60 min | Medium-High | [OK] Acceptable |
| 400-1000 | 1-2 hours | Medium | [WARNING] Consider splitting |
| > 1000 | > 2 hours | Low | [FAIL] Always split |
--force-with-lease (not --force)| Anti-Pattern | Problem | Fix |
|---|---|---|
| Long-lived branches | Merge conflicts, stale code | Trunk-based, short branches |
| Unreviewed merges | Bugs reach production | Branch protection rules |
| Rebasing main | History corruption | Never rebase public branches |
| 1000+ LOC PRs | Poor review quality | Stacked diffs, split PRs |
| "fix" commits | Unclear history | Conventional commits |
| No CI gates | Broken main | Required status checks |
| Secrets in history | Security breach | Pre-commit hooks, gitleaks |
Set these repo defaults before scaling a team:
main (no direct pushes), require status checks, require up-to-date branch on merge.main green under high concurrency.Template: assets/pull-requests/pr-template.md Guide: assets/template-git-workflow-guide.md
For security-related git operations, see dev-git-commit-message/assets/template-security-commits.md:
Note: AI tools assist but cannot replace human judgment for merge decisions.
For Claude Code:
Progressive Disclosure:
Common Operations:
# Rebase feature branch
git fetch origin && git rebase origin/main
# Interactive rebase last 3 commits
git rebase -i HEAD~3
# Squash all commits in branch
git rebase -i $(git merge-base HEAD main)
# Force push safely
git push --force-with-lease origin feature-branch
# Undo last commit (keep changes)
git reset --soft HEAD~1
# Cherry-pick specific commit
git cherry-pick abc123
# Stash changes
git stash push -m "WIP: implementing feature X"
git stash pop
Conflict Resolution:
# Pull latest with rebase
git pull --rebase origin main
# Use visual merge tool
git mergetool
# Accept their changes
git checkout --theirs <file>
# Accept your changes
git checkout --ours <file>
IMPORTANT: When users ask recommendation questions about Git workflows, branching strategies, or collaboration tools, verify current trends via web search (and/or the links in data/sources.json) before answering.
"Git workflow best practices 2026""[specific strategy] vs alternatives 2026""Git collaboration trends January 2026""[branching/PR tools] comparison 2026"After searching, provide: