This skill orchestrates Flutter project Git and GitHub workflows, including commits, pushes, PRs, rebases, and branch management to streamline collaboration.
npx playbooks add skill aidenreed937/comet --skill git-github
提供 Flutter 项目的 Git 版本控制和 GitHub 仓库管理的完整工作流。
为避免消耗主窗口上下文,所有 Git 操作应通过子代理执行
Git 操作(尤其是提交、PR 创建)需要:
git status、git diff、git log 输出(大量 token)使用子代理的好处:
用户请求示例(会自动触发此 skill):
"git提交当前分支的变更"
"创建PR合并到main"
"rebase到最新main分支"
"推送代码到远程"
Claude 行为:
general-purpose 子代理当收到 Git 操作请求时,应该:
// ❌ 错误:直接在主窗口执行
Bash('git status')
Bash('git diff')
// ... 消耗大量主窗口 token
// ✅ 正确:启动子代理执行
Task({
subagent_type: 'general-purpose',
description: '提交当前分支变更',
prompt: `
请执行以下 Git 操作:
1. 查看当前变更状态(git status、git diff)
2. 分析变更内容并编写符合规范的提交信息
3. 使用 Conventional Commits 格式创建提交
4. 添加 Claude Code 签名
5. 返回提交 hash 和摘要
遵循 .claude/skills/git-github/SKILL.md 中的规范。
`,
})
| Git 操作 | 推荐方式 | 原因 |
| ------------------------ | --------- | ------------------------------------------- |
| 提交变更 (git commit) | 🤖 子代理 | 需读取 diff、status、log,消耗大量 token |
| 创建 PR (gh pr create) | 🤖 子代理 | 需分析完整变更历史,编写 PR 描述 |
| Rebase 操作 | 🤖 子代理 | 可能需处理冲突,中间状态复杂 |
| 合并分支 | 🤖 子代理 | 同上 |
| 查看简单状态 | 📝 主窗口 | 输出少(如 git branch、gh auth status) |
---
禁止直接修改 main 分支!
pnpm quality)main - 主分支,保持稳定可发布状态feature/<name> - 功能分支,如 feature/user-authfix/<name> - 修复分支,如 fix/login-bughotfix/<name> - 紧急修复分支refactor/<name> - 重构分支docs/<name> - 文档更新分支原则:先 rebase,后 PR,保持线性历史
# 1. 创建功能分支
git checkout main
git pull origin main
git checkout -b feature/your-feature
# 2. 开发过程中定期同步 main
git fetch origin main
git rebase origin/main
# 3. 完成开发后确保代码质量
flutter analyze
dart format .
flutter test
# 4. Rebase 到最新 main
git fetch origin main
git rebase origin/main
# 5. 解决冲突(如有)
# 编辑冲突文件后:
git add <conflicted-files>
git rebase --continue
# 6. 强制推送(rebase 后必须 force push)
git push --force-with-lease origin feature/your-feature
# 7. 创建 PR
gh pr create --base main --head feature/your-feature \
--title "feat: 功能描述" \
--body "$(cat <<'EOF'
## Summary
- 变更点1
- 变更点2
## Test plan
- [ ] 测试项1
- [ ] 测试项2
🤖 Generated with [Claude Code](https://claude.com/claude-code)
EOF
)"
# 8. 合并前检查清单
# ✅ flutter analyze 通过
# ✅ flutter test 通过
# ✅ 已 rebase 到最新 main,无冲突
# ✅ PR 已创建并审核通过
# 9. 合并 PR(推荐 squash merge)
gh pr merge <pr-number> --squash --delete-branch
# 10. 合并后清理
git checkout main
git pull origin main
格式:<type>(<scope>): <subject>
| 类型 | 说明 |
| -------- | ----------------------- |
| feat | 新功能 |
| fix | 修复 bug |
| docs | 文档变更 |
| style | 代码格式(不影响逻辑) |
| refactor | 重构(非新功能/非修复) |
| perf | 性能优化 |
| test | 测试相关 |
| build | 构建/依赖变更 |
| ci | CI 配置变更 |
| chore | 其他杂项 |
# 简单提交
git commit -m "feat: 添加用户登录功能"
# 带 scope
git commit -m "fix(api): 修复请求超时处理"
# 完整提交(使用 HEREDOC)
git commit -m "$(cat <<'EOF'
feat(auth): 添加 JWT token 刷新机制
- 添加 token 过期检测
- 实现自动刷新逻辑
- 更新请求拦截器
Closes #123
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
flutter pub get 生成<type>(<scope>): <description>
示例:
feat: 添加用户认证模块fix(auth): 修复登录状态丢失问题docs: 更新 README 安装说明## Summary
- 简要描述变更内容(1-3 点)
## Test plan
- [ ] 验证项1
- [ ] 验证项2
🤖 Generated with [Claude Code](https://claude.com/claude-code)
gh auth status
# 创建私有仓库并推送
gh repo create <repo-name> --private --source=. --push
# 创建公开仓库
gh repo create <repo-name> --public --source=. --push
# 设置默认分支
gh repo edit --default-branch main
# 列出 PR
gh pr list
# 查看 PR 详情
gh pr view <pr-number>
# 查看 PR 状态(JSON 格式)
gh pr view <pr-number> --json state,mergedAt
# Squash 合并并删除分支
gh pr merge <pr-number> --squash --delete-branch
# 普通合并
gh pr merge <pr-number> --merge
# Rebase 合并
gh pr merge <pr-number> --rebase
# 从 main 创建 hotfix 分支
git checkout main
git pull origin main
git checkout -b hotfix/critical-bug
# 修复后直接推送并创建 PR
git push -u origin hotfix/critical-bug
gh pr create --base main --title "hotfix: 紧急修复描述"
# 合并后同步到其他开发分支
git checkout feature/xxx
git rebase main
git branch -a # 查看所有分支
git checkout -b feature/xxx # 创建并切换分支
git branch -d feature/xxx # 删除本地分支
git branch -m master main # 重命名分支
git remote -v # 查看远程仓库
git push -u origin main # 推送并设置上游
git push --force-with-lease # 安全强制推送
git pull --rebase origin main # 拉取并 rebase
git reset --soft HEAD~1 # 撤销提交,保留更改
git reset --hard HEAD~1 # 完全撤销(慎用)
git commit --amend -m "新消息" # 修改最近提交信息
git log --oneline -10 # 简洁历史
git log --oneline --graph --all # 图形化历史
git diff main..HEAD # 查看与 main 的差异
flutter analyze 和 flutter test--force 推送--force-with-lease 代替 --force(仅限 feature 分支).gitignore 排除不需要版本控制的文件(build/, .dart_tool/, *.g.dart 等)Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.