Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
514 changes: 183 additions & 331 deletions .agents/skills/ziw-code-review/SKILL.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .agents/skills/ziw-code-review/agents/openai.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
interface:
display_name: "Code Review"
short_description: "Review code changes"
default_prompt: "Use $ziw-code-review to fetch latest state and review the current committed code when explicitly requested, deliberately selected as judgment-based Author QA, or dispatched as independent Agent Review. Do not auto-trigger solely because a commit or PR changed. Submit GitHub results only when --submit is explicit. Treat implementation-workflow review as Author QA, leave review evidence unchanged, and never mutate tracker or merge-ready labels."
default_prompt: "Use $ziw-code-review for the requested target, scaling effort and report length to risk. Do not auto-trigger solely because a commit or PR changed. Treat implementation-workflow review as Author QA, leave review evidence unchanged, and never mutate tracker or merge-ready labels. Independent evidence requires fresh reviewer context; a worktree alone is insufficient. Follow the skill's authority, conditional references, and report contract."
policy:
allow_implicit_invocation: true
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,37 @@ Repo-specific identity rules win.
account, such as triggering an external review bot. Local review submission
is not an external-bot trigger.

Use the repo-configured account login as the expected reviewer identity. Compare
it with API `user.login` on existing and submitted reviews, not a display name,
Git author, or identity claimed in the body.

Never print tokens, credentials, private keys, or authenticated headers.

## Freshness

1. Resolve repository owner/name, PR number and URL, base SHA, and current
`headRefOid` from GitHub.
2. Confirm the locally reviewed head exactly equals the current `headRefOid`.
3. Immediately before posting, resolve `headRefOid` again. If it changed, do
not post stale results. Refresh the checkout and rerun the review.
4. Inspect existing reviews for this head before posting. A body containing
`<!-- ziw-local-review head=<full-sha> -->` is current local-review evidence.
Return its URL instead of creating a duplicate review.

3. Complete the local report, including mode, evidence recommendation,
verdict, conformance, and P0-P2 findings, before checking for a duplicate.
4. Inspect existing reviews and their inline comments through the GitHub API.
Reuse a review only when all of these facts match the completed local
report:
- the API `commit_id` equals the reviewed full head SHA
- API `user.login` equals the configured reviewer account
- API state is `COMMENTED` and `submitted_at` is present
- the body contains the exact marker
`<!-- ziw-local-review head=<full-sha> -->`
- review mode, review-evidence recommendation, verdict, and conformance are
compatible with the completed local report
- the body and inline comments cover every actionable P0-P2 finding in the
completed local report
5. Recheck the current PR head before returning an existing review URL or posting.
If it changed, refresh and rerun review. Reuse only after all checks pass.
Otherwise post the completed current review. A matching marker alone is not evidence, and
a prior clean review cannot replace a report with new findings.

Do not reuse a mismatching, incomplete, pending, dismissed, or forged review.
Do not treat a review on an older commit as current evidence.

