Git助手
- 作者仓库星标 0
- 作者更新于 实时读取
- 作者仓库 skills-registry
- 领域
- AI 智能
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @tomevault-io · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 需要 · Vendor-specific
- 兼容的系统
- macOS · Linux · Windows
- 底层运行要求
- 无特殊要求
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- 读取环境变量
- 网络行为
- 允许外网请求
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: git-workflow-and-versioning
description: Structures git workflow practices. Use when making any code change. Use when committing, branchi…
category: AI 智能
runtime: 无特殊运行时
---
# git-workflow-and-versioning 输出预览
## PART A: 任务判断
- 适用问题:提示词、Agent 工作流、模型评估或自动化推理。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Repo-Specific Workflow / Critical Rules (this repo) / Overview”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于提示词、Agent 工作流、模型评估或自动化推理,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Repo-Specific Workflow / Critical Rules (this repo) / Overview”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、读取环境变量、会按任务需要访问外部网络、需要准备 Vendor-specific API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、读取环境变量;会按任务需要访问外部网络;需要准备 Vendor-specific API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文没有稳定的斜杠命令要求。安装验证后通常全局生效,直接在对话里点名这个 Skill 并描述任务即可。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、读取环境变量。
先用一个小任务确认它会围绕“Repo-Specific Workflow / Critical Rules (this repo) / Overview”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: git-workflow-and-versioning
description: Structures git workflow practices. Use when making any code change. Use when committing, branchi…
category: AI 智能
source: tomevault-io/skills-registry
---
# git-workflow-and-versioning
## 什么时候使用
- 把 AI / Agent方向的常用动作沉淀成 Agent 可调用的技能 适合处理AI Agent、提示词、模型评估与自动化推理,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查…
- 面向提示词、Agent 工作流、模型评估或自动化推理,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Repo-Specific Workflow / Critical Rules (this repo) / Overview」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、读取环境变量;会按任务需要访问外部网络;需要准备 Vendor-specific API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "git-workflow-and-versioning" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Repo-Specific Workflow / Critical Rules (this repo) / Overview
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> 无特殊运行时 | 读取文件、写入/修改文件、读取环境变量 | 会按任务需要访问外部网络
安全层 -> 需要准备 Vendor-specific API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Git Workflow and Versioning
Repo-Specific Workflow
This repo uses scripts/git-agent.sh for session-based agent work. The key workflow:
| Step | Command | Description |
|---|---|---|
| Start | git-agent.sh start <name> |
Creates worktree + branch from main |
| Commit | git-agent.sh commit -m "msg" |
Stages all, runs quality gate, commits without --no-verify |
| End | git-agent.sh end --pr |
Squashes, pushes branch, creates PR (required — main is protected) |
| Abort | git-agent.sh abort <id> |
Discards worktree and branch |
Critical Rules (this repo)
end --mergeis NOT supported on protected branches. The script auto-converts--mergeto--prwhen detected.end --pris required to land changes onmain. Branch protection enforces PR-only merges.- Two-tier commit system:
- Checkpoint commits (during development): Use imperative mood English. Example:
Add validation to registration endpoint - PR merge commits (permanent history): Use conventional commits. Example:
feat: add validation to registration endpoint
- Checkpoint commits (during development): Use imperative mood English. Example:
- CI must pass before PRs can merge. Required checks:
Lint & Validate+Smoke Tests. - Pre-commit hook verifies committer identity (
B67687 <111849193+B67687@users.noreply.github.com>). This runs on every commit (no--no-verifyexcept in crash WIP trap). - Pre-push hook verifies all pushed commits have valid SSH signatures.
Commit-msg hook at ~/.config/git/hooks/commit-msg (outside repo — set via core.hookspath):
Validates conventional commit format (feat:, fix:, etc.) and English imperative checkpoint
commits. Only activates for B67687/agentic-workflows — pass-through for all other repos.
Companion script: scripts/git-branch-cleanup.sh --- scans branches for staleness, merge status, and divergence. Run from the skill directory:
bash ./scripts/git-branch-cleanup.sh scan # all branches
bash ./scripts/git-branch-cleanup.sh stale 5 # branches >5 days old
bash ./scripts/git-branch-cleanup.sh merged # branches merged into main
bash ./scripts/git-branch-cleanup.sh diverged # branches far behind main
Overview
Git is your safety net. Treat commits as save points, branches as sandboxes, and history as documentation. With AI agents generating code at high speed, disciplined version control is the mechanism that keeps changes manageable, reviewable, and reversible.
When to Use
Always. Every code change flows through git.
Core Principles
Trunk-Based Development (Recommended)
Keep main always deployable. Work in short-lived feature branches that merge back within 1-3 days. Long-lived development branches are hidden costs --- they diverge, create merge conflicts, and delay integration. DORA research consistently shows trunk-based development correlates with high-performing engineering teams.
main ──*──*──*──*──*──*──*──*──*── (always deployable)
╲ ╱ ╲ ╱
*──*─╱ *──╱ <- short-lived feature branches (1-3 days)
This is the recommended default. Teams using gitflow or long-lived branches can adapt the principles (atomic commits, small changes, descriptive messages) to their branching model --- the commit discipline matters more than the specific branching strategy.
- Dev branches are costs. Every day a branch lives, it accumulates merge risk.
- Release branches are acceptable. When you need to stabilize a release while main moves forward.
- Feature flags > long branches. Prefer deploying incomplete work behind flags rather than keeping it on a branch for weeks.
1. Commit Early, Commit Often
Each successful increment gets its own commit. Don't accumulate large uncommitted changes.
Work pattern:
Implement slice -> Test -> Verify -> Commit -> Next slice
Not this:
Implement everything -> Hope it works -> Giant commit
Commits are save points. If the next change breaks something, you can revert to the last known-good state instantly.
2. Atomic Commits
Each commit does one logical thing:
# Good: Each commit is self-contained
git log --oneline
a1b2c3d Add task creation endpoint with validation
d4e5f6g Add task creation form component
h7i8j9k Connect form to API and add loading state
m1n2o3p Add task creation tests (unit + integration)
# Bad: Everything mixed together
git log --oneline
x1y2z3a Add task feature, fix sidebar, update deps, refactor utils
3. Descriptive Messages
Commit messages explain the why, not just the what:
# Good: Explains intent
feat: add email validation to registration endpoint
Prevents invalid email formats from reaching the database.
Uses Zod schema validation at the route handler level,
consistent with existing validation patterns in auth.ts.
# Bad: Describes what's obvious from the diff
update auth.ts
Format:
<type>: <short description>
<optional body explaining why, not what>
Types:
feat--- New featurefix--- Bug fixrefactor--- Code change that neither fixes a bug nor adds a featuretest--- Adding or updating testsdocs--- Documentation onlychore--- Tooling, dependencies, config
4. Keep Concerns Separate
Don't combine formatting changes with behavior changes. Don't combine refactors with features. Each type of change should be a separate commit --- and ideally a separate PR:
# Good: Separate concerns
git commit -m "refactor: extract validation logic to shared utility"
git commit -m "feat: add phone number validation to registration"
# Bad: Mixed concerns
git commit -m "refactor validation and add phone number field"
Separate refactoring from feature work. A refactoring change and a feature change are two different changes --- submit them separately. This makes each change easier to review, revert, and understand in history. Small cleanups (renaming a variable) can be included in a feature commit at reviewer discretion.
5. Size Your Changes
Target ~100 lines per commit/PR. Changes over ~1000 lines should be split. See the splitting strategies in code-review-and-quality for how to break down large changes.
~100 lines -> Easy to review, easy to revert
~300 lines -> Acceptable for a single logical change
~1000 lines -> Split into smaller changes
Branching Strategy
Feature Branches
main (always deployable)
│
├── feature/task-creation <- One feature per branch
├── feature/user-settings <- Parallel work
└── fix/duplicate-tasks <- Bug fixes
- Branch from
main(or the team's default branch) - Keep branches short-lived (merge within 1-3 days) --- long-lived branches are hidden costs
- Delete branches after merge
- Prefer feature flags over long-lived branches for incomplete features
Branch Naming
feature/<short-description> -> feature/task-creation
fix/<short-description> -> fix/duplicate-tasks
chore/<short-description> -> chore/update-deps
refactor/<short-description> -> refactor/auth-module
Working with Worktrees
For parallel AI agent work, use git worktrees to run multiple branches simultaneously:
# Create a worktree for a feature branch
git worktree add ../project-feature-a feature/task-creation
git worktree add ../project-feature-b feature/user-settings
# Each worktree is a separate directory with its own branch
# Agents can work in parallel without interfering
ls ../
project/ <- main branch
project-feature-a/ <- task-creation branch
project-feature-b/ <- user-settings branch
# When done, merge and clean up
git worktree remove ../project-feature-a
Benefits:
- Multiple agents can work on different features simultaneously
- No branch switching needed (each directory has its own branch)
- If one experiment fails, delete the worktree --- nothing is lost
- Changes are isolated until explicitly merged
The Save Point Pattern
Agent starts work
│
├── Makes a change
│ ├── Test passes? -> Commit -> Continue
│ └── Test fails? -> Revert to last commit -> Investigate
│
├── Makes another change
│ ├── Test passes? -> Commit -> Continue
│ └── Test fails? -> Revert to last commit -> Investigate
│
└── Feature complete -> All commits form a clean history
This pattern means you never lose more than one increment of work. If an agent goes off the rails, git reset --hard HEAD takes you back to the last successful state.
Change Summaries
After any modification, provide a structured summary. This makes review easier, documents scope discipline, and surfaces unintended changes:
CHANGES MADE:
- src/routes/tasks.ts: Added validation middleware to POST endpoint
- src/lib/validation.ts: Added TaskCreateSchema using Zod
THINGS I DIDN'T TOUCH (intentionally):
- src/routes/auth.ts: Has similar validation gap but out of scope
- src/middleware/error.ts: Error format could be improved (separate task)
POTENTIAL CONCERNS:
- The Zod schema is strict --- rejects extra fields. Confirm this is desired.
- Added zod as a dependency (72KB gzipped) --- already in package.json
This pattern catches wrong assumptions early and gives reviewers a clear map of the change. The "DIDN'T TOUCH" section is especially important --- it shows you exercised scope discipline and didn't go on an unsolicited renovation.
Pre-Commit Hygiene
Before every commit:
# 1. Check what you're about to commit
git diff --staged
# 2. Ensure no secrets
git diff --staged | grep -i "password\|secret\|api_key\|token"
# 3. Run tests
npm test
# 4. Run linting
npm run lint
# 5. Run type checking
npx tsc --noEmit
Automate this with git hooks:
// package.json (using lint-staged + husky)
{
"lint-staged": {
"*.{ts,tsx}": ["eslint --fix", "prettier --write"],
"*.{json,md}": ["prettier --write"]
}
}
Handling Generated Files
- Commit generated files only if the project expects them (e.g.,
package-lock.json, Prisma migrations) - Don't commit build output (
dist/,.next/), environment files (.env), or IDE config (.vscode/settings.jsonunless shared) - Have a
.gitignorethat covers:node_modules/,dist/,.env,.env.local,*.pem
Using Git for Debugging
# Find which commit introduced a bug
git bisect start
git bisect bad HEAD
git bisect good <known-good-commit>
# Git checkouts midpoints; run your test at each to narrow down
# View what changed recently
git log --oneline -20
git diff HEAD~5..HEAD -- src/
# Find who last changed a specific line
git blame src/services/task.ts
# Search commit messages for a keyword
git log --grep="validation" --oneline
Common Rationalizations
| Rationalization | Reality |
|---|---|
| "I'll commit when the feature is done" | One giant commit is impossible to review, debug, or revert. Commit each slice. |
| "The message doesn't matter" | Messages are documentation. Future you (and future agents) will need to understand what changed and why. |
| "I'll squash it all later" | Squashing destroys the development narrative. Prefer clean incremental commits from the start. |
| "Branches add overhead" | Short-lived branches are free and prevent conflicting work from colliding. Long-lived branches are the problem --- merge within 1-3 days. |
| "I'll split this change later" | Large changes are harder to review, riskier to deploy, and harder to revert. Split before submitting, not after. |
| "I don't need a .gitignore" | Until .env with production secrets gets committed. Set it up immediately. |
Red Flags
- Large uncommitted changes accumulating
- Commit messages like "fix", "update", "misc"
- Formatting changes mixed with behavior changes
- No
.gitignorein the project - Committing
node_modules/,.env, or build artifacts - Long-lived branches that diverge significantly from main
- Force-pushing to shared branches
Verification
For every commit:
- Commit does one logical thing
- Message explains the why, follows type conventions
- Tests pass before committing
- No secrets in the diff
- No formatting-only changes mixed with behavior changes
-
.gitignorecovers standard exclusions
Source: B67687/agentic-workflows — distributed by TomeVault.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核