NLDClient-yudde/.cursor/skills/batch-git-ops/SKILL.md

7.4 KiB
Raw Blame History

name description version updated
batch-git-ops 三仓 Git 操作NLDClient/NLDMisc/GamePlay。触发关键词git pull push commit checkout branch status stash fetch log、三仓同步、batch git。 1.0 2026-05-08

Batch Git Operations

Perform git operations across three project repositories simultaneously.

Repository Definitions

All paths are relative to the workspace root (ProjectNLD). Use forward slashes only.

Name Relative Path Description
NLDClient ../../ Main client repo
NLDMisc ../../../NLDMisc Config/data repo
GamePlay Assets/Code/Scripts/GamePlay Core gameplay code repo

Cross-Platform Rules

  • Execute git commands via the Shell tool with working_directory set to each repo's absolute path (resolve from workspace root + relative path)
  • Issue one Shell call per repo per command (parallelizable when independent)
  • Never use && to chain commands (PowerShell incompatible)
  • Never use \ in paths; always use /
  • Always remind the user that git operations carry risk before proceeding

不适用场景

  • 只修改了单个仓库的单个文件且无需同步其他仓库 → 不需要走三仓流程
  • AI 未经用户要求主动做 git 操作 → 遵循 git-safety 协议,不主动操作

Operations

核心操作(高频)

1. batch-status

Show current state of all repos.

For each repo, run:

git status -sb

Present results in a summary table:

| Repo | Branch | Clean | Ahead/Behind |

2. batch-pull

Pull latest changes for all repos.

Workflow:

  1. Run git status --porcelain on each repo in parallel
  2. If any repo has uncommitted changes, warn the user and ask whether to continue (stash / skip / abort)
  3. Run git pull on each repo
  4. Report results:
| Repo | Result | Details |

Result values: updated / already up-to-date / conflict / error

3. batch-create-branch

Create a new branch with the same name in all repos and switch to it.

Parameters: <branch-name> (required), <base-branch> (optional, default: current branch)

Workflow:

  1. Check uncommitted changes in each repo (same as batch-pull step 1-2)
  2. For each repo, check if branch already exists:
    git branch --list <branch-name>
    git branch -r --list "origin/<branch-name>"
    
  3. If branch exists in some repos, ask user: switch to existing / skip / abort
  4. If base-branch specified, run git checkout <base-branch> then git pull first
  5. Create and switch: git checkout -b <branch-name>
  6. Report results per repo

4. batch-checkout

Switch all repos to a specified branch.

Parameters: <branch-name> (required)

Workflow:

  1. Check uncommitted changes (same as above)
  2. For each repo, verify branch exists:
    git branch -a
    
  3. If a repo does NOT have the target branch:
    • List all branches from git branch -a output
    • Search for similar names using substring/prefix matching (e.g., user typed featrue/x, actual is feature/x)
    • Present similar branch names to the user
    • Skip this repo but continue switching others
  4. For repos where branch exists:
    • If branch is remote-only (remotes/origin/<name> but no local), run git checkout -b <branch-name> origin/<branch-name>
    • If branch is local, run git checkout <branch-name>
  5. Report results:
| Repo | Result | Current Branch |

Fuzzy matching logic (applied when exact branch not found):

  • Extract clean branch names from git branch -a output (strip whitespace, *, remotes/origin/ prefix)
  • Check for: exact case-insensitive match, substring containment, common typo patterns (transposed chars)
  • Present top 5 closest matches to user

5. batch-commit

Commit changes in all repos with the same message.

Parameters: <commit-message> (optional — if not provided, AI must auto-generate)

Commit Message Rules:

AI 必须自动检索所有仓库的变更内容(git diffgit status),分析修改涉及的模块和意图,自动生成合适的 commit message。用户也可以手动指定 message 来覆盖。

格式规范:

  • 人工编码修改用户自己写的代码AI 只是帮忙提交):【所属模块】描述内容
  • AI 编码修改AI 在本次会话中编写/修改的代码):【AI编码】【所属模块】描述内容

模块名称根据变更文件的路径和内容自动判断,例如:

  • Buff/ 目录下的文件 → 模块为 Buff
  • Character/State/ 目录下 → 模块为 角色状态
  • UI/ 目录下 → 模块为 UI
  • 配置表相关 → 模块为 配置表
  • 多个模块同时修改时,列出主要模块,如 【Buff/角色状态】

示例:

  • 【Buff】将普攻计数时机从攻击前移到攻击后
  • 【AI编码】【UI】新增背包界面道具排序功能
  • 【AI编码】【Buff/角色】修复buff叠加时属性未正确刷新的问题

Workflow:

  1. For each repo in parallel, run:
    git status --porcelain
    git diff --stat
    git diff
    
  2. Analyze changes to determine affected modules and generate commit message
  3. Present a summary showing changed files per repo, the auto-generated commit message, and whether it's AI-authored code. If a repo has no changes, note it will be skipped
  4. Ask user to confirm (user may modify the message)
  5. For each repo with changes:
    git add .
    git commit -m "<commit-message>"
    
  6. Ask if user wants to push as well (see batch-push)
  7. Report results:
| Repo | Files Changed | Committed | Pushed |

6. batch-push

Push current branches for all repos.

Workflow:

  1. For each repo, check if remote tracking branch exists:
    git rev-parse --abbrev-ref --symbolic-full-name @{u}
    
  2. If no upstream, use: git push -u origin HEAD
  3. If upstream exists, use: git push
  4. Report results per repo

7. batch-fetch / batch-stash / batch-log低频

简洁操作,不再展开详细流程:

  • batch-fetch: 每个仓库执行 git fetch --all --prune,报告更新情况
  • batch-stash <save|pop>: save 时 git stash push -m "batch-stash"pop 时 git stash pop;跳过无变更仓库
  • batch-log: 每个仓库执行 git log --oneline -5,汇总展示

Present as grouped output per repo.

10. compile-gameplay-dll

详细编译流程见 compile-gameplay-dll 技能的 SKILL.md,此处仅说明与 batch-commit 的集成逻辑。

batch-commit 检测到 GamePlay 有 .cs 文件变更时:

  1. 提交前自动触发 compile-gameplay-dll 技能的编译流程
  2. 编译成功后 NLDClient 也会有变更(更新的 DLL 文件),一并纳入提交
  3. 编译失败 → 中止所有仓库的提交并报告错误

Safety Rules

  • NEVER run --force, --hard, reset, or any destructive git command
  • NEVER skip user confirmation before commits or branch operations
  • If any operation fails or produces a conflict, stop and report immediately — do not continue silently
  • Each repo operates independently: one repo's failure must not block others
  • Always show a summary report after batch operations complete

Output Format

Always present results in a structured table for quick scanning. Example:

## Batch Operation Results

| Repo | Operation | Result | Details |
|------|-----------|--------|---------|
| NLDClient | pull | updated | 3 files changed |
| NLDMisc | pull | up-to-date | — |
| GamePlay | pull | updated | 12 files changed |