diff --git a/plugins/pr-review/scripts/prompt.py b/plugins/pr-review/scripts/prompt.py index 76677aab..0f3bef80 100644 --- a/plugins/pr-review/scripts/prompt.py +++ b/plugins/pr-review/scripts/prompt.py @@ -78,6 +78,8 @@ For dependency update PRs, do **NOT** approve a target version that was published less than 7 days ago. First-party packages maintained by the same organization as the reviewed repository are intentionally excluded from this 7-day waiting rule, but still scrutinize them for supply-chain risk. +Before reviewing, you MUST read the repository's own guidance to understand the repo first: read `AGENTS.md` at the repository root (and any nested `AGENTS.md` covering the changed files), plus other relevant docs when present — e.g. `CONTRIBUTING.md`, `CLAUDE.md`, `.cursorrules`, and any review or coding-guideline docs. Apply that guidance to your review. + Review the PR changes below and identify issues that need to be addressed. ## Pull Request Information diff --git a/skills/github-pr-reviewer/scripts/main.py b/skills/github-pr-reviewer/scripts/main.py index 62ec29e6..136b9a65 100644 --- a/skills/github-pr-reviewer/scripts/main.py +++ b/skills/github-pr-reviewer/scripts/main.py @@ -453,12 +453,14 @@ def _build_review_prompt(pr: dict, head_sha: str, label_event: dict) -> str: f" Example: `git clone {clone_url} pr-review-{number}`.\n" "2. Check out the exact pull request branch by PR number, then verify HEAD matches the SHA above.\n" f" Example: `git fetch origin pull/{number}/head:openhands-pr-{number}` followed by `git checkout openhands-pr-{number}`.\n" - "3. Inspect the existing PR context before reviewing, including PR description, issue comments, review comments, changed files, and the diff.\n" + "3. Before reviewing, you MUST read the repository's own guidance to understand the repo first.\n" + " Read `AGENTS.md` at the cloned repository root (and any nested `AGENTS.md` covering the changed files), plus other relevant docs when present — e.g. `CONTRIBUTING.md`, `CLAUDE.md`, `.cursorrules`, and any review or coding-guideline docs. Apply that guidance to your review.\n" + "4. Inspect the existing PR context before reviewing, including PR description, issue comments, review comments, changed files, and the diff.\n" " Prefer `gh pr view`, `gh pr diff`, `gh pr checkout`, or GitHub REST API calls with `GITHUB_PERSONAL_ACCESS_TOKEN`; do not print secret values.\n" - "4. Use the checked-out repository to inspect relevant files and surrounding code, not just the patch.\n" - "5. Before producing the final review text, delete only the cloned repository directory created in step 1.\n" + "5. Use the checked-out repository to inspect relevant files and surrounding code, not just the patch.\n" + "6. Before producing the final review text, delete only the cloned repository directory created in step 1.\n" f" Example: `rm -rf pr-review-{number}`. Do not delete any other files or directories.\n" - "6. Write a high-signal review comment with specific findings. If there are no material issues, say so.\n" + "7. Write a high-signal review comment with specific findings. If there are no material issues, say so.\n" f"\nReview instructions:\n{tone}{extra}\n\n" "Output ONLY the review text — no preamble, no meta-commentary. " "This text will be posted verbatim as a comment on the pull request. " diff --git a/tests/test_pr_review_prompt.py b/tests/test_pr_review_prompt.py index 9cec8601..7f2a6f39 100644 --- a/tests/test_pr_review_prompt.py +++ b/tests/test_pr_review_prompt.py @@ -59,6 +59,16 @@ def test_prompt_with_roasted_trigger(): assert "/codereview-roasted" in prompt +def test_prompt_instructs_reading_repo_guidance(): + """The reviewer must be told to read AGENTS.md (and other guideline docs) + to understand the repo before reviewing.""" + prompt = _format_prompt(require_evidence=False) + + assert "AGENTS.md" in prompt + assert "MUST read" in prompt + assert "CONTRIBUTING.md" in prompt + + def test_format_prompt_omits_evidence_requirements_by_default(): prompt = _format_prompt(require_evidence=False)