shepherd
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseShepherd Skill
Shepherd技能
VCS Provider
VCS提供商
This skill uses VCS operations through Exarchos MCP actions (, , , , , etc.).
These actions automatically detect and route to the correct VCS provider (GitHub, GitLab, Azure DevOps).
No // commands needed — the MCP server handles provider dispatch.
check_cilist_prsmerge_prget_pr_commentsadd_pr_commentghglabazTheinvoked here is the remote PR merge primitive (synthesize-phase). It is distinct frommerge_pr(merge_orchestrate), which is the local@skills/merge-orchestrator/SKILL.mdorchestrator used during the upstreamgit mergesubstate. This skill never invokesmerge-pending.merge_orchestrate
Iterative loop that shepherds published PRs through CI checks and code reviews to merge readiness. Uses the composite action for all PR health checks, fixing failures and addressing feedback until the stack is green.
assess_stackNote: Shepherd is not a separate HSM phase. It operates as a loop within thephase. The workflow phase remainssynthesizethroughout the shepherd iteration cycle. Events (synthesize,shepherd.iteration) and theci.statusview track loop progress without requiring a phase transition.shepherd_status
Position in workflow:
text
/synthesize → /shepherd (assess → fix → resubmit → loop) → /cleanup
^^^^^^^^^ runs within synthesize phase本技能通过Exarchos MCP操作(、、、、等)实现VCS相关操作。
这些操作会自动检测并路由到正确的VCS提供商(GitHub、GitLab、Azure DevOps)。
无需使用//命令——MCP服务器会处理提供商的调度工作。
check_cilist_prsmerge_prget_pr_commentsadd_pr_commentghglabaz此处调用的是远程PR合并原语(属于synthesize阶段)。它与merge_pr(merge_orchestrate)不同,后者是上游@skills/merge-orchestrator/SKILL.md子状态中使用的本地merge-pending编排器。本技能绝不会调用git merge。merge_orchestrate
以迭代循环方式引导已发布的PR通过CI检查和代码评审,直至达到可合并状态。使用复合操作进行所有PR健康检查,修复问题并处理反馈,直至所有检查通过。
assess_stack注意: Shepherd并非独立的HSM阶段。它在阶段内以循环方式运行。在整个Shepherd迭代周期中,工作流阶段始终为synthesize。事件(synthesize、shepherd.iteration)和ci.status视图会跟踪循环进度,无需进行阶段切换。shepherd_status
在工作流中的位置:
text
/synthesize → /shepherd (评估 → 修复 → 重新提交 → 循环) → /cleanup
^^^^^^^^^ 在synthesize阶段内运行Pipeline Hygiene
流水线维护
When accumulates stale workflows (inactive > 7 days), run to bulk-cancel abandoned workflows before starting a new shepherd cycle. Safeguards skip workflows with open PRs or recent commits, so active shepherd targets are never touched. A clean pipeline makes shepherd iteration reporting easier to read and reduces noise in the stale-count view.
mcp__exarchos__exarchos_view pipeline@skills/prune-workflows/SKILL.md当累积了过时工作流(超过7天未活跃)时,在启动新的Shepherd循环前运行批量取消已废弃的工作流。保护机制会跳过包含开放PR或近期提交的工作流,因此绝不会触及活跃的Shepherd目标。干净的流水线能让Shepherd迭代报告更易阅读,并减少过时计数视图中的干扰信息。
mcp__exarchos__exarchos_view pipeline@skills/prune-workflows/SKILL.mdTriggers
触发条件
Activate when:
- User runs or says "shepherd", "tend PRs", "check CI"
/shepherd - PRs are published and need monitoring through the CI/review gauntlet
- After completes and PRs are enqueued
/synthesize
满足以下条件时激活:
- 用户运行或输入"shepherd"、"tend PRs"、"check CI"
/shepherd - PR已发布,需要监控其通过CI/评审的全过程
- 完成且PR已进入队列后
/synthesize
Prerequisites
前置条件
- Active workflow with PRs published (PR URLs in or
synthesis.prUrl)artifacts.pr - PRs created and pushed (already ran)
create_pr - Exarchos MCP tools available for VCS operations
- 存在包含已发布PR的活跃工作流(PR URL存储在或
synthesis.prUrl中)artifacts.pr - PR已创建并推送(已执行)
create_pr - 可使用Exarchos MCP工具进行VCS操作
Process
流程
Runbook: Each shepherd iteration follows the shepherd-iteration runbook:If runbook unavailable, useexarchos_orchestrate({ action: "runbook", id: "shepherd-iteration" })to retrieve action schemas:describeexarchos_orchestrate({ action: "describe", actions: ["assess_stack"] })
The shepherd loop repeats until all PRs are healthy or escalation criteria are met. Default: 5 iterations.
运行手册: 每次Shepherd迭代遵循shepherd-iteration运行手册:如果运行手册不可用,使用exarchos_orchestrate({ action: "runbook", id: "shepherd-iteration" })获取操作 schema:describeexarchos_orchestrate({ action: "describe", actions: ["assess_stack"] })
Shepherd循环会重复执行,直到所有PR健康达标或达到升级标准。默认迭代次数为5次。
Step 0 — Surface Quality Signals
步骤0 — 提取质量信号
At the start of each iteration, query quality hints to inform the assessment:
mcp__exarchos__exarchos_view({ action: "code_quality", workflowId: "<featureId>" })- If is non-empty, include regression context in the status report
regressions - If any hint has , surface the
confidenceLevel: 'actionable'in the iteration summarysuggestedAction - If for any skill, flag degrading quality trends
gatePassRate < 0.80
This step ensures the agent acts on accumulated quality intelligence before polling individual PRs.
在每次迭代开始时,查询质量提示信息以辅助评估:
mcp__exarchos__exarchos_view({ action: "code_quality", workflowId: "<featureId>" })- 如果非空,在状态报告中包含回归上下文
regressions - 如果任何提示的为'actionable',在迭代摘要中展示
confidenceLevelsuggestedAction - 如果任一技能的,标记质量下降趋势
gatePassRate < 0.80
此步骤确保Agent在轮询单个PR之前,先基于累积的质量智能采取行动。
Step 1 — Assess
步骤1 — 评估
Invoke the composite action to check all PR dimensions at once:
assess_stackmcp__exarchos__exarchos_orchestrate({
action: "assess_stack",
featureId: "<id>",
prNumbers: [123, 124, 125]
})The composite action internally handles:
- CI status checking for all PRs
- Formal review status (APPROVED / CHANGES_REQUESTED)
- Inline review comment polling and thread resolution (Sentry, CodeRabbit, humans)
- Stack health verification
- Event emission: events per CI check (feeds CodeQualityView) and
gate.executedevents per PR (feeds ShepherdStatusView). Seeci.statusfor the event format.references/gate-event-emission.md
Review the returned and :
actionItemsrecommendation| Recommendation | Action |
|---|---|
| Skip to Step 4 |
| Proceed to Step 2 |
| Inform user, pause, re-assess after delay |
| See |
调用复合操作,一次性检查所有PR的各项维度:
assess_stackmcp__exarchos__exarchos_orchestrate({
action: "assess_stack",
featureId: "<id>",
prNumbers: [123, 124, 125]
})该复合操作内部会处理:
- 所有PR的CI状态检查
- 正式评审状态(APPROVED / CHANGES_REQUESTED)
- 内联评审评论轮询和线程解决(Sentry、CodeRabbit、人工评审)
- 堆栈健康验证
- 事件发送:每个CI检查发送事件(供CodeQualityView使用),每个PR发送
gate.executed事件(供ShepherdStatusView使用)。事件格式详见ci.status。references/gate-event-emission.md
查看返回的和:
actionItemsrecommendation| 建议 | 操作 |
|---|---|
| 跳至步骤4 |
| 进入步骤2 |
| 通知用户,暂停,延迟后重新评估 |
| 查看 |
Step 2 — Fix
步骤2 — 修复
Before iterating over individual action items, classify them so the loop
knows which to fix inline vs. delegate. Call on
the assessment's (the comment-reply subset is what the
classifier groups by file; CI-fix and review-address items are passed
through unchanged):
classify_review_itemsactionItemstypescript
mcp__exarchos__exarchos_orchestrate({
action: "classify_review_items",
featureId: "<id>",
actionItems: <actionItems from assess_stack>
})The result returns with a
per group: (handle inline), (spawn the fixer
subagent for batched/HIGH-severity work), or
(cheap subagent for doc nits). Iterate the groups in order, applying
per-group strategy, then consult for
detailed per-issue-type instructions.
groups: ClassificationGroup[]recommendationdirectdelegate-fixerdelegate-scaffolderreferences/fix-strategies.mdRemediation event protocol (FLYWHEEL):
-
BEFORE applying a fix, emit:
remediation.attemptedtypescriptmcp__exarchos__exarchos_event({ action: "append", stream: "<featureId>", event: { type: "remediation.attempted", data: { taskId: "<taskId>", skill: "shepherd", gateName: "<failing-gate>", attemptNumber: <N>, strategy: "direct-fix" } } }) -
Apply the fix (CI failure, review comment response, stack restack).
-
AFTER the next assess confirms the fix resolved the gate, emit:
remediation.succeededmcp__exarchos__exarchos_event({ action: "append", stream: "<featureId>", event: { type: "remediation.succeeded", data: { taskId: "<taskId>", skill: "shepherd", gateName: "<gate>", totalAttempts: <N>, finalStrategy: "direct-fix" } } })
These events feed and metrics in CodeQualityView.
selfCorrectionRateavgRemediationAttemptsAction item types:
| Type | Strategy |
|---|---|
| Read logs, reproduce locally, fix, commit to stack branch |
| Use |
| Fix code for CHANGES_REQUESTED, reply to each thread |
| Run |
| Consult |
Every inline review comment must get a reply. The goal is that a human scanning the PR sees every thread has a response.
在逐个处理操作项之前,先对其进行分类,以便循环知道哪些需要直接处理,哪些需要委派。对评估得到的调用(分类器会按文件对评论回复子集进行分组;CI修复和评审处理项会直接传递):
actionItemsclassify_review_itemstypescript
mcp__exarchos__exarchos_orchestrate({
action: "classify_review_items",
featureId: "<id>",
actionItems: <actionItems from assess_stack>
})结果会返回,每个分组带有对应的:(直接处理)、(启动修复子Agent处理批量/高严重性工作)或(使用轻量Agent处理文档小问题)。按顺序遍历分组,应用分组策略,然后参考获取针对不同问题类型的详细处理说明。
groups: ClassificationGroup[]recommendationdirectdelegate-fixerdelegate-scaffolderreferences/fix-strategies.md修复事件协议(FLYWHEEL):
-
应用修复前,发送事件:
remediation.attemptedtypescriptmcp__exarchos__exarchos_event({ action: "append", stream: "<featureId>", event: { type: "remediation.attempted", data: { taskId: "<taskId>", skill: "shepherd", gateName: "<failing-gate>", attemptNumber: <N>, strategy: "direct-fix" } } }) -
应用修复(CI故障修复、评审评论回复、堆栈重新堆叠)。
-
下一次评估确认修复解决问题后,发送事件:
remediation.succeededmcp__exarchos__exarchos_event({ action: "append", stream: "<featureId>", event: { type: "remediation.succeeded", data: { taskId: "<taskId>", skill: "shepherd", gateName: "<gate>", totalAttempts: <N>, finalStrategy: "direct-fix" } } })
这些事件会为CodeQualityView中的和指标提供数据。
selfCorrectionRateavgRemediationAttempts操作项类型:
| 类型 | 策略 |
|---|---|
| 查看日志,本地复现问题,修复后提交到堆栈分支 |
| 使用 |
| 针对CHANGES_REQUESTED修复代码,回复每个线程 |
| 运行 |
| 参考 |
每条内联评审评论都必须回复。目标是让查看PR的人员看到所有线程都有回应。
Step 3 — Resubmit
步骤3 — 重新提交
After fixes are applied, resubmit the stack:
bash
git push --force-with-leaseRe-enable auto-merge if needed:
typescript
exarchos_orchestrate({ action: "merge_pr", prId: "<number>", strategy: "squash" })Return to Step 1 for the next iteration. Track iteration count against the limit (default 5). If the limit is reached without reaching , escalate per .
request-approvalreferences/escalation-criteria.md修复完成后,重新提交堆栈:
bash
git push --force-with-lease如有需要,重新启用自动合并:
typescript
exarchos_orchestrate({ action: "merge_pr", prId: "<number>", strategy: "squash" })返回步骤1进行下一次迭代。跟踪迭代次数是否达到限制(默认5次)。如果达到限制仍未进入状态,按照进行升级处理。
request-approvalreferences/escalation-criteria.mdStep 4 — Request Approval
步骤4 — 请求审批
When returns (all checks green, all comments addressed):
assess_stackrecommendation: 'request-approval'-
Request review via GitHub MCP:
mcp__plugin_github_github__update_pull_request({ owner: "<owner>", repo: "<repo>", pullNumber: <number>, reviewers: ["<approver>"] })Fallback (if MCP token lacks write scope):gh pr edit <number> --add-reviewer <approver> -
Report to user:markdown
## Ready for Approval All CI checks pass. All review comments addressed. Approval requested from: <approvers> PRs: - #123: <url> - #124: <url> Run `/cleanup` after merge completes.
当返回(所有检查通过,所有评论已处理)时:
assess_stackrecommendation: 'request-approval'-
通过GitHub MCP请求评审:
mcp__plugin_github_github__update_pull_request({ owner: "<owner>", repo: "<repo>", pullNumber: <number>, reviewers: ["<approver>"] })备用方案(如果MCP令牌缺少写入权限):gh pr edit <number> --add-reviewer <approver> -
向用户报告:markdown
## 已准备好审批 所有CI检查通过。所有评审评论已处理。 已向以下人员请求审批:<approvers> PR列表: - #123: <url> - #124: <url> 合并完成后运行`/cleanup`。
State Management
状态管理
Track shepherd progress via workflow state:
Initialize:
mcp__exarchos__exarchos_workflow({
action: "set",
featureId: "<id>",
updates: {
"shepherd": {
"startedAt": "<ISO8601>",
"currentIteration": 0,
"maxIterations": 5,
"approvalRequested": false
}
}
})After each iteration: Update , record assessment summary and actions taken. On approval: set with timestamp and approver list.
currentIterationapprovalRequested: true通过工作流状态跟踪Shepherd进度:
初始化:
mcp__exarchos__exarchos_workflow({
action: "set",
featureId: "<id>",
updates: {
"shepherd": {
"startedAt": "<ISO8601>",
"currentIteration": 0,
"maxIterations": 5,
"approvalRequested": false
}
}
})每次迭代后: 更新,记录评估摘要和已执行的操作。请求审批时:设置并记录时间戳和审批人列表。
currentIterationapprovalRequested: truePhase Transitions and Guards
阶段切换与防护
For the full transition table, consult .
@skills/workflow-state/references/phase-transitions.mdThe shepherd skill operates within the phase and does not drive phase transitions directly.
synthesize完整的切换表请参考。
@skills/workflow-state/references/phase-transitions.mdShepherd技能在阶段内运行,不会直接触发阶段切换。
synthesizeSchema Discovery
Schema发现
Use for
parameter schemas and
for phase transitions, guards, and playbook guidance. Use
for event data schemas before emitting events.
exarchos_workflow({ action: "describe", actions: ["set", "init"] })exarchos_workflow({ action: "describe", playbook: "feature" })exarchos_event({ action: "describe", eventTypes: ["shepherd.iteration", "ci.status", "remediation.attempted"] })使用获取参数schema,使用获取阶段切换、防护和工作手册指南。发送事件前,使用获取事件数据schema。
exarchos_workflow({ action: "describe", actions: ["set", "init"] })exarchos_workflow({ action: "describe", playbook: "feature" })exarchos_event({ action: "describe", eventTypes: ["shepherd.iteration", "ci.status", "remediation.attempted"] })Event Emission
事件发送
Before emitting any shepherd events, consult for full Zod schemas, type constraints, and example payloads. Use to discover required fields at runtime.
references/shepherd-event-schemas.mdexarchos_event({ action: "describe", eventTypes: ["shepherd.iteration", "ci.status"] })| Event | When | Purpose |
|---|---|---|
| On skill start (emitted by | Audit trail |
| After each assess cycle | Track progress |
| Per CI check (emitted by | CodeQualityView -- gate pass rates |
| Per CI check result | ShepherdStatusView -- PR health tracking |
| Before applying a fix | selfCorrectionRate metric |
| After fix confirmed | avgRemediationAttempts metric |
| On requesting review | Audit trail |
| On merge detected (emitted by | Audit trail |
发送任何Shepherd事件前,请参考获取完整的Zod schema、类型约束和示例负载。运行时可使用发现必填字段。
references/shepherd-event-schemas.mdexarchos_event({ action: "describe", eventTypes: ["shepherd.iteration", "ci.status"] })| 事件 | 发送时机 | 用途 |
|---|---|---|
| 技能启动时(由 | 审计追踪 |
| 每次评估周期后 | 跟踪进度 |
| 每个CI检查完成时(由 | CodeQualityView——检查通过率 |
| 每个CI检查结果生成时 | ShepherdStatusView——PR健康跟踪 |
| 应用修复前 | selfCorrectionRate指标 |
| 修复确认后 | avgRemediationAttempts指标 |
| 请求评审时 | 审计追踪 |
| 检测到合并时(由 | 审计追踪 |
Domain Knowledge
领域知识
Consult these references for detailed guidance:
- — Fix approaches per issue type, response templates, remediation event emission details
references/fix-strategies.md - — When to stop iterating and escalate to the user
references/escalation-criteria.md - — Event format for
references/gate-event-emission.md(now emitted bygate.executed)assess_stack - — Full Zod-aligned schemas for all four shepherd lifecycle events
references/shepherd-event-schemas.md
如需详细指导,请参考以下文档:
- — 不同问题类型的修复方法、回复模板、修复事件发送细节
references/fix-strategies.md - — 何时停止迭代并向用户升级问题
references/escalation-criteria.md - —
references/gate-event-emission.md事件格式(现由gate.executed发送)assess_stack - — 所有四个Shepherd生命周期事件的完整Zod对齐schema
references/shepherd-event-schemas.md
Decision Runbooks
决策运行手册
When iteration limits are reached or CI repeatedly fails, consult the escalation runbook:
exarchos_orchestrate({ action: "runbook", id: "shepherd-escalation" })This runbook provides structured criteria for deciding whether to keep iterating, escalate to the user, or abort the shepherd loop based on iteration count, CI stability, and review status.
当达到迭代限制或CI反复失败时,参考升级运行手册:
exarchos_orchestrate({ action: "runbook", id: "shepherd-escalation" })本运行手册提供结构化标准,用于决定是继续迭代、向用户升级问题还是终止Shepherd循环,决策依据包括迭代次数、CI稳定性和评审状态。
Anti-Patterns
反模式
| Don't | Do Instead |
|---|---|
| Poll CI/reviews directly | Use |
| Force-merge with failing CI | Fix the failures first |
| Ignore inline comments | Address every thread with a reply |
| Loop indefinitely | Respect iteration limits, escalate |
| Skip remediation events | Emit |
| Push directly to main | All fixes go through stack branches |
| 禁止操作 | 正确做法 |
|---|---|
| 直接轮询CI/评审 | 使用 |
| CI失败时强制合并 | 先修复问题 |
| 忽略内联评论 | 回复每个线程 |
| 无限循环 | 遵守迭代限制,及时升级 |
| 跳过修复事件 | 每次修复都发送 |
| 直接推送到主分支 | 所有修复都通过堆栈分支提交 |
Transition
后续操作
After approval is granted and PRs merge, run to resolve the workflow to completed state.
/cleanup审批通过且PR合并后,运行将工作流标记为完成状态。
/cleanup