liferay/liferay-portal / .claude/skills/pr-check
pr-check
VerifiedCheck that a PR is ready to be sent for review.
validations/branch/pr-reviewer.md
View on GitHub# PR Reviewer
Reviews the branch diff against the rules in `pr-reviewer/rules`, which hold the conventions the source formatter does not enforce, and applies the fixes the reviewer returns. The reviewer drops generated files, frontend sources, generated locale files, and lock files itself, and exits at once when nothing is left, so a diff of only those costs one command.
## Match
`.`
## Command
Resolve the directory that holds the reviewer. A `liferay-portal-ee` checkout ships no `pr-reviewer` directory, so it uses the one in `LIFERAY_PR_REVIEWER_HOME` or in a sibling `liferay-portal` checkout, the same places `review.sh` reads the rules from:
```bash
REVIEWER_HOME="${REPO_ROOT}/pr-reviewer"
if [[ ! -f ${REVIEWER_HOME}/review.sh ]]
then
REVIEWER_HOME="${LIFERAY_PR_REVIEWER_HOME:-${REPO_ROOT%/*}/liferay-portal/pr-reviewer}"
fi
```
When `${REVIEWER_HOME}/review.sh` does not exist, report **NOT VERIFIED**, name the path that was tried, and say to set `LIFERAY_PR_REVIEWER_HOME` or to check out `liferay-portal` beside this repository.
Review the branch diff against the rules in `${REVIEWER_HOME}/rules`:
```bash
LOG=$(mktemp)
LOG_ERROR=$(mktemp)
(cd "${REPO_ROOT}" && "${REVIEWER_HOME}/review.sh" --json "${MERGE_BASE}..HEAD" > "${LOG}" 2> "${LOG_ERROR}")
```
The exit status is the verdict. `0` with a nonempty `reviewed_files` list is a clean diff, so report **PASS** and quote how many files the list holds. `0` with an empty list means that every changed file was generated, frontend, or ignored, so report **NOT VERIFIED** and say that the reviewer had nothing to review. `2` means the reviewer could not run, most often because the `claude` CLI is not on the PATH, so report **NOT VERIFIED** and quote `${LOG_ERROR}`. `1` means violations, and the log holds one JSON object whose `violations` array has an entry for each violation, with `file`, `line`, `rule`, `message`, and `fix`. A group that returned no verdict is named in `${LOG_ERROR}` even then, and the run reports the violations the other groups found. When it is, report **NOT VERIFIED** in place of a **PASS** and quote it.
Apply the fixes. For each violation, read the rule file `${REVIEWER_HOME}/rules/<rule>-*.md` and the code around the line, then make the change the `fix` describes. A `fix` that starts with `Verify:` is one the reviewer was not sure about, so confirm it against the rule and the surrounding code first, and leave the code alone when the rule does not apply. Skip a `fix` that SourceFormatter would revert; the reviewer marks those with `SourceFormatter is authoritative`. Never edit a file that carries an `@generated` marker.
When a fix changed a file under `workspaces/liferay-sample-workspace`, regenerate the other workspaces from it:
```bash
"${REPO_ROOT}/workspaces/refresh_other_workspaces.sh"
```
The reviewer leaves out the copies the refresh writes, so it never flags them, and without the refresh each copy keeps the text the fix replaced and fails [Generated Workspace File](../workspaces/generated-file.md). Skip the refresh when the script does not exist, as in `liferay-portal-ee`.
When at least one fix was applied, commit as the **Autocommit** section says, then review once more:
```bash
LOG_RERUN=$(mktemp)
LOG_RERUN_ERROR=$(mktemp)
(cd "${REPO_ROOT}" && "${REVIEWER_HOME}/review.sh" --json "${MERGE_BASE}..HEAD" > "${LOG_RERUN}" 2> "${LOG_RERUN_ERROR}")
```
Report **PASS** when the rerun exits `0`. Report **NOT VERIFIED** when it exits `2`, quote `${LOG_RERUN_ERROR}`, and say in the note that the fixes in the `<TICKET> Apply pr-reviewer rules` commit were not reviewed again. Keep that commit, since each fix in it was checked against its rule before it was applied. When the rerun exits `1`, judge each violation it flags the way the first round does, by reading the rule file and the code around the line, but apply no fix. A violation you already dismissed in the same file under the same rule stays dismissed. Report **FAIL** when at least one violation still applies, and return those violations as the note below. Report **PASS** when you dismissed every one. Do not start a second round of fixes, since a violation the first round did not resolve needs the developer's judgment, and a loop of automated rounds can chase a false positive indefinitely.
```markdown
**The pr-reviewer rules still flag this branch.** Apply each fix below, or leave the code as it is when a violation is a false positive and say so in the PR description.
| File | Line | Rule | Violation | Fix |
| --- | --- | --- | --- | --- |
| <file> | <line> | <rule> | <message> | <fix> |
```
When no fix was applied, skip the rerun. Report **FAIL** with the same note when at least one violation applies and could not be fixed, and report **PASS** when you dismissed every violation as a false positive.
Whenever you applied a fix, return the applied fixes as the note below, with any verdict, so that the developer can review the `<TICKET> Apply pr-reviewer rules` commit before sending the PR. Give the line in the file before the fix, as the first review reported it:
```markdown
**The pr-check applied these pr-reviewer fixes in the `<TICKET> Apply pr-reviewer rules` commit.** Review each one, and revert any that you disagree with.
| File | Line | Rule | Violation | Change |
| --- | --- | --- | --- | --- |
| <file> | <line> | <rule> | <message> | <what was changed> |
```
Whenever you dismissed a violation, return the dismissed violations as the note below, with a **PASS** as well as a **FAIL**, so that the developer can confirm each one:
```markdown
**The pr-check judged these pr-reviewer violations to be false positives.** Confirm each one, and say so in the PR description.
| File | Line | Rule | Violation | Reason |
| --- | --- | --- | --- | --- |
| <file> | <line> | <rule> | <message> | <why the rule does not apply> |
```
## Autocommit
When `git status --porcelain` is nonempty after the fixes and the refresh, stage the tracked modifications with `git add --update` and create a commit titled `<TICKET> Apply pr-reviewer rules`. `--update` stages each regenerated copy with the fix it carries, and leaves out the ignored build output the refresh also copies.
## Notes
Run **after** the drift validations, so the reviewer sees the regenerated tree, and **before** Source Format, Workspace Source Format, and Go Source Format, so that the formatters format the fixes. That holds in `liferay-portal-ee` too, which has no `portal-impl` to run `format-source-current-branch` from.
The reviewer calls the model once per rule group, in parallel, and every group reads the rules that apply to it in full, so the cost is mostly fixed per run rather than per line.
## Time Estimate
~1-3 min for each review, and it reviews twice when it applies fixes.Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |