# Review  -  Module review guide discovery (Step 2b)

> Loaded by `review/SKILL.md` Step 2b. The SKILL keeps what a guide is and the scope rule; this file carries the discovery walk, the PR-mode probe and the reviewer-prompt injection block.

```bash
# Changed file paths from the patch:
grep -E '^\+\+\+ b/' "$DIFF_FILE" | sed 's|^+++ b/||' | sort -u > /tmp/multi-agent-review-${TASK_ID}-paths.txt

# For each changed path, walk its directory chain up to the repo root and
# collect guide files matching: CLAUDE.md, *-CLAUDE.md, AGENTS.md.
# Root-level CLAUDE.md/AGENTS.md are excluded  -  the host CLI already loads those.
guides=()
while IFS= read -r p; do
  d=$(dirname "$p")
  while [ "$d" != "." ] && [ "$d" != "/" ]; do
    for g in "$d"/CLAUDE.md "$d"/*-CLAUDE.md "$d"/AGENTS.md; do
      [ -e "$g" ] && guides+=("$g")
    done
    d=$(dirname "$d")
  done
done < /tmp/multi-agent-review-${TASK_ID}-paths.txt
# dedupe, cap at 5 (log any dropped so truncation is never silent)
```

Existence checks are resolved against the local checkout when the cwd is the target repo. In PR mode without a local checkout, probe the candidate paths via the provider API instead (`gh api /repos/{o}/{r}/contents/{path}?ref={headSha}` / Bitbucket `GET /projects/{KEY}/repos/{slug}/browse/{path}?at={headSha}`) and fetch the matching files' raw content the same way. No hit → step is a silent no-op.

## Reviewer-prompt injection

Persist `agent-state.review.moduleGuides = [<repo-relative paths>]` and inject this block into every reviewer prompt (Step 3):

> MODULE REVIEW GUIDES: before reviewing, read each of these guide files. Apply a guide's rules/checklist to every changed file under its directory. Guide violations are findings like any other  -  triage them by severity.

Scope: a guide governs only files under its own directory  -  a guide found under one module must not be applied to a sibling module's changes in the same PR.