## Review Shape
Expand All @@ -40,6 +58,8 @@ Submit one review through:
POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews
```

Field definitions: [GitHub review API](https://docs.github.com/en/rest/pulls/reviews).

Use a JSON payload with:

- `commit_id`: the exact reviewed head SHA
Expand Down Expand Up @@ -72,9 +92,14 @@ into shell source.

After submission:

1. Verify the API response belongs to the expected PR and commit.
2. Verify its state is `COMMENTED` and capture its `html_url`.
3. Return `GitHub submission: POSTED <review URL>` in the review report.
1. Verify the API response belongs to the expected PR and its `commit_id`
equals the reviewed head.
2. Verify API `user.login` equals the configured reviewer account.
3. Verify its state is `COMMENTED`, its body has the exact marker, and the
published body and inline comments preserve the completed local report's
verdict and P0-P2 findings.
4. Capture its `html_url` and return
`GitHub submission: POSTED <review URL>` in the review report.

If the API rejects an inline location, correct the payload once by moving that
finding into the review body. Do not fall back to scattered issue comments or a
Expand Down
57 changes: 57 additions & 0 deletions .agents/skills/ziw-code-review/references/hosted-review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Hosted review

Use for existing PRs or an explicit hosted-review request. Recommend actions;
this skill does not trigger bots or change PR state.

## Current evidence

Read repo workflow config, provider config at the reviewed head, and current PR
reviews, bodies, and every inline comment, including human reviews. A clean
summary with unresolved blocking inline findings is not a clean review.

Report auto-review as enabled, disabled, opt-in, provider-specific, or unknown.
For CodeRabbit, check root `.coderabbit.yaml` and `reviews.auto_review`. For
Cursor Bugbot or other providers, use verified repo policy. Include draft and
incremental-review behavior only when it changes the recommendation.

## Recommendation

- Default to `SKIP` after clean review of low-risk changes.
- Recommend `PR REVIEW` for an existing PR when required by repo policy,
explicitly requested, or warranted by risk, complexity, or unresolved
uncertainty. Examples include auth, secrets, payments, destructive data,
migrations, background jobs, public contracts, and cross-cutting refactors.
- If a current review is pending, recommend `WAIT` with no command. If automatic
push review is enabled and the current diff is eligible, let it run without
another trigger. If auto-review mode, actor, or permissions are unknown,
report the gap and recommend no command. A completed current review needs no
duplicate trigger; evaluate its findings.
- Recommend `CLI` only for an explicit local CodeRabbit request before a PR
exists. Never use it as fallback for a hosted PR review or infer a Bugbot CLI.
- Missing auth, credits, or rate limits may policy-skip optional review. Report
required or explicitly requested provider failures as unresolved, not passed.

When a manual CodeRabbit trigger is warranted and repo policy permits it,
recommend `@coderabbitai review` for incremental review or
`@coderabbitai full review` when a full pass is needed. Optional automatic review
may be skipped with `@coderabbitai ignore` in the PR description only when repo
policy permits it. For other providers, recommend only verified configured
commands. The caller owns any authorized trigger or description edit.

Evaluate bot findings against source evidence. Prioritize P0/P1, security, data
loss, correctness regressions, production blockers, and user-requested findings.
Do not recommend keeping a locally clean PR in draft solely to wait for hosted
review; report whether review should run after Orchestrator marks it ready.

## Report fields

```text
Hosted bot review provider: <none | CodeRabbit | Cursor Bugbot | other | unknown>
Hosted bot review recommendation: SKIP | WAIT | CLI | PR REVIEW, because <reason>
Hosted bot review state: auto-review <enabled | disabled | opt-in | provider-specific | unknown>; hosted review <none | pending | complete | unknown>
Hosted bot review command: <none | verified command>
```

Keep unknown, pending, and policy-skipped states explicit. None is evidence of a
completed clean review. An unconfigured provider does not establish its automatic
review settings; report unknown settings rather than inferring they are disabled.
45 changes: 45 additions & 0 deletions .agents/skills/ziw-code-review/references/main-drift.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Main drift and review-debt intake

Use only for independent checkpoint review or explicitly authorized review-debt
intake. Ordinary PR review recommends follow-ups without creating tracker issues.
For intake without a main-drift request, skip checkpoint handling.

## Checkpoint review

Keep the checkpoint outside the repo:

```text
${CODEX_HOME:-$HOME/.codex}/automation-state/ziw-review/<repo-slug>/last-reviewed-origin-main
```

On first run, record current `origin/main` and stop unless backfill was requested.
Otherwise review the supplied checkpoint-to-current range as merged product
state. If the checkpoint is not an ancestor, report the history problem; do not
silently replace the range or advance the checkpoint over unreviewed work.

Collect spec sections cited by tickets linked to merged PRs in the range. Verify
merged behavior against those sections using the core conformance table. Report
escaped conformance drift separately from new bugs, with audited sections and
outcomes. Advance the checkpoint only after review and authorized issue updates
complete. Report incomplete intake and leave the checkpoint unchanged on failure.

## Tracker intake

Search for duplicates by problem, files, PR, and range before creating or updating
issues. Use the configured review-debt intake route, label, project, or parent.
If no dedicated route exists, use the configured normal repo route and report
the setup gap. If the provider/location itself is unknown, report the blocker.

- Use the configured provider location, routing label, and risk labels.
- Use `Bug` or `Tech Debt` unless another type clearly fits.
- Use `kind-slice` only for one concrete PR with acceptance criteria and checks;
otherwise use `kind-spec` or `kind-epic` for To Issues to slice.
- Add `ready-for-agent` only when config allows review to create ready debt and
the full issue-body contract is satisfied. Otherwise use `needs-info` or
`ready-for-human` with the exact decision needed.
- Include reviewed range and file evidence. Keep issue text metadata-only.

Escalate findings needing product, security, customer, credential, provider, or
ADR judgment instead of ticketing them. Suppress low-confidence, duplicate, and
style-only issues. Return issues created or recommended, checkpoint outcome when
applicable, and the next owner/action to Orchestrator.
33 changes: 23 additions & 10 deletions .agents/skills/ziw-code-review/references/remote-worker-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ Use this when the user asks for a remote worker agent to review a branch or PR.
- Use the repo-configured remote worker provider from
`docs/agents/workflow/config.md`.
- Launch a review-only run against the PR branch or head ref.
- Start a fresh reviewer session with no implementation conversation context.
A separate worktree isolates files only; it does not make a reused session an
independent reviewer.
- Set auto-PR creation off when the provider supports that option.
- Paste the prompt below.
- Supply the installed `ziw-code-review` skill path with the prompt below. If the
worker cannot access it, provide the skill and its applicable references.
- Do not print, store, or commit provider API keys.

For remote review, assume hosted secrets are opt-in per issue. Default to local
Expand All @@ -21,9 +25,17 @@ credentials.
Code review only. Do not edit files, commit, push, or open a PR.

Repo/branch: <repo and branch or PR URL>
Base: <base branch>
Immutable target SHA: <full reviewed head or checkpoint SHA>
Base SHA or merge base: <full SHA>
Intent: <user request or issue outcome>
Linked issue and acceptance criteria: <issue URL/key and exact criteria, or explicitly missing>
Cited spec sections: <exact sections, or none>
Required checks: <configured commands and code-host checks>
Review-diff fingerprint: <orchestrator-supplied value, or explicitly missing>
Review skill: <installed ziw-code-review/SKILL.md path or supplied instructions>

Read first:
- The supplied review skill and its applicable references
- AGENTS.md or CLAUDE.md
- docs/agents/workflow/config.md if present
- docs/agents/remote-worker-agent.md or provider adapter docs if present
Expand All @@ -33,18 +45,19 @@ Read first:

Review the diff against the base branch for correctness, security, data loss, race conditions, API/schema contract drift, missing enum/status handling, missing tests, and scope drift. Scope drift includes delivering adjacent tickets, optional polish, broad refactors, or new surfaces outside the issue boundary. Run focused checks if cheap. Do not call hosted bot review providers such as CodeRabbit or Cursor Bugbot from this worker.

Resolve the target only from the immutable target SHA. Confirm the checkout and
diff match the supplied target and base before reviewing. Stop with a stale or
missing-input result if they do not. Treat a missing orchestrator fingerprint
as missing evidence. Do not derive one from the head SHA.

Use this review rubric:
- Verify every finding with file:line evidence.
- Prioritize P0/P1 correctness, security, auth, data-loss, migration, concurrency, and API-contract issues.
- Treat config/numeric limit changes as high-risk until justified by production bounds, rollback, and monitoring.
- Suppress style nits, low-confidence speculation, broad refactors, and optional micro-optimizations.

Return only:
- Scope check: clean, drift, or missing requirements
- Findings table with severity, confidence, file:line, evidence, impact, and suggested fix
- Checks run
- Hosted bot review recommendation: skip, CLI, or PR review; include provider
and auto-review mode
and command or skip marker when known
- Verdict: ready, needs revision, or do not merge
Return the canonical `## REVIEW REPORT` defined by the supplied review skill,
including conformance and the applicable workflow/PR handoff fields.
Do not substitute a reduced report. Do not fix findings, trigger hosted review
bots, mutate tracker or code-host state, or perform merge or deployment work.
```
47 changes: 0 additions & 47 deletions .agents/skills/ziw-code-review/references/review-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,50 +146,3 @@ Confidence guide:
- Idempotency tests only cover first success, not completed retry, in-flight retry, retry after optional side effects, and retry under rate-limit pressure.
- Destructive or revocation tests assert database state but not the externally
visible API behavior after invalidation, such as old URLs or handles failing.

## Hosted Bot Review Escalation Rubric

Recommend `SKIP` when the code review is clean and the PR is docs-only, tests-only, copy/UI-only, a mechanical rename, dependency metadata, or a small isolated bug fix with good tests.

Recommend `CLI` only when the configured provider supports a local CLI, the PR is not open yet, and the change is high risk enough to benefit from another model pass before publishing. CodeRabbit supports this path when explicitly requested. Do not infer a Cursor Bugbot CLI.

Recommend `PR REVIEW` when the PR is already open, the diff is broad, or review comments need to land on GitHub threads.

Use this CodeRabbit command map only when CodeRabbit is the configured provider:

- Auto-review enabled and the PR is eligible: wait for the automatic review if
it is already running or current; otherwise comment `@coderabbitai review` for
incremental review or `@coderabbitai full review` for a fresh full pass.
- Auto-review disabled or opt-in only: comment `@coderabbitai review` for
incremental review, or `@coderabbitai full review` when no complete review
covers the current review-relevant diff.
- Manual `review` and `full review` commands consume PR review allowance when
the review runs; record a skip instead when rate limits or credits block an
optional review.
- Optional review should be skipped for this PR: add `@coderabbitai ignore` to
the PR description, not a comment. Remove it to re-enable automatic reviews.
- Too many rapid commits: comment `@coderabbitai pause` while work is churning
and `@coderabbitai resume` when the branch is ready for automatic reviews.

For Cursor Bugbot or another hosted review provider, use only the verified
repo-configured trigger or automatic review policy. If the trigger, actor, or
app permission is unknown, report the provider as unresolved rather than
guessing a command.

For a draft PR with a clean local review, do not use draft state as the reason
to delay hosted bot review. Recommend ready-for-review when the local gate is
clean, then recommend `PR REVIEW` only if the risk or complexity triggers below
apply. Ready-for-review means non-draft.

Escalation triggers:

- Auth, authorization, secrets, data retention, deletion, payments, billing, migrations, or background jobs.
- Cross-cutting refactor or public API/schema/CLI contract change.
- Code review found P0/P1 issues and fixes were non-trivial.
- Reviewer uncertainty remains after reading the source and running focused checks.
- User explicitly asks for CodeRabbit, Cursor Bugbot, or another configured
hosted review provider on this PR.

When hosted bot review runs, only act on high-priority findings. High-priority
means P0/P1, security, data loss, correctness regression, production blocker,
or a finding the user specifically asks to address.
Loading