7.1 KiB
| name | version | description | metadata | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| gitlink-workflow | 1.0.0 | AI 自动化工作流:Issue 分类、PR Review、Release Notes 生成、仓库初始化、Sprint 报告等。当用户需要 AI 自动化 GitLink 操作时触发。 |
|
gitlink-workflow(AI 自动化工作流)
前置条件: 先阅读
../gitlink-shared/SKILL.md
CRITICAL — GitLink 操作只能用 gitlink-cli。禁止用 gh(GitHub CLI)操作 GitLink 资源。gh 仅适用于 GitHub 平台。
本技能提供 Claude Code 可直接执行的高级工作流模板。
工作流 1:Issue Triage(Issue 自动分类)
场景:自动为新 Issue 添加标签分类。
# 1. 获取未标记的 Issue 列表
gitlink-cli issue +list --state open --format json
# 2. 逐个查看 Issue 详情
gitlink-cli issue +view --id <issue_id> --format json
# 3. 根据内容分析,通过 Raw API 添加标签
gitlink-cli api POST /:owner/:repo/issues/:id --body '{"issue_tag_ids":[<tag_id>]}'
分类规则建议:
- 标题/描述包含 "bug"、"错误"、"失败" → bug 标签
- 标题/描述包含 "feature"、"新增"、"建议" → enhancement 标签
- 标题/描述包含 "question"、"如何"、"怎么" → question 标签
工作流 2:PR Review(代码审查辅助)
场景:获取 PR 变更,分析代码质量,添加 Review 评论。
# 1. 获取 PR 详情
gitlink-cli pr +view --id <pr_id> --format json
# 2. 获取完整审查上下文(仓库、PR、变更文件、Review、Issue、标签)
gitlink-cli workflow +review-context --number <pr_id> --format json
# 3. 添加 Review 评论(写操作前需确认用户意图)
gitlink-cli api POST /:owner/:repo/pulls/:id/reviews --body '{"body":"代码审查意见...","event":"COMMENT"}'
工作流 3:Release Notes 生成
场景:从提交历史和 PR 信号自动生成版本发布说明,适合维护者发版前检查、Agent 生成 changelog 草稿、竞赛材料展示等场景。
# 只读远程模式:从 GitLink compare 数据生成 Markdown
gitlink-cli workflow +release-notes \
--owner Gitlink \
--repo gitlink-cli \
--from-ref v1.1.0 \
--to-ref master \
--version v1.2.0 \
--format markdown
# 本地 JSON 模式:供 Agent 流水线、测试夹具或离线复现使用
gitlink-cli workflow +release-notes \
--from shortcuts/workflow/testdata/release_notes.json \
--format json
规则:
- 优先使用
workflow +release-notes生成草稿,再由维护者决定是否创建 Release。 - 使用
--format json作为 Agent 间传递格式;使用--format markdown作为人类可读发布说明。 - 远程模式只读取 compare 数据,不创建 Release,不评论、不打标签、不合并。
--include-prs默认开启;当 compare 响应包含 PR 信号时会一起分类。- 分类规则是确定性的,不依赖 LLM API,便于审计和复现。
工作流 4:Repo Setup(仓库初始化)
场景:创建仓库并完成基础配置。
# 1. 创建仓库
gitlink-cli repo +create --name my-project --description "项目描述"
# 2. 设置分支保护
gitlink-cli branch +protect --name main --owner myuser --repo my-project
# 3. 创建初始 Issue
gitlink-cli issue +create --title "项目初始化" --body "- [ ] 完善 README\n- [ ] 配置 CI\n- [ ] 添加 License" --owner myuser --repo my-project
工作流 5:Sprint Report(Sprint 报告)
场景:汇总 Issue/PR 统计,生成周报。
# 1. 获取 Issue 统计
gitlink-cli issue +list --state open --format json
gitlink-cli issue +list --state closed --format json
# 2. 获取 PR 统计
gitlink-cli pr +list --state open --format json
gitlink-cli pr +list --state merged --format json
# 3. 获取仓库工作流报告
gitlink-cli workflow +repo-report --format json
Workflow: PR Summary (Read-only)
Use workflow +pr-summary when a maintainer or Agent needs a structured PR review summary, review focus, test suggestions, or a markdown report that can be copied into a PR discussion.
# Read-only GitLink fetch mode
gitlink-cli workflow +pr-summary --owner Gitlink --repo gitlink-cli --number 1 --format markdown
# Local JSON input mode for Agent pipelines
gitlink-cli workflow +pr-summary --from shortcuts/workflow/testdata/pr_summary.json --format json
Rules:
- Prefer
--format jsonwhen another Agent consumes the output. - Prefer
--format markdownwhen a human maintainer needs a report. - This command is read-only: it does not comment, approve, reject, merge, label, or close pull requests.
- Do not use LLM APIs for this workflow; it is rule-based and explainable.
Workflow: Review Context (Read-only)
Use workflow +review-context when an Agent needs one deterministic JSON bundle for PR review or gatekeeping. It aggregates shortcut-backed read-only fetches for repository info, PR details, changed files, existing reviews, open issues, and labels.
gitlink-cli workflow +review-context --owner Gitlink --repo gitlink-cli --number 1 --format json
# Trim context for large repositories
gitlink-cli workflow +review-context --owner Gitlink --repo gitlink-cli --number 1 \
--issue-limit 10 --label-limit 30 --format json
# Only fetch PR and changed files
gitlink-cli workflow +review-context --owner Gitlink --repo gitlink-cli --number 1 \
--include-repo=false --include-reviews=false --include-issues=false --include-labels=false \
--format json
Rules:
- This command is read-only and never comments, approves, rejects, merges, labels, or closes resources.
- Prefer it before
workflow +pr-summarywhen a review agent needs raw context plus existing review state. - The command records partial fetch failures in
notesso Agents can proceed with available context.
Workflow: Repo Report (Read-only)
Use workflow +repo-report when a maintainer or Agent needs a single repository workflow report
that aggregates health, issue triage, and PR review signals.
适用于需要生成仓库治理报告、比赛材料、维护者汇总或 Agent 综合分析的场景。
# Maintainer report
gitlink-cli workflow +repo-report --owner Gitlink --repo gitlink-cli --format markdown
# Agent-readable report
gitlink-cli workflow +repo-report --owner Gitlink --repo gitlink-cli --format json
# Local fixture mode
gitlink-cli workflow +repo-report --from shortcuts/workflow/testdata/repo_report.json --format json
Rules:
- Prefer
--format jsonwhen another Agent consumes the output. - Prefer
--format markdownfor maintainer reports, competition materials, and review handoff. - Treat remote mode as read-only aggregation only.
- Do not perform remote write operations.
- Do not comment, label, close, approve, reject, or merge from this workflow.
- PR details in remote report mode may be partial; use
workflow +pr-summary --number <n>for a focused PR review.
最佳实践
- 所有工作流命令使用
--format json以便解析输出 - 写入操作前确认用户意图
- 批量操作建议先用小范围测试
- 保存工作流执行结果以便回溯