Repository navigation
[#3145] Added a 'review-code' skill that reviews the local branch or a pull request against project rules and a team checklist. #3256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
27ff5ce
57648e4
129c6b8
3f99e3c
528f96e
d622cac
cadcb12
a2bd533
4179578
0bdef0a
1a6c163
863fb79
b1e343d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| --- | ||
| name: review-code | ||
| description: Use when asked to review code, review the current branch, check changes before opening a pull request, or review a GitHub pull request from its URL or number. | ||
| --- | ||
|
|
||
| # Review code | ||
|
|
||
| Review a change the way a senior developer on this project would: against | ||
| the project's own rules first, then the team checklist, then general | ||
| engineering judgment. | ||
|
|
||
| The review is read-only. Never edit the project's files, check out | ||
| branches, push, or post to GitHub. Writing to the git-ignored `.artifacts/` | ||
| directory, such as the documentation cache `AGENTS.md` describes, is | ||
| allowed. Print the report in the conversation and stop. | ||
|
|
||
| Run every command from the project root. | ||
|
|
||
| ## 1. Get the diff | ||
|
|
||
| **Pull request** (a URL, or a number such as `123`). Drop a leading `#` | ||
| from a number first, because the shell reads `#` as the start of a | ||
| comment. | ||
|
|
||
| 1. `gh pr view <pr> --json number,title,body,url,state,headRefOid` | ||
| 2. `gh pr diff <pr>` | ||
|
|
||
| Pass the full URL as `<pr>` whenever the developer gave one, so `gh` reads | ||
| the right repository. To read a changed file in full at the PR head, take | ||
| `<owner>/<repo>` from the PR URL and run | ||
| `gh api -H "Accept: application/vnd.github.raw" "repos/<owner>/<repo>/contents/<path>?ref=<headRefOid>"`. | ||
| When `git cat-file -e <headRefOid>` succeeds, `git show <headRefOid>:<path>` | ||
| reads the same content locally. Never read a PR file from the working | ||
| tree, which can hold uncommitted edits. | ||
|
|
||
| When `state` is `MERGED` or `CLOSED`, say so at the top of the report, | ||
| leave out the verdict, and present the findings as follow-ups. | ||
|
|
||
| When the pull request belongs to another repository, the rules in step 2 | ||
| come from that repository: read its `AGENTS.md`, `CLAUDE.md` and | ||
| contributing docs with `gh api`, and skip `checklist.md`. | ||
|
|
||
| **Local branch** (no argument): | ||
|
|
||
| 1. Find the base: the branch the developer names, otherwise the default | ||
| branch from `git symbolic-ref --short refs/remotes/origin/HEAD` | ||
| without its `origin/` prefix. When that command fails, use | ||
| `gh repo view --json defaultBranchRef --jq .defaultBranchRef.name`. | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| 2. `git fetch origin <base>` | ||
| 3. `git merge-base origin/<base> HEAD` and copy the hash it prints. | ||
| 4. `git diff <hash>` - this includes uncommitted changes. | ||
| 5. `git status --short` - read untracked files as new files. | ||
| 6. `git log --oneline origin/<base>..HEAD` for the intent of the change. | ||
|
|
||
| When the base does not resolve, or both the diff and the untracked files | ||
| are empty, reply with 1 line that says which and stop. When the developer expected changes, also run | ||
| `git status --short --ignored` and name any ignored files that match. | ||
|
|
||
| ## 2. Load the rules | ||
|
|
||
| Apply them in this order. An earlier source wins over a later one. | ||
|
|
||
| 1. `AGENTS.md`, any `AGENTS.md` or `CLAUDE.md` in a directory the change | ||
| touches, and the files in `docs/` - the decisions this project made. | ||
| When they allow something the checklist would flag, do not flag it. | ||
| 2. `checklist.md` in this directory - the team's review checklist. | ||
| 3. General judgment: correctness, security, data loss, error handling, | ||
| and missing tests. | ||
|
|
||
| Skip anything the project's linters already enforce: `ahoy lint` and any | ||
| other lint command that `AGENTS.md` lists. Flag a change that disables or | ||
| bypasses a linter. | ||
|
|
||
| ## 3. Review | ||
|
|
||
| - Read each changed file in full, not only the diff hunks. Open the | ||
| callers, services, routes and config that the change relies on. | ||
| - Spot-check generated files, such as lock files and test fixtures, | ||
| instead of reading them in full. | ||
| - Check every finding against the code before reporting it. Drop it when | ||
| the code already handles the case. | ||
| - A claim that cannot be checked from the code goes in **Questions**, not | ||
| in a severity section. | ||
|
|
||
| ## 4. Report | ||
|
|
||
| Use this format and leave out empty sections: | ||
|
|
||
| ```markdown | ||
| ## Review: <PR title, or branch name> | ||
|
|
||
| **Verdict:** Ready to merge | Ready after fixes | Needs work | ||
|
|
||
| ### Critical | ||
| - `path/to/file.php:42` - What is wrong. Why it matters. How to fix it. | ||
|
|
||
| ### Important | ||
| - ... | ||
|
|
||
| ### Minor | ||
| - ... | ||
|
|
||
| ### Questions | ||
| - Things the author needs to confirm. | ||
| ``` | ||
|
|
||
| Point each finding at `path:line`. Use the path alone when the finding is | ||
| about something missing, such as a test. | ||
|
|
||
| | Severity | Use for | | ||
| |-----------|------------------------------------------------------------------------------------------| | ||
| | Critical | Security holes, data loss, broken behavior, a change that fails the build or deployment | | ||
| | Important | Bugs in edge cases, missing tests for changed behavior, checklist violations | | ||
| | Minor | Readability and maintainability. Report at most 5. | | ||
|
|
||
| | Verdict | When | | ||
| |-------------------|--------------------------------------------------------------| | ||
| | Needs work | Any Critical finding, or a question that blocks the merge | | ||
| | Ready after fixes | Important findings and no Critical ones | | ||
| | Ready to merge | Only Minor findings, non-blocking questions, or no findings | | ||
|
|
||
| When there are findings, offer to fix them or post them to the pull | ||
| request. Do neither unless the developer asks. | ||
|
Comment on lines
+122
to
+123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve the read-only contract. Line 12 through Line 15 says the skill must never edit project files or post to GitHub. Line 122 through Line 123 then permits fixing or posting when the developer asks. This conflicting instruction can trigger side effects that the skill forbids. Offer a patch draft or posting instructions only; keep edits and GitHub actions out of this skill.
|
||
|
|
||
| ## Customizing | ||
|
|
||
| - Change what the review checks: edit `checklist.md`. | ||
| - Change a project rule: edit `AGENTS.md` or `docs/`. The review reads | ||
| them on every run. | ||
| - Change the procedure or the report format: edit this file. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Review checklist | ||
|
|
||
| The team owns this file. Add, change or remove items to match how the | ||
| project works. `AGENTS.md` and `docs/` override anything here. | ||
|
|
||
| ## Security | ||
|
|
||
| - User input reaches SQL only through placeholders or the query builder, | ||
| never through string concatenation. | ||
| - Render arrays use `#plain_text` or a template for values that are not | ||
| trusted, not `#markup` with variables. | ||
| - Twig templates do not apply `|raw` to values that users can change. | ||
| - `t()` and `$this->t()` pass user values through `@` or `%` | ||
| placeholders. | ||
| - Every new route declares `requirements` such as `_permission`. A route | ||
| with `_access: 'TRUE'` is intentionally public. | ||
| - Entity queries call `accessCheck()` explicitly. `accessCheck(FALSE)` | ||
| appears only where the code checks access itself. | ||
| - State-changing actions use Form API forms or a route with | ||
| `_csrf_token: 'TRUE'`. | ||
| - Secrets come from environment variables, not from code, config or | ||
| settings files. | ||
|
|
||
| ## Drupal APIs | ||
|
|
||
| - Classes receive services through dependency injection. `\Drupal::` | ||
| static calls appear only in procedural code such as `.module` and | ||
| `.install` files. | ||
| - Code loads entities with `loadMultiple()` instead of `load()` inside a | ||
| loop. | ||
| - New hooks follow the style the module already uses. | ||
|
|
||
| ## Caching | ||
|
|
||
| - Output that varies by user, role, route or query parameter declares the | ||
| matching `#cache` contexts. | ||
| - Output built from entities or config declares their cache tags. | ||
| - Code sets `max-age` to `0` only with a comment that explains why. | ||
|
|
||
| ## Configuration and updates | ||
|
|
||
| - Configuration changes are exported to `config/default`. | ||
| - Custom modules that add configuration ship a schema in | ||
| `config/schema/`. | ||
| - Changes that need existing data or configuration transformed ship a | ||
| `hook_update_N()`, `hook_post_update_NAME()` or a deploy hook in | ||
| `*.deploy.php`. | ||
| - Settings for a contributed module go in | ||
| `web/sites/default/includes/modules/`. | ||
|
|
||
| ## Tests | ||
|
|
||
| - Changed behavior has a test in the suite that covers the changed code. | ||
| - PHPUnit tests sit in the suites that `phpunit.xml` defines. | ||
| - Behat scenarios sit in `tests/behat/features/` and wait for conditions. | ||
|
|
||
| ## Front end | ||
|
|
||
| - JavaScript attaches through `Drupal.behaviors` and uses `once()`. | ||
| - Libraries are attached where they are used, not globally. | ||
| - Twig marks user-facing strings for translation with `|t` or | ||
| `{% trans %}`. |
Uh oh!
There was an error while loading. Please reload this page.