9.3 KiB
| name | description |
|---|---|
| batch-git-ops | Git operations for NLD project. This project has three git repos (NLDClient, NLDMisc, GamePlay) that must stay in sync. Use this skill for ANY git operation including git pull, git push, git commit, git checkout, git branch, git status, git stash, git fetch, git log, compile GamePlay DLL. All git operations in this project must consider all three repos to ensure alignment. Also triggers on compile DLL, build DLL, convert to DLL, GamePlay DLL, Unity MCP compile. |
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_directoryset 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
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:
- Run
git status --porcelainon each repo in parallel - If any repo has uncommitted changes, warn the user and ask whether to continue (stash / skip / abort)
- Run
git pullon each repo - 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:
- Check uncommitted changes in each repo (same as batch-pull step 1-2)
- For each repo, check if branch already exists:
git branch --list <branch-name> git branch -r --list "origin/<branch-name>" - If branch exists in some repos, ask user: switch to existing / skip / abort
- If base-branch specified, run
git checkout <base-branch>thengit pullfirst - Create and switch:
git checkout -b <branch-name> - Report results per repo
4. batch-checkout
Switch all repos to a specified branch.
Parameters: <branch-name> (required)
Workflow:
- Check uncommitted changes (same as above)
- For each repo, verify branch exists:
git branch -a - If a repo does NOT have the target branch:
- List all branches from
git branch -aoutput - Search for similar names using substring/prefix matching (e.g., user typed
featrue/x, actual isfeature/x) - Present similar branch names to the user
- Skip this repo but continue switching others
- List all branches from
- For repos where branch exists:
- If branch is remote-only (
remotes/origin/<name>but no local), rungit checkout -b <branch-name> origin/<branch-name> - If branch is local, run
git checkout <branch-name>
- If branch is remote-only (
- Report results:
| Repo | Result | Current Branch |
Fuzzy matching logic (applied when exact branch not found):
- Extract clean branch names from
git branch -aoutput (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 diff、git status),分析修改涉及的模块和意图,自动生成合适的 commit message。用户也可以手动指定 message 来覆盖。
格式规范:
- 人工编码修改(用户自己写的代码,AI 只是帮忙提交):
【所属模块】描述内容 - AI 编码修改(AI 在本次会话中编写/修改的代码):
【AI编码】【所属模块】描述内容
模块名称根据变更文件的路径和内容自动判断,例如:
Buff/目录下的文件 → 模块为BuffCharacter/State/目录下 → 模块为角色状态UI/目录下 → 模块为UI- 配置表相关 → 模块为
配置表 - 多个模块同时修改时,列出主要模块,如
【Buff/角色状态】
示例:
【Buff】将普攻计数时机从攻击前移到攻击后【AI编码】【UI】新增背包界面道具排序功能【AI编码】【Buff/角色】修复buff叠加时属性未正确刷新的问题
Workflow:
- For each repo in parallel, run:
git status --porcelain git diff --stat git diff - Analyze changes to determine affected modules and generate commit message
- 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
- Ask user to confirm (user may modify the message)
- For each repo with changes:
git add . git commit -m "<commit-message>" - Ask if user wants to push as well (see batch-push)
- Report results:
| Repo | Files Changed | Committed | Pushed |
6. batch-push
Push current branches for all repos.
Workflow:
- For each repo, check if remote tracking branch exists:
git rev-parse --abbrev-ref --symbolic-full-name @{u} - If no upstream, use:
git push -u origin HEAD - If upstream exists, use:
git push - Report results per repo
7. batch-fetch
Fetch remote updates without merging.
For each repo, run:
git fetch --all --prune
Report fetched updates per repo.
8. batch-stash
Stash or pop changes across all repos.
Parameters: save or pop
save: rungit stash push -m "batch-stash"on each repo (skip if clean)pop: rungit stash popon each repo (skip if stash is empty)
Report results per repo.
9. batch-log
Show recent commit history across repos.
For each repo, run:
git log --oneline -5
Present as grouped output per repo.
10. compile-gameplay-dll
Compile GamePlay source code into GamePlay_Dll/GamePlay.dll via Unity.
This step is automatically required during batch-commit when GamePlay has code changes, but can also be invoked manually.
Prerequisites — ensure repos are up-to-date: Before compiling, NLDClient and GamePlay MUST be on the latest code to avoid compile errors from version mismatch. Run the following first:
git pullin NLDClient repo (../../)git pullin GamePlay repo (Assets/Code/Scripts/GamePlay)- Call
refresh_unityvia Unity MCP to let Unity pick up file changes:CallMcpTool: server="user-unityMCP", toolName="refresh_unity", arguments={ "mode": "force", "scope": "all", "compile": "request", "wait_for_ready": true } - Check
read_consolefor compilation errors. If errors exist, stop and report.
Compile workflow:
- Call
execute_menu_itemvia Unity MCP:CallMcpTool: server="user-unityMCP", toolName="execute_menu_item", arguments={ "menu_path": "Tools/文件与路径/转换为Dll" } - Wait for compilation to complete — poll
editor_stateresource (mcpforunity://editor/state) and check theisCompilingfield until it becomesfalse - Check
read_consolefor errors:CallMcpTool: server="user-unityMCP", toolName="read_console", arguments={ "action": "get", "types": ["error"], "count": "20" } - If errors exist, report them and do NOT proceed with commit
- If successful, the updated
GamePlay.dllwill be inAssets/Code/Scripts/GamePlay_Dll/— this file belongs to the NLDClient repo
Important: After successful DLL compilation, both NLDClient (which contains the compiled DLL) and GamePlay (the source) need to be committed.
Integration with batch-commit
When batch-commit detects GamePlay has changes (via git status --porcelain):
- Before committing, check if GamePlay changes include
.csfiles - If yes, trigger the
compile-gameplay-dllworkflow above (including pulling latest for NLDClient and GamePlay) - After successful compilation, NLDClient will also have changes (the updated DLL file)
- Include both repos in the commit
- If compilation fails, abort the commit for all repos and report errors
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 |