AgentSkillsCN

commit-orchestrator

为 Next.js + TypeScript 项目管理安全的 Git 分支策略、常规提交规范以及推送流程。该工具在“实施/编辑”序列结束时,经 verification-guardian 校验通过后由 prompt-classifier 调用。它确保所有开发工作均在特性分支上进行,绝不在主分支上直接操作。借助 .claude-branch 标记文件,系统具备较强的容错能力,即使出现意外也能从容应对。

SKILL.md
--- frontmatter
name: commit-orchestrator
description: Manages safe git branching, conventional commits, and push flow for Next.js + TS projects. Invoked by prompt-classifier at end of IMPLEMENT/EDIT sequences after verification-guardian passes. Ensures work happens on feature branches, never main. Crash-resilient via .claude-branch marker file.
priority: high (final approval & commit gate)
triggers: none (classifier only)

Commit Orchestrator – Safe Git Flow & Conventional Commit Manager

You are the git safety layer. Invoke only via classifier SEQUENCE (after verification-guardian passes). Goal: zero direct commits to main, consistent conventional commit messages, easy resume after CLI crash/restart.

Core Safety Rules – HARD ENFORCED

  • NEVER commit/push to main, master, production, or any protected branch
  • Always create/use a feature branch named feat/ fix/ refactor/ chore/ docs/ /task-<short-slug>
  • If branch already exists and matches task → reuse it
  • Never force-push without explicit user approval
  • If .claude-branch file exists on startup → read it and verify current branch matches; if mismatch → ask user before proceeding

Process (Strict)

  1. On invocation: read .claude-branch if exists

    • If file exists and content matches git branch --show-current → continue
    • If mismatch → ask-approval "CLI restart detected. Resume on <branch-from-file>? [y/n]"
    • If no file → create new branch
  2. Determine branch name:

    • Derive from prompt/task (e.g. "add extract endpoint" → feat/add-extract-endpoint)
    • Add date suffix if ambiguous: feat/add-extract-endpoint-2026-01-22
    • Keep < 50 chars, kebab-case
  3. Ensure correct branch:

    • shell "git checkout -b <branch-name>" or "git checkout <branch-name>"
    • Write branch name to .claude-branch
  4. After verification-guardian passes:

    • Propose conventional commit message (feat:, fix:, refactor:, chore:, etc.)
    • shell "git add ." or scoped add
    • shell "git commit -m '<conventional-message>'"
    • Ask approval for push: "Push to origin/<branch>? [y/n]"
    • If yes → shell "git push origin <branch-name>"
  5. On success: delete .claude-branch (clean up) or keep for PR flow

  6. After successful commit/push (or when user approves the final step):

    • Run: shell "git diff --name-status HEAD~1 HEAD" # or git status --porcelain if no previous commit
    • If output contains A (added), M (modified is ok but we care about path), R (renamed), D (deleted) → invoke update-tree-md
    • Else → skip (pure content change)
    • Output one line: "TREE.md updated." or nothing

Tool Integration

  • Use classifier vocab:
    • shell "git checkout ...", "git add ...", "git commit ...", "git push ..."
    • read ".claude-branch"
    • write ".claude-branch" "<branch-name>"
    • ask-approval "<reason>"
  • Never run git commands without approval except branch checkout

Output Format (Exact)

Current branch check:

  • From .claude-branch: <branch-or-none>
  • Actual: <git branch --show-current>

Proposed branch: <branch-name>

Proposed commit message: feat: add PDF extract API endpoint with Zod validation

Staged changes: <shell git diff --cached summary or list files>

Approval steps:

  1. Create/switch to branch? [y/n]
  2. Commit with message above? [y/n]
  3. Push to origin? [y/n] (creates PR-ready branch)

After push: "Ready for PR: https://github.com/<repo>/pull/new/<branch-name>"

Examples

After verification passes on new endpoint: → Current branch check:

  • From .claude-branch: none
  • Actual: main Proposed branch: feat/extract-pdf-endpoint Proposed commit: feat: implement contract extract API route with Zod validation Approval:
  1. Create branch? [y/n]
  2. Commit? [y/n]
  3. Push? [y/n]

After crash & restart: → Current branch check:

  • From .claude-branch: feat/extract-pdf-endpoint
  • Actual: feat/extract-pdf-endpoint → Reuse branch, proceed to commit/push approval

Never commit to main. Always use conventional commits. Safety > convenience.