Phin Tech docs Red Pen in the store →

Hooks

A hook is a program of your own that Red Pen runs when something happens on a pull request. List them in ~/.config/redpen/hooks.toml, beside the settings:

[[hook]]
on = "reviewed"
run = "~/bin/redpen-worklog"

[[hook]]
on = "requested"
run = "say 'review requested'"

The file is read each time something happens, so a hook you add works without restarting Red Pen. A hook whose on isn't one of the events below never runs, and the log says so.

Events #

on When
reviewed You reviewed a pull request. Your review is on the Forge, so Red Pen notices at its next refresh, or at the next launch if it was closed.
requested Your review was asked for by name.
returned A pull request you reviewed has new commits or replies since.
marked You put a mark on a pull request.
unmarked You took a mark off a pull request: once for each, when m x takes them all off.
snoozed You snoozed a pull request.
dismissed You dismissed a pull request.

The first time Red Pen sees an Account, nothing is news: it can't tell what's new until it knows what was there.

What a hook is given #

run is a command line for your login shell ($SHELL -l -c), so ~, arguments and your PATH work as in a terminal. It runs in your home folder.

Its standard input is the event as JSON:

{
  "event": "reviewed",
  "at": "2026-11-05T15:03:00Z",
  "verdict": "approved",
  "marks": ["follow-up"],
  "pull": {
    "repo": "acme/api",
    "number": 377,
    "title": "Paginate the audit log endpoint",
    "url": "https://github.com/acme/api/pull/377",
    "author": "bo",
    "branch": "paginate-the-audit-log",
    "base": "main",
    "draft": false,
    "labels": ["api"],
    "checks": "passing",
    "opened": "2026-11-04T10:00:00Z"
  }
}

marks is every mark on the pull request after the event. verdict (approved, changes-requested or commented) comes with reviewed, mark (the one put on or taken off) with marked and unmarked, and until with snoozed.

For a hook that's a line or two of shell, the same facts are in the environment: REDPEN_EVENT, REDPEN_REPO, REDPEN_NUMBER, REDPEN_TITLE, REDPEN_URL, REDPEN_AUTHOR, REDPEN_MARKS (with a space between each), and REDPEN_VERDICT, REDPEN_MARK or REDPEN_UNTIL.

Hooks run one at a time, in the order things happened, so two appending to one file never interleave. One that runs longer than 30 seconds is stopped. What a hook prints, and whether it failed, goes to the log in ~/Library/Logs/tech.phin.redpen/.

Captures, just sample and tests run no hooks.

A worklog #

There are two ways to say you've reviewed something. The reviewed event is a review left on the Forge, noticed at the next refresh. The "reviewed" mark (m r) is your own word for it, at once, whether or not you left one there: a marked hook sees it as REDPEN_MARK=reviewed.

~/bin/redpen-worklog, made executable with chmod +x, appends a line under today's heading for either:

#!/bin/sh
log="$HOME/notes/worklog.md"
case "$REDPEN_EVENT:$REDPEN_MARK" in
    reviewed:*) said="Reviewed ($REDPEN_VERDICT)" ;;
    marked:reviewed) said="Reviewed" ;;
    *) exit 0 ;;
esac
today=$(date +%F)
grep -qx "## $today" "$log" 2>/dev/null || printf '\n## %s\n\n' "$today" >> "$log"
printf -- '- %s [%s#%s](%s) %s\n' \
    "$said" "$REDPEN_REPO" "$REDPEN_NUMBER" "$REDPEN_URL" "$REDPEN_TITLE" >> "$log"

with whichever of these you want:

[[hook]]
on = "marked"
run = "~/bin/redpen-worklog"

[[hook]]
on = "reviewed"
run = "~/bin/redpen-worklog"