Skip to content

Commit 073f7b4

Browse files
authored
chore(pr): add PR readiness workflow
Adds a PR template, documents PR readiness expectations, and bundles a pr-ready skill for review-ready branch handoff.
1 parent fd120d4 commit 073f7b4

3 files changed

Lines changed: 191 additions & 5 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Summary
2+
3+
-
4+
5+
## Context
6+
7+
- Related issue/user request:
8+
- Scope:
9+
- Non-goals:
10+
11+
## Changes
12+
13+
-
14+
15+
## Validation
16+
17+
Record exact commands and outcomes. Mark items N/A with a reason when they do not apply.
18+
19+
- [ ] `git diff --check`
20+
- [ ] `cargo fmt --all`
21+
- [ ] `cargo check --workspace`
22+
- [ ] `cargo clippy --workspace --all-targets -- -D warnings`
23+
- [ ] `cargo test --workspace`
24+
- [ ] Targeted/manual checks:
25+
- [ ] Not run:
26+
27+
## PR Readiness
28+
29+
- [ ] Diff is limited to the intended files.
30+
- [ ] Generated files were not edited by hand.
31+
- [ ] User-facing docs/help were updated or are not needed.
32+
- [ ] No secrets, credentials, local paths, or unrelated logs are included.
33+
- [ ] Remaining risks or follow-up work are listed above.

AGENTS.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,24 @@ When creating issues, add labels that map to the relevant crate(s) — for examp
8181

8282
When closing issues via commit, include `fixes #<number>` or `closes #<number>` in the commit message — GitHub closes the issue automatically on merge to main.
8383

84+
## PR Readiness
85+
86+
Before opening or updating a PR:
87+
88+
- Re-check the live branch state with `git status --short --branch` and preserve unrelated dirty files.
89+
- Inspect the actual diff with `git diff --stat` and `git diff`; ensure every changed file is intentional for the requested scope.
90+
- Read `.github/PULL_REQUEST_TEMPLATE.md` if present and use it as the PR body structure.
91+
- Choose verification from the touched surface, not a generic checklist. For Rust changes, run the required commands from the Commands section unless the user explicitly narrowed the scope and you can justify a focused subset. For docs/templates-only changes, at minimum run `git diff --check`.
92+
- Include exact commands and outcomes in the PR body. If a check was not run, say why.
93+
- Document context that helps reviewers: related issue/user request, affected crates or docs, user-facing behavior, migration/backcompat notes, and remaining risks.
94+
- Use `gh pr create --body-file <file>` after previewing the exact body text. Never pass multi-line Markdown directly via `--body`.
95+
96+
For parallel-agent or batch work:
97+
98+
- One independently mergeable work unit per branch/PR. Avoid PRs that require another agent's PR to land first.
99+
- Each worker prompt must include the base branch/commit, assigned files or ownership boundary, non-goals, verification recipe, and PR body requirements.
100+
- Each worker final response must include the branch, PR URL, summary, verification evidence, and known gaps. Use a bare `PR: <url>` line when an orchestrator needs to parse results.
101+
84102
## Providers
85103

86104
Coven Code supports exactly two providers: **Claude** (Anthropic) and **Codex**

src-rust/crates/tools/src/bundled_skills.rs

Lines changed: 140 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,97 @@ Be direct and actionable. Focus on unblocking, not on explaining concepts."#,
202202
user_invocable: true,
203203
},
204204

