Skip to content

Review pull requests

A reviewer has the least time for the riskiest lines of a change. Here decide reads each changed function first, and marks the ones to read closely.

You need decide installed, an API key, and a GitHub repository where you can add a workflow.

The demo is a small shop repository with one uncommitted change, a refund fix with problems planted in it:

Terminal window
git clone --depth 1 https://github.com/deepnoodle-ai/decide
sh decide/demo/setup.sh shop && cd shop

code-risk asks whether code could cause security or data problems, and how maintainable it is. --each function asks about each function the diff touches:

~/shop
git diff | decide run code-risk --each function
Output as text
$ git diff | decide run code-risk --each function
Skipped 2 files not in Go, Python, JavaScript, TypeScript, or Java
Running code-risk on 3 functions and 1 hunk · typesafe jev-latest

billing/invoice.go#L12  Total
  risk             no            97%
  maintainability  ━━━━━━━━━━━╸  3.9 of 4  Exceptionally clear and focused

billing/refund.go:7  package billing
  risk             no            80%
  maintainability  ━━━━━━━━────  2.7 of 4  Clear responsibilities and mostly direct …

billing/refund.go#L16  Refunds.Apply
! risk             yes           88%
  maintainability  ━━━━━━━─────  2.4 of 4  Understandable with some friction

billing/refund.go#L23  Refunds.Search
! risk             yes           90%
  maintainability  ━━━━━━──────  2.0 of 4  Understandable with some friction

✓ 4 answered  ! 2 flagged  100ms
Flagged: billing/refund.go#L16, billing/refund.go#L23
See these results again with: decide runs view 20261112-170019-9855

Refunds.Apply and Refunds.Search are flagged on risk. Apply no longer checks a refund against the payment, and Search builds SQL from its input.

Add your key as a repository secret named TYPESAFE_API_KEY. Then save this as .github/workflows/decide.yml:

.github/workflows/decide.yml
name: decide
on: pull_request
permissions:
contents: read
jobs:
code-risk:
runs-on: ubuntu-latest
env:
TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # the base branch, to diff against
- name: Install decide
7 collapsed lines
run: |
base=https://github.com/deepnoodle-ai/decide/releases/latest/download
curl -fsSLO "$base/decide_linux_amd64.tar.gz"
curl -fsSLO "$base/checksums.txt"
sha256sum --check --ignore-missing checksums.txt
tar -xzf decide_linux_amd64.tar.gz decide
sudo mv decide /usr/local/bin/
- uses: actions/cache@v4
with:
path: ~/.decide/cache
key: decide-${{ github.ref }}-${{ github.sha }}
restore-keys: decide-${{ github.ref }}-
- name: Judge the changed functions
if: env.TYPESAFE_API_KEY != ''
env:
BASE: ${{ github.base_ref }}
run: |
git diff "origin/$BASE...HEAD" |
decide run code-risk --each function --format github

Each flagged function becomes a warning on the pull request. The job passes either way, so for now the results are advice.

Add --fail-on flagged to the last line, and the job fails when a function is flagged:

Terminal window
git diff "origin/$BASE...HEAD" |
decide run code-risk --each function --format github --fail-on flagged

Make the job a required check to block merges on it.

In the shop repository, run the same check and print the exit code:

~/shop
git diff | decide run code-risk --each function --fail-on flagged > /dev/null
echo $?
Output as text
$ git diff | decide run code-risk --each function --fail-on flagged > /dev/null
Skipped 2 files not in Go, Python, JavaScript, TypeScript, or Java
Running code-risk on 3 functions and 1 hunk · typesafe jev-latest

✓ 4 answered  ! 2 flagged  0s
  8 answers from cache · 0 asked
Flagged: billing/refund.go#L16, billing/refund.go#L23
See these results again with: decide runs view 20261112-165955-377c
Exiting with code 2 because 2 items were flagged (--fail-on flagged)
$ echo $?
2

decide exits with code 2, so the job fails and the merge waits.

decide is Apache 2.0. Made by Deep Noodle, after some very hard thinking.