$npx -y skills add adityahimaone/hermes-agent-rtk-caveman --skill github-code-reviewReview code changes by analyzing git diffs, leaving inline comments on PRs, and performing thorough pre-push review. Works with gh CLI or falls back to git + GitHub REST API via curl.
| 1 | # GitHub Code Review |
| 2 | |
| 3 | Perform code reviews on local changes before pushing, or review open PRs on GitHub. Most of this skill uses plain `git` — the `gh`/`curl` split only matters for PR-level interactions. |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | - Authenticated with GitHub (see `github-auth` skill) |
| 8 | - Inside a git repository |
| 9 | |
| 10 | ### Setup (for PR interactions) |
| 11 | |
| 12 | ```bash |
| 13 | if command -v gh &>/dev/null && gh auth status &>/dev/null; then |
| 14 | AUTH="gh" |
| 15 | else |
| 16 | AUTH="git" |
| 17 | if [ -z "$GITHUB_TOKEN" ]; then |
| 18 | if [ -f ~/.hermes/.env ] && grep -q "^GITHUB_TOKEN=" ~/.hermes/.env; then |
| 19 | GITHUB_TOKEN=$(grep "^GITHUB_TOKEN=" ~/.hermes/.env | head -1 | cut -d= -f2 | tr -d '\n\r') |
| 20 | elif grep -q "github.com" ~/.git-credentials 2>/dev/null; then |
| 21 | GITHUB_TOKEN=$(grep "github.com" ~/.git-credentials 2>/dev/null | head -1 | sed 's|https://[^:]*:\([^@]*\)@.*|\1|') |
| 22 | fi |
| 23 | fi |
| 24 | fi |
| 25 | |
| 26 | REMOTE_URL=$(git remote get-url origin) |
| 27 | OWNER_REPO=$(echo "$REMOTE_URL" | sed -E 's|.*github\.com[:/]||; s|\.git$||') |
| 28 | OWNER=$(echo "$OWNER_REPO" | cut -d/ -f1) |
| 29 | REPO=$(echo "$OWNER_REPO" | cut -d/ -f2) |
| 30 | ``` |
| 31 | |
| 32 | --- |
| 33 | |
| 34 | ## 1. Reviewing Local Changes (Pre-Push) |
| 35 | |
| 36 | This is pure `git` — works everywhere, no API needed. |
| 37 | |
| 38 | ### Get the Diff |
| 39 | |
| 40 | ```bash |
| 41 | # Staged changes (what would be committed) |
| 42 | git diff --staged |
| 43 | |
| 44 | # All changes vs main (what a PR would contain) |
| 45 | git diff main...HEAD |
| 46 | |
| 47 | # File names only |
| 48 | git diff main...HEAD --name-only |
| 49 | |
| 50 | # Stat summary (insertions/deletions per file) |
| 51 | git diff main...HEAD --stat |
| 52 | ``` |
| 53 | |
| 54 | ### Review Strategy |
| 55 | |
| 56 | 1. **Get the big picture first:** |
| 57 | |
| 58 | ```bash |
| 59 | git diff main...HEAD --stat |
| 60 | git log main..HEAD --oneline |
| 61 | ``` |
| 62 | |
| 63 | 2. **Review file by file** — use `read_file` on changed files for full context, and the diff to see what changed: |
| 64 | |
| 65 | ```bash |
| 66 | git diff main...HEAD -- src/auth/login.py |
| 67 | ``` |
| 68 | |
| 69 | 3. **Check for common issues:** |
| 70 | |
| 71 | ```bash |
| 72 | # Debug statements, TODOs, console.logs left behind |
| 73 | git diff main...HEAD | grep -n "print(\|console\.log\|TODO\|FIXME\|HACK\|XXX\|debugger" |
| 74 | |
| 75 | # Large files accidentally staged |
| 76 | git diff main...HEAD --stat | sort -t'|' -k2 -rn | head -10 |
| 77 | |
| 78 | # Secrets or credential patterns |
| 79 | git diff main...HEAD | grep -in "password\|secret\|api_key\|token.*=\|private_key" |
| 80 | |
| 81 | # Merge conflict markers |
| 82 | git diff main...HEAD | grep -n "<<<<<<\|>>>>>>\|=======" |
| 83 | ``` |
| 84 | |
| 85 | 4. **Present structured feedback** to the user. |
| 86 | |
| 87 | ### Review Output Format |
| 88 | |
| 89 | When reviewing local changes, present findings in this structure: |
| 90 | |
| 91 | ``` |
| 92 | ## Code Review Summary |
| 93 | |
| 94 | ### Critical |
| 95 | - **src/auth.py:45** — SQL injection: user input passed directly to query. |
| 96 | Suggestion: Use parameterized queries. |
| 97 | |
| 98 | ### Warnings |
| 99 | - **src/models/user.py:23** — Password stored in plaintext. Use bcrypt or argon2. |
| 100 | - **src/api/routes.py:112** — No rate limiting on login endpoint. |
| 101 | |
| 102 | ### Suggestions |
| 103 | - **src/utils/helpers.py:8** — Duplicates logic in `src/core/utils.py:34`. Consolidate. |
| 104 | - **tests/test_auth.py** — Missing edge case: expired token test. |
| 105 | |
| 106 | ### Looks Good |
| 107 | - Clean separation of concerns in the middleware layer |
| 108 | - Good test coverage for the happy path |
| 109 | ``` |
| 110 | |
| 111 | --- |
| 112 | |
| 113 | ## 2. Reviewing a Pull Request on GitHub |
| 114 | |
| 115 | ### View PR Details |
| 116 | |
| 117 | **With gh:** |
| 118 | |
| 119 | ```bash |
| 120 | gh pr view 123 |
| 121 | gh pr diff 123 |
| 122 | gh pr diff 123 --name-only |
| 123 | ``` |
| 124 | |
| 125 | **With git + curl:** |
| 126 | |
| 127 | ```bash |
| 128 | PR_NUMBER=123 |
| 129 | |
| 130 | # Get PR details |
| 131 | curl -s \ |
| 132 | -H "Authorization: token $GITHUB_TOKEN" \ |
| 133 | https://api.github.com/repos/$OWNER/$REPO/pulls/$PR_NUMBER \ |
| 134 | | python3 -c " |
| 135 | import sys, json |
| 136 | pr = json.load(sys.stdin) |
| 137 | print(f\"Title: {pr['title']}\") |
| 138 | print(f\"Author: {pr['user']['login']}\") |
| 139 | print(f\"Branch: {pr['head']['ref']} -> {pr['base']['ref']}\") |
| 140 | print(f\"State: {pr['state']}\") |
| 141 | print(f\"Body:\n{pr['body']}\")" |
| 142 | |
| 143 | # List changed files |
| 144 | curl -s \ |
| 145 | -H "Authorization: token $GITHUB_TOKEN" \ |
| 146 | https://api.github.com/repos/$OWNER/$REPO/pulls/$PR_NUMBER/files \ |
| 147 | | python3 -c " |
| 148 | import sys, json |
| 149 | for f in json.load(sys.stdin): |
| 150 | print(f\"{f['status']:10} +{f['additions']:-4} -{f['deletions']:-4} {f['filename']}\")" |
| 151 | ``` |
| 152 | |
| 153 | ### Check Out PR Locally for Full Review |
| 154 | |
| 155 | This works with plain `git` — no `gh` needed: |
| 156 | |
| 157 | ```bash |
| 158 | # Fetch the PR branch and check it out |
| 159 | git fetch origin pull/123/head:pr-123 |
| 160 | git checkout pr-123 |
| 161 | |
| 162 | # Now you can use read_file, search_files, run tests, etc. |
| 163 | |
| 164 | # View diff against the base branch |
| 165 | git diff main...pr-123 |
| 166 | ``` |
| 167 | |
| 168 | **With gh (shortcut):** |
| 169 | |
| 170 | ```bash |
| 171 | gh pr checkout 123 |
| 172 | ``` |
| 173 | |
| 174 | ### Leave Comments on a PR |
| 175 | |
| 176 | **General PR comment — with gh:** |
| 177 | |
| 178 | ```bash |
| 179 | gh pr comment 123 --body "Overall looks good, a few suggestions below." |
| 180 | ``` |
| 181 | |
| 182 | **General PR comment — with curl:** |
| 183 | |
| 184 | ```bash |
| 185 | curl -s -X POST \ |
| 186 | -H "Authorization: token $GITHUB_TOKEN" \ |
| 187 | https://api.github.com/repos/$OWNER/$REPO/issues/$PR_NUMBER/comments |