205+
// -----------------------------------------------------------------------
206+
// pr-ready
207+
// -----------------------------------------------------------------------
208+
BundledSkill {
209+
name: "pr-ready",
210+
description: "Prepare or create a review-ready pull request with repo template, context, and verification evidence.",
211+
aliases: &["pr", "pull-request", "ready-pr"],
212+
when_to_use: Some("When the user asks to create or open a PR, make changes PR-ready, or verify a branch before review."),
213+
argument_hint: Some("[scope, issue, or branch]"),
214+
prompt_template: r#"# PR Ready
215+
216+
Prepare a review-ready pull request. Do not commit, push, or open a PR unless
217+
the user has already asked for that action. If the user only asked whether the
218+
branch is ready, report readiness status instead.
219+
220+
## Input
221+
222+
$ARGUMENTS
223+
224+
## Phase 1: Establish Context
225+
226+
1. Read repo instructions (`AGENTS.md` plus nested instruction files that apply)
227+
and `.github/PULL_REQUEST_TEMPLATE.md` if present.
228+
2. Inspect git state with `git status --short --branch`; preserve unrelated
229+
dirty files and never stage files outside this task.
230+
3. Identify the base branch, current branch, related issue or PR, requested
231+
scope, affected crates/docs, and non-goals.
232+
4. Review `git diff --stat` and `git diff` so the PR body reflects the real
233+
changed files.
234+
235+
## Phase 2: Verify
236+
237+
Choose checks from the touched surface and repository instructions:
238+
239+
- Rust: run formatter/checks/tests required by the repo, or explain any focused
240+
subset.
241+
- Docs/templates only: run `git diff --check` and any documented docs build or
242+
link check that covers the changed surface.
243+
- UI/TUI: run focused automated tests and a manual or headless smoke path when
244+
available.
245+
246+
Record each command exactly with pass/fail/blocked status. Do not hide missing
247+
verification; explain the blocker or why the check is out of scope.
248+
249+
## Phase 3: Compose the PR
250+
251+
Use the repository PR template when present. If no template exists, use this
252+
minimum body:
253+
254+
```
255+
## Summary
256+
- ...
257+
258+
## Context
259+
- Related issue/user request:
260+
- Scope:
261+
- Non-goals:
262+
263+
## Changes
264+
- ...
265+
266+
## Validation
267+
- `command` - PASS/FAIL/BLOCKED, key output
268+
- Not run: ...
269+
270+
## PR Readiness
271+
- Diff limited to intended files:
272+
- Generated files handled correctly:
273+
- Docs/help updated:
274+
- Remaining risks:
275+
```
276+
277+
Before creating or updating the PR, write the body to a temp file, preview the
278+
exact file contents, then use `gh pr create --body-file <file>` or
279+
`gh pr edit --body-file <file>`. Never pass multi-line Markdown through
280+
`--body`.
281+
282+
## Final Response
283+
284+
Report the PR URL, branch, summary, verification evidence, and known gaps. If a
285+
PR was opened, include a bare `PR: <url>` line so orchestrators can parse it."#,
286+
allowed_tools: None,
287+
user_invocable: true,
288+
},
289+
205290
// -----------------------------------------------------------------------
206291
// batch
207292
// -----------------------------------------------------------------------
208293
BundledSkill {
209294
name: "batch",
210-
description: "Research and plan a large-scale change, then execute it in parallel across isolated worktree agents that each open a PR.",
295+
description: "Research and plan a large-scale change, then execute it in parallel across isolated worktree agents that each open a review-ready PR.",
211296
aliases: &[],
212297
when_to_use: Some("When the user wants to make a sweeping, mechanical change across many files that can be decomposed into independent parallel units."),
213298
argument_hint: Some("<instruction>"),
@@ -225,6 +310,9 @@ Enter plan mode, then:
225310
226311
1. **Understand the scope.** Launch subagents to deeply research what this instruction
227312
touches. Find all files, patterns, and call sites that need to change.
313+
Read the repo instruction files and existing PR template (`AGENTS.md`,
314+
nested instruction files, `.github/PULL_REQUEST_TEMPLATE.md`) plus relevant
315+
CI workflows so the plan reflects the real review gates.
228316
When research touches OpenClaw CLI flows, verify the live command shape with
229317
`openclaw agent --help`; avoid obsolete `agent main` subcommands and
230318
unsupported OpenClaw persistence flags.
@@ -233,20 +321,37 @@ Enter plan mode, then:
233321
Each unit must be independently implementable in an isolated git worktree and
234322
mergeable on its own without depending on another unit's PR landing first.
235323
236-
3. **Determine the e2e test recipe.** Figure out how a worker can verify its change
237-
actually works end-to-end. If you cannot find a concrete path, ask the user.
324+
3. **Determine the PR readiness contract.** Figure out how each worker can verify
325+
its change end-to-end, which template sections it must fill, which labels or
326+
issue links are relevant, and what evidence reviewers need. If you cannot
327+
find a concrete verification path, ask the user.
238328
239329
4. **Write the plan.** Include: research summary, numbered work units, e2e recipe,
240-
and the exact worker instructions.
330+
PR body requirements, and the exact worker instructions.
241331
242332
## Phase 2: Spawn Workers (After Plan Approval)
243333
244334
Spawn one background agent per work unit using the Agent tool with
245335
`isolation: "worktree"` and `run_in_background: true`. Launch them all in a single
246336
message block so they run in parallel. Each agent prompt must be fully self-contained.
247337
338+
Each worker prompt must include:
339+
340+
- Base branch and base commit/sha.
341+
- The exact assigned objective, owned files or boundaries, and non-goals.
342+
- Required context: instruction files, related issues/PRs, template sections, and
343+
code paths the worker must read before editing.
344+
- Verification commands and expected evidence.
345+
- PR creation rules: stage only files changed for the unit, preserve unrelated
346+
dirty work, write the PR body to a temp file, preview it, then use
347+
`gh pr create --body-file <file>`.
348+
- Final response contract: branch, PR URL, summary, verification, risks, and a
349+
bare `PR: <url>` line.
350+
248351
After each agent finishes, parse the `PR: <url>` line from its result and render
249-
a status table. When all agents have reported, print a final summary."#,
352+
a status table with unit, branch, PR, verification, and risk/gap columns. When
353+
all agents have reported, print a final summary that identifies ready PRs,
354+
blocked PRs, duplicate work, and any remaining integration order."#,
250355
allowed_tools: None,
251356
user_invocable: true,
252357
},
@@ -554,6 +659,22 @@ mod tests {
554659
assert!(skill.prompt_template.contains("options"));
555660
}
556661

