AgentSkillsCN

push

将提交推送到远程仓库,并可选择创建PR。当用户希望推送自己的更改时,可使用此功能。

SKILL.md
--- frontmatter
name: push
description: Push commits to remote and optionally create a PR. Use when the user wants to push their changes.
disable-model-invocation: true
user-invocable: true
allowed-tools: mcp__acp__Bash

Push Changes: $ARGUMENTS

CRITICAL: Use mcp__acp__Bash for ALL git commands. NEVER use the Task subagent or the built-in Bash tool — they run in an isolated sandbox. Pushes will NOT persist there.

Follow these steps in order. Do not skip steps.

Step 1: Assess State

Run:

  • git branch --show-current to get the current branch

  • git remote -v to verify a remote exists

  • git log origin/<branch>..HEAD --oneline to list unpushed commits

  • If no remote is configured: Inform the user and stop.

  • If no unpushed commits: Inform the user everything is up to date. Stop.

  • If unpushed commits exist: Proceed to Step 2.

Step 2: Preview

Show the user:

  • Current branch name
  • Number of commits to push
  • Commit list (git log origin/<branch>..HEAD --oneline)
  • Files changed (git diff origin/<branch>..HEAD --stat)

Safety Check

  • If pushing to main or master: Warn the user explicitly and ask for confirmation before proceeding.

Step 3: Push

Execute git push origin <branch>.

  • Never use --force or --force-with-lease
  • If the push is rejected (e.g., remote has new commits), inform the user and suggest git pull --rebase first. Do not force-push.

Show the push result.

Step 4: Offer PR Creation (Optional)

If the current branch is not main or master:

  • Ask the user if they want to create a pull request
  • If yes, run gh pr create --fill or let the user customize the title/body
  • If $ARGUMENTS contains PR-related instructions, use them

If already on main/master, skip this step.

Rules

  • Never force-push under any circumstances
  • Never push without showing what will be pushed first
  • Respect branch protection — if push fails, report the error clearly