name: orchestrate-github-pr-review description: Use when given a GitHub pull request link and needing an end-to-end multi-skill review pipeline that prepares a PR worktree, runs category reviews in parallel, submits one merged PR review, and then cleans up.
Orchestrate PR Review Pipeline
Overview
Run a full PR review pipeline by orchestrating existing skills directly.
This skill must:
- prepare PR diff worktree metadata
- run 6 review skills in parallel subagents
- merge and submit one PR review
- clean up the temporary worktree
Do not call scripts from this skill. Invoke the skills themselves.
Inputs
pr_link(required)- GitHub PR URL, for example
https://github.com/pingcap/tidb/pull/12345
- GitHub PR URL, for example
project_path(optional)- absolute path to target repo, used when current directory is outside the project
Output
Emit one JSON object summarizing orchestration status:
{
"pr_link": "https://github.com/pingcap/tidb/pull/12345",
"prepare": {},
"review_outputs": [],
"merge_submit": {},
"cleanup": {},
"status": "success",
"reason": ""
}
status values:
successpartial-failure(review/merge failed but cleanup attempted)failed(prepare failed, or critical orchestration failure)
reason values:
- empty string on success
- machine-readable failure reason on non-success (for example
subagent-dispatch-unavailable)
Direct Skill Invocation Rule
Required: invoke these skills directly by name:
- prepare-pr-diff-worktree
- review-clarity-naming-comment-intent
- review-correctness-query-planner-execution
- review-correctness-state-schema-transaction
- review-runtime-reliability-performance
- review-scope-structure-abstraction
- review-upgrade-compatibility-and-test-determinism
- merge-review-json-and-submit-pr-review
- cleanup-pr-diff-worktree
Forbidden in this skill:
- direct execution of
prepare-pr-diff-worktree/scripts/* - direct execution of
merge-review-json-and-submit-pr-review/scripts/* - direct execution of
cleanup-pr-diff-worktree/scripts/*
Subagent Execution Hard Gate
- For step 2, invoke
dispatching-parallel-agentsby workflow intent (parallel, independent tasks). - Step 2 MUST use a subagent mechanism. The parent agent MUST NOT run any of the 6 review skills inline.
- Dispatch all 6 review subagents in one batch so they run concurrently.
- Every subagent launch in this workflow MUST disable parent-thread history inheritance:
- native runtime: set
fork_context=false codex execfallback: start a fresh child process with no parent conversation transcript in prompt input
- native runtime: set
- If the selected backend cannot guarantee context isolation, stop and return
failedwith reasoncontext-isolation-unavailable. - Do not reuse stale/open subagents from earlier attempts; use fresh subagents for prepare/review/merge/cleanup calls.
- Do NOT terminate review subagents just because they are slow. These review skills have no checkpoint/resume, so early termination discards completed in-memory work.
- Terminate a review subagent only when there is an obvious hang signal (for example: runtime marks the task as stuck/disconnected/crashed, or repeated long-interval health checks show zero state/output changes).
- Allowed subagent backends (in priority order):
- Native runtime Task/subagent API.
codex execchild-agent processes (one process per reviewer) when native Task/subagent API is unavailable.
- If neither native Task/subagent dispatch nor
codex execis available, stop and returnfailedwith reasonsubagent-dispatch-unavailable. - Do not silently fall back to sequential, in-parent execution.
- Do not continue with any review skill execution after a subagent-dispatch failure.
Workflow
Prepare worktree metadata
- Invoke prepare-pr-diff-worktree with:
pr_linkproject_path(when provided)
- If prepare is executed in a subagent, run it in a fresh isolated subagent (
fork_context=false) and explicitly scope the prompt to prepare only. - Scope-breach guard after prepare:
- expected outputs: prepare JSON (
code_path,diff_filename,work_tree) - unexpected at this stage:
review-*.json,merged-review-output.json,github-review-payload.json - if unexpected artifacts are newly produced by the prepare subagent, treat as
scope-breach, terminate that subagent, and rerun prepare once in a new isolated subagent
- expected outputs: prepare JSON (
- Capture output JSON fields:
code_pathdiff_filenamework_tree
- Invoke prepare-pr-diff-worktree with:
Dispatch 6 review skills in parallel subagents
- Detect one dispatch backend:
- preferred: native Task/subagent API
- fallback:
codex execchild-agent processes
- Fail fast only if neither backend is available.
- Use one subagent per review skill.
- Dispatch these 6 subagents at the same time (single parallel batch).
- Every subagent must launch with explicit write-capable filesystem access:
- set subagent sandbox mode to
workspace-write(neverread-only) - keep the same network restrictions as the parent agent
- keep the same escalation/approval behavior as the parent agent
- set subagent sandbox mode to
- Required per-subagent prompt contract:
- "Invoke skill
<review-skill-name>directly." - "Inputs:
code_path=<...>,diff_filename=<...>,output_filename=<...>." - "Write output JSON to exactly
output_filename." - "Run this subagent with
workspace-writesandbox access." - "Run this subagent with
fork_context=false(no inherited parent conversation context)." - "Execute only this review step. Do not run prepare, merge, cleanup, or orchestration."
- "Do not run in parent; execute in this subagent only."
- "Invoke skill
- Example dispatch shape using native Task/subagent API (conceptual):
Task("Invoke skill review-clarity-naming-comment-intent with code_path=<...> diff_filename=<...> output_filename=review-clarity-naming-comment-intent.json. Execute in this subagent only.", sandbox_mode="workspace-write") Task("Invoke skill review-correctness-query-planner-execution with code_path=<...> diff_filename=<...> output_filename=review-correctness-query-planner-execution.json. Execute in this subagent only.", sandbox_mode="workspace-write") Task("Invoke skill review-correctness-state-schema-transaction with code_path=<...> diff_filename=<...> output_filename=review-correctness-state-schema-transaction.json. Execute in this subagent only.", sandbox_mode="workspace-write") Task("Invoke skill review-runtime-reliability-performance with code_path=<...> diff_filename=<...> output_filename=review-runtime-reliability-performance.json. Execute in this subagent only.", sandbox_mode="workspace-write") Task("Invoke skill review-scope-structure-abstraction with code_path=<...> diff_filename=<...> output_filename=review-scope-structure-abstraction.json. Execute in this subagent only.", sandbox_mode="workspace-write") Task("Invoke skill review-upgrade-compatibility-and-test-determinism with code_path=<...> diff_filename=<...> output_filename=review-upgrade-compatibility-and-test-determinism.json. Execute in this subagent only.", sandbox_mode="workspace-write") - Example dispatch shape using
codex execfallback (conceptual):codex exec --sandbox workspace-write -C "<code_path>" \ "Invoke skill review-clarity-naming-comment-intent directly. Inputs: code_path=<code_path>, diff_filename=<diff_filename>, output_filename=review-clarity-naming-comment-intent.json. Write output JSON to exactly output_filename. Run this subagent with workspace-write sandbox access. Do not run in parent; execute in this subagent only." \ > review-clarity-naming-comment-intent.log 2>&1 & codex exec --sandbox workspace-write -C "<code_path>" \ "Invoke skill review-correctness-query-planner-execution directly. Inputs: code_path=<code_path>, diff_filename=<diff_filename>, output_filename=review-correctness-query-planner-execution.json. Write output JSON to exactly output_filename. Run this subagent with workspace-write sandbox access. Do not run in parent; execute in this subagent only." \ > review-correctness-query-planner-execution.log 2>&1 & codex exec --sandbox workspace-write -C "<code_path>" \ "Invoke skill review-correctness-state-schema-transaction directly. Inputs: code_path=<code_path>, diff_filename=<diff_filename>, output_filename=review-correctness-state-schema-transaction.json. Write output JSON to exactly output_filename. Run this subagent with workspace-write sandbox access. Do not run in parent; execute in this subagent only." \ > review-correctness-state-schema-transaction.log 2>&1 & codex exec --sandbox workspace-write -C "<code_path>" \ "Invoke skill review-runtime-reliability-performance directly. Inputs: code_path=<code_path>, diff_filename=<diff_filename>, output_filename=review-runtime-reliability-performance.json. Write output JSON to exactly output_filename. Run this subagent with workspace-write sandbox access. Do not run in parent; execute in this subagent only." \ > review-runtime-reliability-performance.log 2>&1 & codex exec --sandbox workspace-write -C "<code_path>" \ "Invoke skill review-scope-structure-abstraction directly. Inputs: code_path=<code_path>, diff_filename=<diff_filename>, output_filename=review-scope-structure-abstraction.json. Write output JSON to exactly output_filename. Run this subagent with workspace-write sandbox access. Do not run in parent; execute in this subagent only." \ > review-scope-structure-abstraction.log 2>&1 & codex exec --sandbox workspace-write -C "<code_path>" \ "Invoke skill review-upgrade-compatibility-and-test-determinism directly. Inputs: code_path=<code_path>, diff_filename=<diff_filename>, output_filename=review-upgrade-compatibility-and-test-determinism.json. Write output JSON to exactly output_filename. Run this subagent with workspace-write sandbox access. Do not run in parent; execute in this subagent only." \ > review-upgrade-compatibility-and-test-determinism.log 2>&1 & wait - Start all six tasks before awaiting any single one.
- Monitor all six tasks in a polling loop; do not block forever on only one task while ignoring the others.
- Slow progress is not a hang. Keep waiting while a task remains in a valid running state.
- Before force-terminating for hang, perform multiple long-interval checks (for example, at least 3 checks spaced at least 5 minutes apart). If any progress appears, reset the hang suspicion counter.
- If a task must be terminated for an obvious hang, record the explicit hang signal in failure details and preserve any output file that already exists.
- Use fixed output filenames:
review-clarity-naming-comment-intent.jsonreview-correctness-query-planner-execution.jsonreview-correctness-state-schema-transaction.jsonreview-runtime-reliability-performance.jsonreview-scope-structure-abstraction.jsonreview-upgrade-compatibility-and-test-determinism.json
- Reviewer invocation map:
- review-clarity-naming-comment-intent ->
review-clarity-naming-comment-intent.json - review-correctness-query-planner-execution ->
review-correctness-query-planner-execution.json - review-correctness-state-schema-transaction ->
review-correctness-state-schema-transaction.json - review-runtime-reliability-performance ->
review-runtime-reliability-performance.json - review-scope-structure-abstraction ->
review-scope-structure-abstraction.json - review-upgrade-compatibility-and-test-determinism ->
review-upgrade-compatibility-and-test-determinism.json
- review-clarity-naming-comment-intent ->
- Scope-breach guard during step 2:
- if a review subagent emits prepare/merge/cleanup artifacts (outside its own
output_filename) as a primary action, treat asscope-breachand rerun that reviewer in a fresh isolated subagent
- if a review subagent emits prepare/merge/cleanup artifacts (outside its own
- Detect one dispatch backend:
Merge and submit review
- After all subagents finish, invoke merge-review-json-and-submit-pr-review in a fresh isolated subagent (
fork_context=false). - Pass:
pr_linkinput_files= all 6 review JSON files from step 2
- Optional outputs:
merged_output=merged-review-output.jsonpayload_output=github-review-payload.json
- After all subagents finish, invoke merge-review-json-and-submit-pr-review in a fresh isolated subagent (
Cleanup (always attempt)
- Invoke cleanup-pr-diff-worktree in a finally-style step in a fresh isolated subagent (
fork_context=false). - Pass:
work_treefrom prepare outputproject_pathwhen needed by current directory context
- Cleanup must run even if any reviewer or merge step fails.
- Invoke cleanup-pr-diff-worktree in a finally-style step in a fresh isolated subagent (
Return orchestration summary JSON
- Include:
- prepare result JSON
- per-review output file list
- merge/submit result JSON
- cleanup result JSON
- final
status
- Include:
Failure Handling
- If prepare fails: stop pipeline and return
failed. - If context isolation cannot be guaranteed for any subagent launch: stop pipeline and return
failedwith reasoncontext-isolation-unavailable. - If neither native Task/subagent dispatch nor
codex execis available in step 2: stop pipeline and returnfailedwith reasonsubagent-dispatch-unavailable. - If one or more
codex execsubagents fail to start or exit non-zero, treat as reviewer-subagent failure. - Do not run any reviewer inline in the parent as fallback.
- If a subagent performs out-of-scope orchestration work, treat as
scope-breach, terminate it, and retry that step in a fresh isolated subagent. If retry still breaches scope, returnpartial-failurewith reasonscope-breach. - If one or more review subagents fail:
- do not kill other in-flight review subagents unless they also show obvious hang signals
- continue waiting for all non-hung subagents to finish and collect any completed outputs
- skip merge step
- run cleanup
- return
partial-failurewith failure details (including any hang signals used to justify forced termination)
- If merge fails:
- run cleanup
- return
partial-failurewith merge error and file outputs kept for retry
- If cleanup fails:
- return
partial-failureand include cleanup error details
- return
Determinism Requirements
- Do not rename review output filenames.
- Do not drop any of the 6 category review skills.
- Do not reorder severity handling logic inside downstream skills.