SuperAPI AI Directory

git-workflow

Office & productivity

View repository

Updated 10-15 23:48

About this skill

Git Workflow Assistant

Core Principles

  • Only perform the Git actions the user explicitly requests. Generating a commit message does not equal staging or committing; committing does not equal pushing; creating a PR does not equal merging a PR, closing an Issue, or publishing a Release.
  • Treat existing, untracked, and unrelated modifications in the working tree as user assets; do not overwrite, revert, or mix them into this round of commits.
  • Prefer non-interactive commands. Reduce the degree of automation when history rewriting, conflict resolution, or remote overwriting is involved.

Workflow

1. Read repository rules and status

First read the applicable AGENTS.md、CONTRIBUTING.md, README, commit conventions, and CI instructions, then check:

git status --short --branch
git diff
git diff --cached
git log --oneline -10
git remote -v
git branch -vv

Also identify untracked files, the current branch, upstream, remote differences, and existing failures. Do not look only at the staged diff.

2. Clarify actions and file scope

Break the user request into separate authorizations:

Action Default permission
Analyze status, generate a commit message or PR text Read-only
Stage, commit Execute only after the user requests it, and select only files relevant to this round
Create or switch branches Execute only when the user explicitly requests it; if the implementation process requires it but authorization has not been granted, first explain the reason and obtain consent
fetch, push, create PR Confirm separately that each is within the scope of the request; do not infer one from another
merge, close Issue, publish Release Must have explicit authorization
rebase, modify published history, force-update remote High risk; must have explicit authorization and meet additional conditions

When unrelated changes exist, do not use git add . or git add -A. Stage target files one by one, and use git diff --cached to review.

3. Plan atomic commits

  • Determine from the actual diff whether feat、fix、docs、refactor、test、perf or chore。
  • Follow the language, scope, and format of the repository's recent commits.
  • A commit should express only one change that can be independently understood and verified.
  • Closes #123 Use only when the corresponding Issue should indeed be automatically closed by that commit.

Commit messages follow:

<type>(<scope>): <简短描述>

<必要时说明原因、关键实现和兼容性>

<关联 Issue 或 Breaking Change>

4. Execute after verification

Before committing, first check whether the verification script will download dependencies, access external services, or produce other state, then run tests, lint, build, or documentation checks related to the changes, and record the actual commands and exit statuses. Obtain authorization first when external side effects may occur. If the baseline already has failures, explain them separately; do not mark items that were not run as passing.

After executing commit, check:

git status --short --branch
git show --stat --oneline HEAD

Before pushing, first git fetch, confirm that upstream has no new unintegrated commits; force push is prohibited.

5. Create PR

PR text should help reviewers quickly review in combination with the diff and verification results, and should at least include:

## 变更摘要

## 关键改动

## 验证结果

## 风险与回滚

## 关联 Issue

Check only the checks that were actually completed. Add screenshots, migration notes, and rollback steps only when applicable.

Rebase and history cleanup boundaries

  • Before rebase, require both the working tree and the staging area to be clean; do not automatically stash without authorization.
  • First fetch and confirm the target baseline, and if necessary create a local backup reference with the user's permission.
  • Do not rebase public branches or published commits that others depend on.
  • Prohibited git push --force. When it is truly necessary to update a private branch that the user has explicitly authorized rewriting, only use --force-with-lease。
  • When encountering a conflict, stop and report the conflicting files and available options; do not guess content ownership or resolve it on your own.

Output

Briefly report in Chinese:

  • Which Git actions were performed, and which files and branches were affected.
  • The verification actually run and its results.
  • The commit SHA, push status, and PR URL (if already performed).
  • Matters that were not performed, failed, or still require a user decision.