662+
#[test]
663+
fn pr_ready_skill_enforces_template_and_body_file_contract() {
664+
let skill = find_bundled_skill("pr-ready").unwrap();
665+
assert!(skill.user_invocable);
666+
assert_eq!(find_bundled_skill("pull-request").unwrap().name, "pr-ready");
667+
assert!(skill
668+
.prompt_template
669+
.contains(".github/PULL_REQUEST_TEMPLATE.md"));
670+
assert!(skill
671+
.prompt_template
672+
.contains("git status --short --branch"));
673+
assert!(skill.prompt_template.contains("preserve unrelated"));
674+
assert!(skill.prompt_template.contains("gh pr create --body-file"));
675+
assert!(skill.prompt_template.contains("PR: <url>"));
676+
}
677+
557678
#[test]
558679
fn batch_skill_guards_stale_openclaw_research_patterns() {
559680
let skill = find_bundled_skill("batch").unwrap();
@@ -564,6 +685,20 @@ mod tests {
564685
.contains("unsupported OpenClaw persistence flags"));
565686
}
566687

688+
#[test]
689+
fn batch_skill_requires_pr_readiness_contract_for_workers() {
690+
let skill = find_bundled_skill("batch").unwrap();
691+
assert!(skill
692+
.prompt_template
693+
.contains(".github/PULL_REQUEST_TEMPLATE.md"));
694+
assert!(skill.prompt_template.contains("PR readiness contract"));
695+
assert!(skill
696+
.prompt_template
697+
.contains("Base branch and base commit/sha"));
698+
assert!(skill.prompt_template.contains("gh pr create --body-file"));
699+
assert!(skill.prompt_template.contains("risk/gap columns"));
700+
}
701+
567702
#[test]
568703
fn find_case_insensitive() {
569704
assert!(find_bundled_skill("SIMPLIFY").is_some());

0 commit comments

Comments
 (0)