SuperAPI AI 工具集

git workflow with conventional commits

编程与开发

查看项目

更新于 10-16 04:38

技能介绍

用途

该技能提供符合 Conventional Commits 规范与 Miyabi PR 指南的完整 Git 工作流自动化,覆盖暂存、提交、创建 PR 与合并等环节。

主要能力

  • 按 Conventional Commits 格式生成提交消息,结构为 <type>(<scope>): <subject>,可包含 body 与 footer。
  • 提供提交类型清单(按优先级):feat、fix、docs、refactor、test、chore、style、perf、ci、build、revert,并给出用途、频率与示例。
  • 提供范围(scope)清单:auth、api、db、ui、cli、agent、worktree、deps 等。
  • 提供三种工作流模式:标准提交、PR 创建、合并策略。
  • 提供分支命名规则:<type>/<issue-number>-<brief-description>。
  • 提供 Worktree 从创建到合并的完整流程。
  • 提供错误处理方案:pre-commit hook、合并冲突、误提交分支、误提交密钥。
  • 提供提交前与 PR 创建前的检查清单。

使用方式

调用触发场景包括:提交变更(如“commit these changes”)、创建 PR(如“create a PR”)、合并分支(如“merge this branch”)、功能完成后、评审反馈后。

标准提交流程:

  1. 查看状态:git status && git diff --name-status
  2. 暂存:git add <files>
  3. 提交(使用 HEREDOC):
git commit -m "$(cat <<'EOF'
feat(agent): add CodeGenAgent implementation

Implement CodeGenAgent for AI-driven code generation:
- Add BaseAgent trait implementation
- Support for Rust, TypeScript, Python
- Automatic test generation

Closes #270

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
  1. 推送:git push -u origin feature/270-codegen-agent

PR 创建(使用 GitHub CLI):

gh pr create \
  --title "feat(agent): Issue #270 - Add CodeGenAgent" \
  --body "$(cat <<'EOF'
## Summary
Implements CodeGenAgent for AI-driven code generation.

## Changes
- ✅ Add `crates/miyabi-agents/src/codegen.rs`
- ✅ Implement BaseAgent trait
- ✅ Add unit tests (85% coverage)

## Test Plan
- [x] Unit tests pass
- [x] Clippy warnings resolved
- [x] Format check passed

## Related Issues
Closes #270

## Quality Report
- **Score**: 85/100 ✅
- **Coverage**: 85%

🤖 Generated with [Claude Code](https://claude.com/claude-code)
EOF
)" \
  --draft

合并策略:

  • Squash(推荐):gh pr merge --squash --delete-branch,用于大半 PR。
  • Merge:gh pr merge --merge --delete-branch,用于大规模功能。
  • Rebase:gh pr merge --rebase --delete-branch,用于单提交 PR。

Worktree 工作流:

# Step 1: Worktree创建
git worktree add .worktrees/issue-270 -b feature/270-codegen-agent

# Step 2: Worktree内作业
cd .worktrees/issue-270
# ... 变更 ...
git add .
git commit -m "feat(agent): add CodeGenAgent"

# Step 3: 推送
git push -u origin feature/270-codegen-agent

# Step 4: PR创建
gh pr create --title "feat(agent): Issue #270" --draft

# Step 5: 清理(合并后)
cd ../..
git worktree remove .worktrees/issue-270
git push origin --delete feature/270-codegen-agent
git branch -d feature/270-codegen-agent

错误处理:

  • Pre-commit Hook:git status 确认,git add .、git commit --amend --no-edit、git push --force-with-lease。
  • 合并冲突:git status、git diff 查看,解决后 git add <resolved-files>、git merge --continue 或 git rebase --continue。
  • 误提交到错误分支:git reset --soft HEAD~1,git checkout correct-branch,重新 git add . 与 git commit -m "Your message"。
  • 误提交密钥:git rm --cached path/to/secret-file、git commit --amend --no-edit、git push --force-with-lease;旧提交使用 git-filter-repo。

检查清单:

  • 提交前:测试通过(cargo test)、无 Clippy 警告(cargo clippy)、已格式化(cargo fmt)、无密钥、符合 Conventional Commits、变更与 Issue 需求一致、必要时更新文档。
  • PR 创建前:标题符合规范、描述完整、CI 通过、无冲突、分配评审者、添加标签、关联 Issue(Closes #XXX)。

适用场景

适用于需要规范化提交信息、自动化 PR 创建与合并、使用 Worktree 隔离开发、以及处理常见 Git 错误的开发流程。

限制

资料未提供该技能的具体安装命令、收费方式、支持平台范围及实际效果数据,暂未提供。