/sumsec-skills:git-commit-prfrom sumsec-skills
Automates safe git commit, push, and PR/MR creation with branch management, commit message generation, and failure handling.
Ships in sumsec-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
用于在真实仓库里安全地完成 commit、push、PR/MR。
目标不是“机械跑命令”,而是先识别仓库状态、分支状态、远程状态和平台能力,再选择合适路径执行。
仅提交、仅创建 PR/MR、提交并创建 PR/MRgh CLI 自动创建 PR,失败时降级为平台链接git add .;先列出变更,再确认是“全部提交”还是“指定文件提交”。.env、密钥、凭证、tokens、私钥导出文件;若用户坚持,先明确提醒风险。git config。--force / --force-with-lease / --amend / --no-verify;只有用户明确同意后才能使用。master / main 且要新增本地提交,优先新建分支,不要直接在主干上开发式提交。先确认用户属于哪一种目标,再走对应路径:
若用户描述不清,先问一句:
“你是要我只提交 commit,还是要连 push 和 PR 一起做?”
开始前至少检查以下信息:
git status --short --branchgit diff --statgit diff --cached --statgit log --pretty=format:"%s" -n 20git branch --show-currentgit remote -v若要创建 PR,再补:
git remote show origin 或等价命令,确认默认基线分支gh auth statusgit diff <base-branch>...HEAD --stat,确认确实有 PR 内容git status,确保当前目录是 git 仓库。git remote -v,确认至少存在一个远程。origin、upstream),在推送和建 PR 前确认使用哪个远程。gh auth status;未登录则提示用户先登录,或降级为创建链接。unstagedstageduntrackedpush / PR。git add <files>git branch --show-current。master 或 main:
feat/<description>fix/<description>docs/<description>refactor/<description>chore/<description>git log --pretty=format:"%s" -n 30docs(skill-name): ...、fix(skill-name): ...。subject 行:保持单行、不加句号、动词前置,概括本次提交的核心意图。
body 必须详尽:无论改动大小,body 应完整描述本次变动的所有内容:
body 使用多行格式,每个要点用 - 列出,便于阅读。
若要带 body,优先使用 heredoc 格式,避免转义错误:
git commit -m "$(cat <<'EOF'
<subject>
- <改动点1:文件/模块 + 具体变更>
- <改动点2:文件/模块 + 具体变更>
- <改动点3:原因或影响说明>
EOF
)"
提交人信息:仅使用用户环境变量中的 git 配置(user.name / user.email),不附加任何 AI agent 的 Co-Authored-By、Signed-off-by 或类似署名信息。
当变更涉及多个文件且各文件改动相对独立时,优先按文件拆分为多次提交:
判断条件(满足任一即应拆分):
拆分执行流程:
git add <file> + git commit拆分提交的 message 示例:
# 第1次提交
git commit -m "$(cat <<'EOF'
feat(git-commit-pr): add per-file split commit strategy
- Add section 5.2 defining when and how to split commits by file
- Criteria: ≥3 files with independent purposes, cross-module changes
- Execution flow: group → order → stage individually → commit with full body
EOF
)"
# 第2次提交
git commit -m "$(cat <<'EOF'
docs(git-commit-pr): enrich commit message body requirements
- Add section 5.1 mandating detailed body for all commits
- Body must list every changed file/function with specific modifications
- Require explanation of behavioral changes and dependency impacts
EOF
)"
不拆分的情况:
git status 确认结果。git pushgit push -u <remote> <branch>master/main 且准备直接推送主干,先再次确认是否真的要这样做。pull --rebase,或经用户确认后 --force-with-leasegh CLIgh 是否已安装并登录:gh auth status。git diff <base-branch>...HEAD --stat 非空gh 能力匹配.github/pull_request_template.md## Summary
- ...
- ...
## Test Plan
- [ ] ...
- [ ] ...
## Risks
- ...
base_branch 默认取远程默认分支;当前仓库通常为 mastergh pr create --title "<title>" --body "<body>" --base <base_branch>
若 gh 不可用,解析远程仓库 URL 并生成对应平台的创建链接:
| 平台 | 链接格式 |
|---|---|
| GitHub | https://github.com/<owner>/<repo>/pull/new/<branch> |
| GitLab | https://<host>/<owner>/<repo>/-/merge_requests/new?merge_request[source_branch]=<branch> |
| Gitee | https://gitee.com/<owner>/<repo>/pull/new/<branch> |
| Codeup | https://codeup.aliyun.com/<owner>/<repo>/merge_requests/new?source_branch=<branch> |
注意:部分平台支持 URL 参数预填标题和描述,可根据情况生成带参数的链接。
gh 成功,可提供 gh pr view --web 作为后续操作。用户:帮我提交 PR
Skill:
master,工作区有 2 个改动文件。emoji + 简短主题。feat/optimize-git-commit-pr-skill🛠️Refine git commit and PR workflow skillgh pr create 基于 master 创建 PR,标题默认取最近 commit subject,正文使用 Summary/Test Plan 模板。用户:帮我发 PR
Skill:
master。git push -u origin <branch>。git diff master...HEAD --stat 非空。用户:帮我提交一下这些改动
Skill:
master/main,先询问是否需要新建功能分支。git checkout -b feat/some-change
git add <files>
git commit -m "🎨Refine some UI or content change"
| 场景 | 处理方式 |
|---|---|
| 不是 git 仓库 | 提示用户 git init 或切换到正确目录 |
| 没有远程仓库 | 提示添加 remote,例如 git remote add origin <url> |
| 工作区干净且无新增提交 | 不创建空 commit,也不创建空 PR |
当前在 master/main 且要新增提交 | 优先建议新建分支 |
| 暂存区包含无关文件 | 重新确认范围,只暂存目标文件 |
| 疑似敏感文件被纳入提交 | 先提醒风险,再等待用户确认 |
| pre-commit hook 失败 | 显示错误信息,优先修复后重试;只有用户明确要求才跳过 hook |
| 推送被拒绝(远程有新提交) | 提示先 git pull --rebase,或询问是否 --force-with-lease |
| 分支名冲突(本地) | 提示覆盖或切换到已有分支 |
| 分支名冲突(远程) | 提示使用不同名称或确认强制推送 |
gh 未登录 | 提示执行 gh auth login 后重试 |
| 当前分支尚未 push 就要建 PR | 先推送,再创建 PR |
| 基线分支选择错误风险 | 通过远程默认分支或用户指定值确认 |
| 分支相对基线无差异 | 停止创建 PR,并说明“没有可合并内容” |
| 平台不支持自动链接生成 | 输出手动创建的指导步骤 |
<type>/<description>,如 feat/login。type(scope): summary,例如 docs(skill-optimizer): ...。origin、upstream),询问推送到哪个。.github/pull_request_template.md 读取并填充。Closes #123。git 基础环境,gh CLI 为可选。What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
Generated from the plugin's indexed repository (summersec/sumsec-skills) — no native marketplace selected
npx claudepluginhub p/summersec-sumsec20 skills in this plugin
/agent-chat-history按 YYYY-MM-DD 在 Windows/macOS/Linux 检索本机聊天与 Agent 会话历史(Claude Code 项目 jsonl、Codex CLI history.jsonl、Cursor workspaceStorage 与 state.vscdb);可只导出用户提示词。用户要查看或导出某日记录、按天筛 jsonl/SQLite、只抽提示词、排查历史丢失或做只读审计时使用。/claude-agents-symlink将项目根目录的 Claude 记忆文件统一为指向根目录 AGENTS 文件的软链接。用于用户要求把 `CLAUDE.md` 或 `claude.md` 指向 `AGENTS.md` 或 `agents.md`、希望批量统一多个项目的根目录记忆文件,或需要兼容 Windows、macOS、Linux 的跨平台软链接处理流程时。/context7-cliUse the ctx7 CLI to fetch library documentation, manage AI coding skills, and configure Context7 MCP. Activate when the user mentions "ctx7" or "context7", needs current docs for any library, wants to install/search/generate skills, or needs to set up Context7 for their AI coding agent./context7-mcpThis skill should be used when the user asks about libraries, frameworks, API references, or needs code examples. Activates for setup questions, code generation involving libraries, or mentions of specific frameworks like React, Vue, Next.js, Prisma, Supabase, etc./eli5-zh按指定听众的背景、词汇和兴趣,把任意主题、代码、概念或报错讲清楚。 用户说 ELI5、eli5、讲人话、说人话、通俗解释、用小学生能听懂的方式、给五岁小孩讲、 讲给我妈听、跟老板解释、解释给经理、讲给非技术人员听、dumb it down、explain like I am、 explain this to my、break this down for、simplify this for 时使用本 skill。 给特定角色或关系解释时也要触发:领导、老板、产品经理、设计师、工程师、父母、对象、 同事、客户、面试官、大学生、初中生、高中生。即便只是「跟我老婆解释一下」或「告诉老板」也应触发。
/find-docsRetrieves up-to-date documentation, API references, and code examples for any developer technology. Use this skill whenever the user asks about a specific library, framework, SDK, CLI tool, or cloud service — even for well-known ones like React, Next.js, Prisma, Express, Tailwind, Django, or Spring Boot. Your training data may not reflect recent API changes or version updates.
Always use for: API syntax questions, configuration options, version migration issues, "how do I" questions mentioning a library name, debugging that involves library-specific behavior, setup instructions, and CLI tool usage.
Use even when you think you know the answer — do not rely on training data for API details, signatures, or configuration options as they are frequently outdated. Always verify against current docs. Prefer this over web search for library documentation and API details.2 plugins in one repository ship this exact skill · first indexed Jul 19, 2026