Git 工作流助手,生成提交信息、PR 描述、分支管理建议,并自动化常见 Git 操作。
Git Workflow是一项面向实际任务的技能,主要用于Git 工作流助手,生成提交信息、PR 描述、分支管理建议,自动化常见 Git 操作;Version : 1.0;
2. 生成 PR 描述;3. 分支管理建议;4. 智能提交;Commands;suggest-commit。它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。
从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。该技能适合用于一次性任务,也可以接入自动化工作流,与其他技能或上层代理配合完成更完整的业务链路;在组合使用时,应明确每一步的输入输出关系,并避免不同步骤之间出现参数冲突。
Git 工作流助手,生成提交信息、PR 描述、分支管理建议,自动化常见 Git 操作。
Version: 1.0
Features: 智能提交信息、PR 描述生成、分支策略建议、Git 自动化
# 根据暂存区变更生成提交信息 python3 scripts/main.py suggest-commit # 自定义类型 python3 scripts/main.py suggest-commit --type feat
# 根据分支对比生成 PR 描述 python3 scripts/main.py pr-description --base main --head feature-branch
# 获取分支策略建议 python3 scripts/main.py branch-strategy # 检查过时分支 python3 scripts/main.py check-branches
# 自动暂存、生成信息、提交 python3 scripts/main.py smart-commit
| 命令 | 说明 | 示例 |
|---|---|---|
suggest-commit |
生成提交信息 | suggest-commit |
pr-description |
生成 PR 描述 | pr-description --base main |
branch-strategy |
分支策略 | branch-strategy |
check-branches |
检查分支 | check-branches |
smart-commit |
智能提交 | smart-commit |
$ python3 scripts/main.py suggest-commit 📝 Suggested commit message: feat(auth): add OAuth2 login support - Implement Google OAuth2 provider - Add token refresh mechanism - Update login UI Files changed: - src/auth/oauth.py (+45 lines) - src/ui/login.js (+23 lines) - tests/test_oauth.py (+67 lines)
自动遵循 Conventional Commits 规范:
[(scope)]: [body] [footer]
类型自动检测:
feat - 新功能fix - Bug 修复docs - 文档更新style - 代码格式refactor - 重构test - 测试chore - 构建/工具$ python3 scripts/main.py pr-description --base main --head feature/api-v2 📝 PR Description ================ ## Summary Implement API v2 with improved performance and new endpoints. ## Changes - ✨ New endpoint `/api/v2/users` - ⚡ Optimize database queries - 📚 Update API documentation ## Testing - [x] Unit tests added - [x] Integration tests pass - [ ] Performance benchmarks ## Breaking Changes None ## Related Issues Closes #123
$ python3 scripts/main.py branch-strategy 🌿 Branch Strategy ================== Current branch: feature/payment Base branch: main Recommended workflow: 1. Keep feature branch up to date: git fetch origin git rebase origin/main 2. Squash commits before merge: git rebase -i HEAD~3 3. Merge strategy: git checkout main git merge --no-ff feature/payment ⚠️ Warning: Branch is 5 commits behind main
一键完成提交流程:
$ python3 scripts/main.py smart-commit 🔍 Checking repository status... 📦 Staging all changes... 📝 Generating commit message... Suggested: feat(payment): add Stripe integration Use this message? [Y/n/e(edit)]: y ✅ Committed: feat(payment): add Stripe integration Next steps: - git push origin feature/payment - Create PR: https://github.com/user/repo/compare/main...feature/payment
$ python3 scripts/main.py check-branches 🧹 Branch Cleanup ================= Stale branches (merged to main): - feature/old-login (last updated 30 days ago) - hotfix/temp-fix (last updated 45 days ago) Active branches: - feature/new-ui (2 days ago) - bugfix/auth-error (1 day ago) Delete stale branches? [y/N]: y ✅ Deleted 2 stale branches
.git-workflow.json:
{
"commit_style": "conventional",
"pr_template": ".github/pull_request_template.md",
"auto_stage": false,
"commit_types": {
"feat": "✨",
"fix": "🐛",
"docs": "📚",
"style": "💎",
"refactor": "♻️",
"test": "🧪",
"chore": "🔧"
}
}
添加到 .gitconfig:
[alias]
cm = !python3 /path/to/git-workflow/scripts/main.py suggest-commit
pr = !python3 /path/to/git-workflow/scripts/main.py pr-description
smart = !python3 /path/to/git-workflow/scripts/main.py smart-commit
使用:
git cm # 生成提交信息 git pr # 生成 PR 描述 git smart # 智能提交
# .github/workflows/pr.yml
name: PR Helper
on:
pull_request:
types: [opened]
jobs:
description:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Generate PR Description
run: |
DESC=$(python3 skills/git-workflow/scripts/main.py pr-description --base main)
echo "$DESC" >> $GITHUB_STEP_SUMMARY
# 1. 开发完成,查看变更 git diff # 2. 生成提交信息 python3 main.py suggest-commit # 3. 提交 git commit -m "feat: add user authentication" # 4. 推送 git push origin feature/auth
# 1. 推送到远程 git push origin feature/api-v2 # 2. 生成 PR 描述 python3 main.py pr-description --base main --head feature/api-v2 # 3. 复制输出到 GitHub PR
# 检查分支状态 python3 main.py check-branches # 删除已合并分支 python3 main.py check-branches --delete-merged
skills/git-workflow/
├── SKILL.md # 本文件
└── scripts/
├── main.py # ⭐ 统一入口
├── commit_generator.py # 提交信息生成
├── pr_generator.py # PR 描述生成
└── branch_manager.py # 分支管理