Reviewing
cd /path/to/your-repositorykerpeten review --dry-runThis build only reviews locally: review needs --dry-run, and nothing is posted to a merge request or sent to the backend yet.
What is reviewed
Section titled “What is reviewed”The review is of the change between a base and HEAD. Without --base, the base is the default branch of origin; --base <branch or commit> names another. The change starts where your branch left the base, so commits that came to the base later are not part of it. When there is no --base and origin has no default branch set, the review stops and asks for --base.
The review is of HEAD, but the tools read the files on disk. So kerpeten review stops with an error when a tracked file has uncommitted changes, and names the files; commit or stash them first. Untracked files do not matter, because the tools only see files tracked at HEAD.
Reviewing a pull request or merge request
Section titled “Reviewing a pull request or merge request”gh pr checkout 12 # on GitHubglab mr checkout 12 # on GitLabkerpeten review --dry-run --mr 12--mr <n> reviews pull request or merge request n of the project the origin remote names: a pull request of a GitHub repository, or a merge request of a GitLab project. On GitLab, n is the number inside the project, the one in !12. Kerpeten reads it with the platform’s own command line tool, gh for GitHub and glab for GitLab, so it uses the sign-in of that tool and holds no token of its own. It only reads. The reviewer gets the title and the description instead of the branch name and the commit messages; when the description is empty, it gets the commit messages. The title and the description are data for the models, like the diff.
It needs three things:
- The tool of the platform, installed and signed in to the host of
origin:ghwithgh auth login --hostname <host>, orglabwithglab auth login --hostname <host>. A public project on gitlab.com is read without a sign-in.glabdoes not send aGITLAB_TOKENof the environment to a host it does not know, so sign in to that host. - The working copy at the last commit of the pull request or merge request.
gh pr checkout <n>orglab mr checkout <n>gets it. The review is of that commit, soHEADat another commit stops the review. - The base commit, in the local repository. On GitHub it is the last commit of the branch the pull request goes into, on GitLab the commit where the branch of the merge request left that branch.
git fetch origingets it, becauseoriginis the project.
The change is the one between that base commit and HEAD, from where the branch left the base. So --mr and --base do not go together.
The order is fixed, so that a review that cannot run costs nothing: first the platform is chosen and the project is read from origin, then the tool reads the pull request or merge request of that project, then HEAD is checked against its last commit and the base commit is looked up, then the uncommitted changes are checked, then the diff is made, then the comments of the pull request or merge request are read with the same tool. Only after all of that is a model called.
What it does not do yet: it posts nothing. No comment is written to the pull request or merge request, and --dry-run is still needed. The review does decide what it would write, and shows it: see the comment plan. The comments that are already there are read for that alone, to find the ones Kerpeten wrote; the models do not get them.
Which project
Section titled “Which project”The project is always the one the origin remote names. No other remote plays a part: Kerpeten tells gh or glab the host and the project itself, and the tool chooses neither. So every review with --mr needs an origin remote, also when .kerpeten.yml has platform.
The address of origin can be written as https://host/path, ssh://git@host/path, git://host/path or git@host:path, or in git’s remote helper form <helper>::<address> when the address is itself a URL with a host. The host is the host name alone: a port in the address is not passed on to the tool. A name in the path is letters, digits, ., _ and -, and one .git at the end is dropped. On GitHub the path is an owner and a name. On GitLab it is a namespace and a name, with any groups between.
Two things it cannot do yet:
- A clone of a fork reviews the pull requests or merge requests of the fork. One of the project the fork was made from is not found there, and there is no setting to name another remote.
- A GitLab under a sub-folder of its host, such as
https://host/gitlab/group/project, is not supported. The folder is taken for a part of the project path, and the merge request is not found.
When a repository was renamed or moved and origin still has the old address, the platform answers with the new name. The review then stops and says to point origin at the new address; git remote set-url origin <address> does that.
Which platform
Section titled “Which platform”The host of origin tells the kind of platform: github.com is GitHub, gitlab.com is GitLab. For any other host, such as a GitLab of your own or GitHub Enterprise, set platform in .kerpeten.yml:
platform: gitlabKerpeten does not guess the platform from the host name and does not try one tool after the other. Without the key and without a host it knows, --mr stops with an error that asks for the key. The key names the kind of platform only: the host and the project still come from origin.
The merge request in the output
Section titled “The merge request in the output”The text output starts with one line for the pull request or merge request, and --json has a merge_request object:
{ "merge_request": { "tenant": "default", "platform": { "kind": "github", "host": "github.com" }, "project": { "id": "1296269" }, "mr": 12, "title": "Add a division helper", "state": "open", "head_sha": "69435fefd9f2c0a4b4f4f6d0e3c1a2b3c4d5e6f7", "base_sha": "524f2b14fb27a1b2c3d4e5f60718293a4b5c6d7e" }}platform.kind is github or gitlab. project.id is the platform’s id of the repository: on GitLab, of the project the merge request goes into. state is open, closed or merged. tenant is the value of the environment variable KERPETEN_TENANT, and default when it is not set or empty.
Errors
Section titled “Errors”Each of these stops the review before any model is called. What you can put right ends with exit code 2, and the error says what to do:
| Error | What to do |
|---|---|
The repository has no origin remote, or origin is a path on this machine |
Add an origin remote with the address of the project on GitHub or GitLab. Setting platform does not replace it |
origin names no project: a remote helper without a URL, a URL with a query or a fragment, a path with other characters, one name only, or more than an owner and a name on GitHub |
Correct the address of origin. The message shows the host and the path, never a password |
The host of origin is neither github.com nor gitlab.com, and platform is not set |
Set platform: github or platform: gitlab in .kerpeten.yml |
gh or glab is not found |
Install the GitHub CLI from https://cli.github.com, or the GitLab CLI from https://gitlab.com/gitlab-org/cli |
gh is not signed in to the host of origin |
Run gh auth login --hostname <host> |
GitLab at the host of origin does not accept the sign-in of glab |
Run glab auth login --hostname <host>; when GITLAB_TOKEN is set, correct it there |
| The pull request or merge request was not found | The message names the project that was asked, <host>/<path> of origin. Check the number, and that the sign-in can read that project; GitLab gives this answer too for a private project that glab cannot read. A request of another project, such as the one a fork was made from, is not read |
HEAD is not the last commit of the pull request or merge request |
Run gh pr checkout <n> or glab mr checkout <n>, or push your commits |
| The base commit is not in the repository | Run git fetch origin. origin is the project, so the branch the pull request or merge request goes into is there |
--mr is not a whole number of 1 or more, or --base is given too |
Fix the command line |
A read the platform failed at ends with exit code 1:
| Error | What to do |
|---|---|
A server error of the platform, an answer that cannot be read, or any other failure of gh or glab |
Run again; the error text says what the tool reported |
| The read took longer than two minutes, or the answer was larger than 20,000,000 bytes | Run again; the message names the limit that was reached |
| The platform answers with a pull request or merge request of another project | The repository was renamed or moved: point origin at its new address |
| The comments of the pull request or merge request cannot all be read, also when their list reaches one of the two limits | Run again. Without all comments the review cannot tell which findings are already written, and would write them a second time |
| GitLab is merging the merge request right now | Run again when the merge is done |
| The GitLab merge request has no diff yet | Push a commit to its branch, or wait until GitLab has made the diff |
The comment plan
Section titled “The comment plan”A review of a pull request or merge request ends with a comment plan: for every finding, what a posted review would do with it, and the exact text it would write. Nothing is posted yet; the plan is only shown. A review without --mr has no comment plan, and neither has one whose change is empty, because no model reviewed anything. A review whose reviewer gave no result has none either: it ends with an error and prints no result.
Each finding gets one action. The rules are applied in this order:
| Action | When |
|---|---|
stored |
The scorer stored the finding: the judge refuted it, could not judge it, or its score is under the summary threshold. It is never written. |
suppressed_duplicate |
A line comment of Kerpeten is already on the same lines of the same file, written for the same commit. The finding is not written again. |
inline |
The score reaches the inline threshold and the whole range of the finding lies inside one hunk of the diff, on the side of the new file. Changed lines and the context lines around them both count. The finding becomes a comment on its lines. |
summary |
Every other finding: its score is between the two thresholds, its lines are not in one hunk of the diff, or the review already has as many line comments as limits.max_inline_comments allows. It becomes an entry of the summary comment. |
When more findings qualify for a line comment than the limit allows, the ones with the highest score keep their lines. Findings with the same score are ordered by file, then first line, then title, so the same review always gives the same plan. Findings that are already written do not count against the limit.
Which comments are Kerpeten’s is decided by a hidden marker at the end of the comment, an HTML comment that the platform does not show, and never by the author: a local review writes from your own account. On GitLab a line comment is a note in the diff. A finding counts as already written only for the commit it was written for, so after a new commit it is written again. A finding that an earlier summary comment lists does not count as written.
A line comment has the title of the finding with its category and priority, the body, the fix, a note that asks for a 👎 on findings you do not want again, and the marker:
**Division by zero is not handled** · bug · P1
`div(a, b)` returns Infinity when b is 0.
**Fix:** Check b before dividing.
👎 If you do not want this finding again, react with 👎; you can reply with the reason.<!-- kerpeten:finding v1 head=69435fefd9f2c0a4b4f4f6d0e3c1a2b3c4d5e6f7 file=c3JjL2EudHM lines=2-4 -->In the marker, head is the commit that was reviewed, file is the path of the file written as base64url, and lines is the first and the last line of the finding.
A pull request or merge request has one summary comment. It names the commit that was reviewed and the number of line comments of the run, lists the findings of the summary with the highest score first, and says so when the review ended early. A review with nothing to report still has a summary, with one sentence that says so. It ends with a marker of its own, <!-- kerpeten:summary v1 head=<commit> -->.
The title, the body and the fix are the reviewer’s text, in the comment language. The fixed texts around them are Turkish for the language tr, with or without a region, and English for every other language.
The reviewer’s text cannot break a comment. Outside code, a < that could start HTML gets a backslash, which Markdown does not show, so the text reads the same but cannot hide what follows it or pass for a marker. A code block that is left open is closed. Code is left as it is. A title that ends in a backslash or in #, or that starts or ends with *, gets a backslash there too, so it is shown as written.
No comment is longer than 60,000 characters. A title longer than 300 characters is cut and ends with …. A fix longer than 10,000 characters is cut, and so is a body that does not fit; each then ends with a note that says so. A summary that would be too long lists the findings that fit and says how many it does not show.
The text output has one line for the plan after the findings: line, and the action of each finding is the planned one:
comment plan: 1 line comments, 2 in the summary, 0 already written, 1 stored--json has a comment_plan object after findings, with the whole text of every comment:
{ "comment_plan": { "line_comments": [ { "file": "src/a.ts", "start_line": 2, "end_line": 4, "body": "**Division by zero is not handled** · bug · P1\n\n..." } ], "summary": { "body": "## Kerpeten review\n\n..." } }}Extra context
Section titled “Extra context”--extra-context <path> gives the reviewer and the judge text from outside the repository, such as a ticket, a design note or a team rule; --extra-context - reads it from stdin. The text goes into the message of the reviewer and of every judge call as data, in a block of its own. It must be UTF-8 text of at most 20,000 characters: a source that cannot be read, is not text, is empty or is longer stops the review with an error before any model is called, and nothing is cut. There is no .kerpeten.yml setting for it, so a reviewed change cannot pull a file into the review.
Rule files
Section titled “Rule files”When the repository root has an AGENTS.md or a CLAUDE.md tracked at HEAD, Kerpeten puts its text into the reviewer’s message, as data. The judge does not get it there; it reads the rule lines a finding cites with its tools. Only the text at HEAD counts: an untracked rule file is ignored, and a link that leaves the repository is not read and is reported on stderr. When both files have the same text, as when CLAUDE.md links to AGENTS.md, the text is sent once. A rule file longer than 40,000 characters is cut, and the cut is reported on stderr like a cut diff.
A change that breaks a rule written in these files is a finding with the category convention, for example a name that AGENTS.md says must be snake_case but that the change writes in camelCase. Its evidence cites the rule line. Rules about how a person or an agent should work, such as which commands to run, are not code rules and are ignored.
The judge
Section titled “The judge”The candidate filter drops findings whose file or lines do not exist at HEAD. Each kept finding then goes to the judge in its own call. When no finding is left after the filter, because the reviewer reported none or the filter dropped them all, the judge is not called.
The judge has its own limits beside the reviewer’s; Configuration lists them.
Output
Section titled “Output”Each finding shows its place, category, title, body, fix and evidence, then the judge’s verdict, priority, nature, fix_effort and rationale, the score (0-100) and the action: inline for a comment on its line, summary for the summary comment, or stored for the run record only. The thresholds in .kerpeten.yml set the scores for inline and summary. A finding the judge could not judge shows its judge_error instead of the labels and gets stored; the command still exits with 0. Nothing is posted in a dry run, so the action only tells what a posted review would do. In a review of a pull request or merge request the action is the one of the comment plan, which also knows the diff, the limit of line comments and what is already written, and which can be suppressed_duplicate too.
The fix is the reviewer’s note on how to fix the finding, in one to three sentences, or what has to be checked or decided when the fix is not clear. The judge says in its rationale when the note is wrong; the note does not change the verdict or the score.
The usage is reported per role: a reviewer entry, and a judge entry only when the judge ran, which is the sum of all judge calls. When the change is empty, no model runs and the usage list is empty. --json prints { "findings": [...], "usage": [...] } with the same fields, and with --mr a merge_request object before them. A review that has a comment plan also has a comment_plan object after the findings; an empty change has no plan, so the object is left out then. A limit that ends the reviewer early and a limit that ends the judge stage are reported on stderr as separate lines, each with its reason, also with --json.