local-link/skills/git-skills/skills/git-push/SKILL.md
代码质量门禁与智能推送助手。核心能力:在 git push 前自动运行项目配置的代码质量检查(test、lint、format、check-types),检测到问题时尝试自动修复,修复成功后继续推送。使用场景:(1) 用户说 "push"、"推送"、"提交到远程" (2) 用户想确保代码质量后再推送 (3) 用户遇到 lint/format 错误需要修复后推送 (4) 作为 pre-push 质量门禁。始终遵循"检测 → 修复 → 再检测 → 推送"的循环,直到代码通过检查或无法自动修复。
npx skillsauth add lionad-morotar/local-tools git-pushInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
本技能采用子代理执行模式。主代理通过 Task 工具调用子代理,子代理独立完成整个"检测-修复-推送"工作流后,返回简洁的确认信息。
使用 Task 工具调用子代理,子代理类型为 general-purpose:
subagent_type: general-purpose
prompt: |
执行 git-push 工作流:
1. 检测当前 git 仓库的变更文件
2. 根据项目配置运行代码检查(lint、format、test、check-types)
3. 发现可自动修复的问题时,执行修复并重新检查
4. 所有检查通过后执行 git push
5. 返回执行结果给主代理
当前工作目录:{current_working_directory}
返回格式要求:
- 成功:简要说明推送成功
- 需要手动修复:列出具体问题
- 失败:说明失败原因
子代理执行以下完整工作流:
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ 检测变更 │ → │ 运行检查 │ → │ 自动修复 │ → │ 执行推送 │
│ (git status)│ │ (lint/test)│ │ (fixable?) │ │ (git push) │
└─────────────┘ └──────┬──────┘ └──────┬──────┘ └─────────────┘
│ │
▼ ▼
┌─────────────┐ ┌─────────────┐
│ 通过 ✅ │ │ 无法自动修复 │
│ 直接推送 │ │ 报告给主代理 │
└─────────────┘ └─────────────┘
获取变更文件:
git status --porcelain
git diff --name-only --cached
git diff --name-only
如无变更 → 返回"无变更需要推送"
检测项目配置(按优先级):
package.json scripts(最优先):
npm run lintnpm run format 或 npm run format -- --checknpm run testnpm run check-types配置文件检测(无 scripts 时):
.eslintrc.*, eslint.config.*.prettierrc.*, prettier.config.*tsconfig.jsonbiome.jsonpyproject.toml (Python)执行策略:
可自动修复的问题:
| 工具 | 修复命令 |
|-----|---------|
| ESLint | npm run lint -- --fix 或 npx eslint --fix |
| Prettier | npm run format 或 npx prettier --write |
| Biome | npx biome check --write |
| Ruff | ruff check --fix |
修复后处理:
git add -A不可自动修复的问题:
→ 停止自动修复,准备报告给主代理
检查全部通过后:
git push
首次推送新分支:
git push -u origin <branch-name>
| 异常类型 | 处理方式 | |---------|---------| | 非快进推送 (non-fast-forward) | 告知主代理需要先 pull/rebase | | 分支保护 (protected branch) | 告知主代理需要创建 Pull Request | | 网络错误 | 重试 1 次,仍失败则报告 | | 修复循环 | 自动修复最多尝试 2 次 |
子代理向主代理返回简洁的执行结果:
推送成功:
✅ 推送成功
代码检查全部通过,变更已推送到远程仓库。
[可选:推送的分支和 commit 信息]
需要手动修复:
⚠️ 需要手动处理
以下问题无法自动修复:
1. [具体错误描述]
2. [具体错误描述]
建议操作:
- [修复建议]
推送失败:
❌ 推送失败
[失败原因]
建议操作:
- [解决建议]
无变更:
ℹ️ 没有变更
当前没有需要推送的变更文件。
主代理根据子代理返回的内容,向用户展示:
[子代理返回的结果]
[如有需要,主代理补充的上下文信息]
主代理不需要解释子代理的执行细节,只需传递子代理的结果。
tools
open understand dashboard for user
tools
这是一个技能文件的模板,展示了技能的基本结构和内容组织方式。
development
Be direct and informative. No filler, no fluff, but give enough to be useful.
development
使用 Evaluator-optimizer 模式进行系统性多轮网络搜索,采用结构化 Ask 流程在搜索前澄清研究目标。基于 YC Office Hours 的提问方法论,确保搜索方向清晰、结果可验证。当用户需要深入调查复杂主题、验证假设或全面收集信息时使用。