Free SKILL.md scraped from GitHub. Clone the repo or copy the file directly into your Claude Code skills directory.
npx versuz@latest install krat0ss-my-agent-v5-skills-git-workflowgit clone https://github.com/Krat0sS/My-Agent-V5.gitcp My-Agent-V5/SKILL.MD ~/.claude/skills/krat0ss-my-agent-v5-skills-git-workflow/SKILL.md---
name: git-workflow
version: "2.0"
description: Git 标准工作流 — 状态查看、差异对比、暂存、提交、推送、回滚、分支管理
trigger:
keywords:
- git
- commit
- push
- 提交代码
- 推送代码
- 回滚代码
- 查看改动
- git status
- git diff
- git log
- 分支
- merge
- pull
exclude:
- 天气
- 搜索文件
- 整理桌面
- 搜索网页
tools:
- run_command
- git_status
- git_diff
- git_add
- git_commit
- git_push
- git_restore
- git_clone
- git_checkout
- git_merge
steps:
- action: "查看当前仓库状态 — git status 看有哪些改动"
tool: run_command
params:
command: "git status"
risk: low
- action: "查看具体改动内容 — git diff 看改了什么"
tool: run_command
params:
command: "git diff"
risk: low
- action: "根据用户意图执行操作"
tool: auto
risk: low
- action: "如果是提交,确认提交信息并执行"
tool: run_command
risk: low
- action: "如果是推送,先确认本地测试通过再推"
tool: run_command
risk: medium
constraints:
- "push 前必须先确认用户意图(除非用户明确说'提交并推送')"
- "禁止使用 git push --force(除非用户明确要求并理解风险)"
- "commit 信息要简洁明了,描述改动内容,不要用 'update' 这种无意义信息"
- "回滚前先用 git diff 确认要回滚的内容"
- "不要在 commit 信息中包含敏感信息(token、密码等)"
- "如果工作目录不在 git 仓库中,先提示用户初始化或 clone"
rollback: "git reset --soft HEAD~1"
---
# git-workflow Git 工作流
## 使用场景
用户要求提交代码、推送改动、查看 git 状态、回滚改动、管理分支。
## 常用操作流程
### 查看状态
```bash
git status # 查看哪些文件有改动
git diff # 查看未暂存的改动
git diff --cached # 查看已暂存待提交的改动
git log --oneline -10 # 查看最近 10 条提交记录
```
### 提交改动
```bash
git add -A # 暂存所有改动
git commit -m "类型: 简短描述" # 提交
```
### 推送到远程
```bash
git pull --rebase # 先拉取远程更新
git push # 推送
```
### 回滚操作
```bash
# 回滚最后一次提交(保留改动在工作区)
git reset --soft HEAD~1
# 回滚单个文件
git restore <file>
# 回滚已暂存的文件
git restore --staged <file>
```
### 分支操作
```bash
git branch # 查看分支
git checkout -b feature/xxx # 创建并切换新分支
git merge feature/xxx # 合并分支
git branch -d feature/xxx # 删除分支
```
## Commit 信息规范
- `feat: 新功能描述`
- `fix: 修复 bug 描述`
- `refactor: 重构描述`
- `docs: 文档更新`
- `test: 测试相关`
- `chore: 杂项改动`
- `self-upgrade: Agent 自我升级`
## 错误处理
### push 被拒绝
```bash
git pull --rebase # 先拉取远程更新
# 解决冲突(如果有)
git push # 重新推送
```
### 合并冲突
```
→ 用 git diff 查看冲突文件
→ 告知用户冲突位置
→ 不要自动解决冲突(除非用户明确要求)
```
### 权限问题
```
→ 提示用户检查 GITHUB_TOKEN 配置
→ 或提示用 git config credential.helper store
```
## 安全约束
- 禁止 `git push --force`(除非用户明确要求)
- 禁止 `git reset --hard`(除非用户明确要求)
- commit 信息不含敏感信息
- 回滚前先确认改动内容