git-kit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit Kit
Git Kit
Git 常见操作的统一入口。先按「意图路由」理解用户要做什么,落到一个分支执行,再按该分支的验收标准收尾。
本 skill 采用多文件结构。主文件只含意图路由。 命中某个分支后,按「按需加载」指引读取对应子文件执行其完整流程,避免一次性加载全部内容。
A unified entry point for common Git operations. First understand what the user intends through "Intent Routing," select exactly one route, execute that route, and then finish according to its acceptance criteria.
This skill uses a multi-file structure. The main file contains only intent routing. After matching a route, follow the "Load on Demand" instructions to read the corresponding child file and execute its complete workflow, avoiding loading everything at once.
意图路由(决策树)
Intent Routing (Decision Tree)
从用户消息解析意图,落入唯一分支。不得跳过路由直接执行。
| 分支 key | 命中信号(用户消息中出现) | 对应子文件 |
|---|---|---|
| 提交/推送当前变更("提交""push""commit""推送");起点是稳定分支时自动建工作分支 | |
| 只要 commit message 文案("写个commit消息""生成commit信息",或用户明确说"不用提交、只要文案") | |
| 分支 + 中文描述("建个分支…""切到新分支…""开个分支做XX") | |
| 创建/更新 PR/MR("提PR""创建合并请求""更新MR") | |
| 合并 PR/MR 并回主干更新("合并PR""合并MR""merge PR""把PR合掉""合入主干");命中后 head 为稳定分支时保留不删 | |
| 只给分支打版本标签并推送("打tag""打个tag""打标签""release tag""给分支打标签") | |
| | |
| 仓库瘦身/浅克隆/减小体积("瘦身""清理git历史""shallow clone") | |
| 拉取并分类自己 star 的 GitHub 仓库("分类我的star""把我star的仓库整理成清单") | |
模糊请求直接按意图覆盖交叉处理:
- 既说"提交"又说"推送" → (含生成 message);只说"信息/文案"或明确"不提交" →
commit-push。commit-message - PR/MR 相关:"合并请求"作 GitLab 术语(名词) → ;"合并"作动词(合并XX/合入XX/merge)→
pr-create。pr-merge - 与
tag的分界:release只给分支打标签就结束(任意分支、任意时机,不建平台 Release);tag是release之后的发布段——版本号已在稳定分支上,它负责打 tag、默认创建 GitHub/GitLab Release、跟踪其他后效(发布流水 / npm 等,按探测结果)并出回执。用户要「升版本/开 PR/合并」时不属于pr-merge,走release+commit-push+pr-create。pr-merge - 未命中任何信号 → 停止并询问用户具体要做的 Git 操作,不擅自动手。
参数约定(从用户消息提取,优先于任何上下文):
- :提取中文描述(候选分支名唯一依据)。
branch - :可选目标分支名;没有则探测目标仓库默认分支。
pr-create - :优先取用户显式提供的编号/URL;没有则探测当前分支关联的开放 PR/MR;无论来源,合并前都展示「编号 + 标题 + 目标分支 + head 分支及其去向(将删除 / 稳定分支保留)」并给用户三选项(是 / 否 / 自定义 id)确认;探测不到则要求用户提供编号,不猜测。head 为稳定分支时一律保留不删,判定与覆盖规则见
pr-merge与references/stable-branch.md。references/pr-merge.md - :至少给
release或--version <v> [--version-file <路径>]。哪个文件是版本源由你读仓库判定(脚本不认识任何清单格式;先验与每类现成命令见--tag <v1.1.0>):字面常量型用references/version-conventions.md+--version(边界匹配回查 + 回报行号),派生/注入型(Go ldflags、setuptools-scm、--version-file、Composer)只用${revision};发布流水硬校验版本的仓库加--tag。--require-version-match表示还没定目标版本(不是要用户报 tag),STATE=NEEDS_TARGET按STATE=BLOCKED处理(含多版本线BLOCKERS:必须显式给完整 tag);不自行改版本号。target-tag-ambiguous - :可选分支名或 tag 名(
tag);没有则探测最新 tag 与来源分支、候选分支、候选版本号并先展示给用户选择确认,不擅自决定打哪个分支/版本。目标是发布的仓库要额外对齐版本号(tag 版本必须等于版本源文件里的声明值,否则发布流水拒绝发布)——版本源文件由读仓库决定,不一致时先走$1+commit-push升版本,见pr-create「发版约束」。references/tag.md - :可选保留天数
slim;没有则默认N。30 days ago
两类消息的上下文约束:
- 命中 或
commit-message分支时,只处理用户提供的话术/描述,忽略任何代码、文件、git diff、git status 等上下文。branch - 命中 、
commit-push、pr-create、pr-merge、tag、release分支时,主动读取 git 状态是必要的(diff/remote/历史)。slim
Parse the user's intent from the message and route it to exactly one branch. Do not skip routing and execute an operation directly.
| Route key | Matching signals (present in the user's message) | Corresponding child file |
|---|---|---|
| Commit or push current changes ("commit," "push," "commit," or "push"); if the starting point is a stable branch, automatically create a working branch | |
| Only needs commit message copy ("write a commit message," "generate commit information," or the user explicitly says "do not commit, just give me the text") | |
| A branch plus a Chinese description ("create a branch…," "switch to a new branch…," "create a branch to do XX") | |
| Create or update a PR/MR ("open a PR," "create a merge request," "update the MR") | |
| Merge a PR/MR and update the main branch ("merge the PR," "merge the MR," "merge PR," or "merge it into the main branch"); after matching, retain and do not delete the head when it is a stable branch | |
| Only tag a branch with a version and push it ("create a tag," "tag it," "add a tag," "release tag," or "tag the branch") | |
| The release phase after | |
| Slim down the repository, perform a shallow clone, or reduce repository size ("slim it down," "clean up Git history," or "shallow clone") | |
| Pull and categorize the user's starred GitHub repositories ("categorize my starred repositories" or "organize my starred repositories into a list") | |
For ambiguous requests, directly handle overlaps according to the matched intent:
- Both "commit" and "push" → (including message generation); only "information/text" or an explicit "do not commit" →
commit-push.commit-message - For PR/MR-related requests: "merge request" used as a GitLab noun → ; "merge" used as a verb (merge XX, merge into XX, or merge) →
pr-create.pr-merge - The boundary between and
tag:releaseonly tags a branch and then ends (any branch, at any time, with no platform Release creation);tagis the phase afterrelease—the version is already present on a stable branch, and it is responsible for creating a tag, creating a GitHub/GitLab Release by default, tracking other downstream effects (release workflows, npm, etc., based on detection results), and producing a receipt. When the user wants to "bump the version/open a PR/merge," this does not belong topr-merge; userelease+commit-push+pr-create.pr-merge - If no signal matches → stop and ask the user which Git operation they want; do not take action without explicit intent.
Parameter conventions (extracted from the user's message and taking priority over any context):
- : extract the Chinese description (the sole basis for candidate branch names).
branch - : the target branch name is optional; if absent, detect the target repository's default branch.
pr-create - : prioritize an explicitly provided number or URL; if absent, detect an open PR/MR associated with the current branch. Regardless of the source, before merging, display the "number + title + target branch + head branch and its destination (will be deleted / retained because it is a stable branch)" and ask the user to confirm using three options (yes / no / custom ID). If nothing can be detected, require the user to provide a number and do not guess. When the head is a stable branch, always retain it and do not delete it; see
pr-mergeandreferences/stable-branch.mdfor detection and override rules.references/pr-merge.md - : provide at least
releaseor--version <v> [--version-file <path>]. Determine which file is the version source by reading the repository (the script does not recognize any manifest format; first identify the applicable existing commands for each convention in--tag <v1.1.0>): for literal constant versions, usereferences/version-conventions.md+--version(perform boundary-match verification and report the line number); for derived or injected versions (Go ldflags, setuptools-scm,--version-file, Composer), use only${revision}; for repositories whose release workflows strictly validate versions, add--tag.--require-version-matchmeans the target version has not yet been determined (this does not mean asking the user for a tag). HandleSTATE=NEEDS_TARGETaccording toSTATE=BLOCKED(including the multi-version-lineBLOCKERS: a complete tag must be provided explicitly). Do not change version numbers on your own.target-tag-ambiguous - : the branch name or tag name (
tag) is optional; if absent, detect the latest tag and its source branch, candidate branches, and candidate version numbers, then display them for the user to select and confirm before deciding which branch or version to tag. For repositories where the target is a release, additionally align the version number (the tag version must exactly match the value declared in the version source file; otherwise the release workflow will reject the release). Determine the version source file by reading the repository. If they do not match, first follow$1+commit-pushto bump the version; see the "Release Constraints" section inpr-create.references/tag.md - : the retention period
slimis optional; if absent, default toN.30 days ago
Context constraints for the two message types:
- When matching the or
commit-messageroute, process only the wording or description provided by the user and ignore all code, files, Git diffs, Git status, and other context.branch - When matching ,
commit-push,pr-create,pr-merge,tag, orrelease, proactively reading Git status is necessary (diff, remote, and history).slim
按需加载
Load on Demand
确认分支后,执行以下子文件的完整流程:
- 或
commit-push:先commit-message,再read references/commit-format.md,最后按该文件执行。read references/<对应分支>.md另需先commit-push(起点是稳定分支时自动建分支,发版升版本不例外)。read references/stable-branch.md - :
branch。read references/branch.md - :先
pr-create(gh/glab 的仓库参数规则),再read references/repo-id.md。read references/pr-create.md - :先
pr-merge(判定 head 是否保留)与read references/stable-branch.md(gh/glab 的仓库参数规则),再read references/repo-id.md。read references/pr-merge.md - :先
tag(候选分支的稳定分支偏好),再read references/stable-branch.md(含「发版约束」:版本号对齐与升版本顺序),并用read references/tag.md生成注记正文(推送前让用户确认)。scripts/changelog.sh --link-to <tag> - :先
release(决策点一律用选项式提问,不打印现状等人用自然语言回答),再read references/ask-options.md(先认出仓库属于哪类版本约定,照该类命令取证),再read references/version-conventions.md(发布段流程与计划卡),再read references/release.md「发版约束」(版本对齐与注记 tag),运行read references/tag.md做只读预检(版本源要自己读仓库声明:scripts/release-preflight.sh或--version <v> --version-file <路径>,脚本只回查「声明的文件里有没有这个版本」;返回--tag <tag>决定是打 tag、只验证、还是先定版本源;同时给出STATE/RELEASE_PLATFORM/RELEASE_CLI_READY决定 Release 是创建还是只校验,RELEASE_EXISTS给出发布步骤原文;EFFECT_HINTS非空即停,BLOCKERS只如实报告),用WARN生成并落盘变更说明(scripts/changelog.sh --link-to <tag>进 tag 注记与 Release body,推送前过目;之后不再重算);Release 默认由流程创建(BODY时只校验,不重复建)。打 tag 与创建/校验 Release 后,用EFFECT_RELEASE=workflow等流水 + 验 Release + 验产物(一次出scripts/release-verify.sh --platform <p> --tag <tag> [--probe-url <产物 URL>]回执;产物无公开地址就不传,以流水结论为准;npm 仓可用KEY=VALUE别名;默认 3 分钟 / 5 秒,--npm-pkg <包名>给出失败/未知原因)。若用户选择把变更写进VERIFY_REASONS:CHANGELOG.md→ 开changelog.sh --from <上个 tag> --to <BASE_REF> --version <tag> --link-to <tag> --write CHANGELOG.md分支 →docs/changelog-<tag>→pr-create→ 重新预检,再打 tag(正文仍用先前冻结那份)。pr-merge - :
slim,按其中指引运行read references/slim.md(脚本为单一真源,与scripts/git-slim.sh命令共用)。/git/slim - :
star-classify,按其中指引运行read references/star-classify.md。scripts/git-star.sh
After confirming the route, execute the complete workflow in the corresponding child file:
- or
commit-push: firstcommit-message, thenread references/commit-format.md, and finally execute the instructions in that file.read references/<corresponding route>.mdadditionally requirescommit-pushfirst (automatically create a branch when the starting point is a stable branch, including when bumping a version for a release).read references/stable-branch.md - :
branch.read references/branch.md - : first
pr-create(repository parameter rules for gh/glab), thenread references/repo-id.md.read references/pr-create.md - : first
pr-merge(determine whether to retain the head) andread references/stable-branch.md(repository parameter rules for gh/glab), thenread references/repo-id.md.read references/pr-merge.md - : first
tag(stable branch preference for candidate branches), thenread references/stable-branch.md(including "Release Constraints": version alignment and version bump order), and useread references/tag.mdto generate the annotation body (have the user review it before pushing).scripts/changelog.sh --link-to <tag> - : first
release(always ask questions at decision points using options, rather than printing the current state and waiting for a natural-language answer), thenread references/ask-options.md(first identify the repository's version convention and collect evidence using the corresponding commands), thenread references/version-conventions.md(release phase workflow and plan card), then the "Release Constraints" section ofread references/release.md(version alignment and annotation tag). Runreferences/tag.mdfor a read-only preflight check (read the version source from the repository's declarations:scripts/release-preflight.shor--version <v> --version-file <path>; the script only verifies whether the declared file contains that version). The returned--tag <tag>determines whether to create a tag, perform verification only, or first identify the version source;STATE/RELEASE_PLATFORM/RELEASE_CLI_READYdetermine whether the Release should be created or only verified, andRELEASE_EXISTSprovides the original publishing steps. IfEFFECT_HINTSis non-empty, stop; reportBLOCKERSitems honestly. UseWARNto generate and persist the release notes (thescripts/changelog.sh --link-to <tag>is used for both the tag annotation and the Release body, and must be reviewed before pushing; do not recalculate it afterward). The Release is created by default as part of the workflow (whenBODY, only verify it and do not create it again). After creating the tag and creating or verifying the Release, useEFFECT_RELEASE=workflowand other workflows to verify the Release and artifacts (produce ascripts/release-verify.sh --platform <p> --tag <tag> [--probe-url <artifact URL>]receipt in one pass; if an artifact has no public URL, do not pass the option and use the workflow result as authoritative; for npm repositories, theKEY=VALUEalias is available; defaults are 3 minutes / 5 seconds, and--npm-pkg <package name>explains failures or unknown outcomes). If the user chooses to write the changes intoVERIFY_REASONS:CHANGELOG.md→ create achangelog.sh --from <previous tag> --to <BASE_REF> --version <tag> --link-to <tag> --write CHANGELOG.mdbranch →docs/changelog-<tag>→pr-create→ run the preflight check again, then create the tag (the body remains the previously frozen version).pr-merge - :
slimand follow its instructions to runread references/slim.md(the script is the single source of truth and is shared with thescripts/git-slim.shcommand)./git/slim - :
star-classifyand follow its instructions to runread references/star-classify.md.scripts/git-star.sh