github-pr-workflow — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited github-pr-workflow (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Complete guide for managing the PR lifecycle. Each section shows the gh way first, then the git + curl fallback for machines without gh.
When git pull fails with "divergent branches" (local commits + remote commits both exist):
# Check what diverged
git log --oneline origin/main..HEAD # local-only commits
git log --oneline HEAD..origin/main # remote-only commits
# Stash any uncommitted changes first
git add -A && git stash
# Rebase local commits on top of remote (cleaner than merge)
git pull --rebase
# Restore stashed changes
git stash popPrefer --rebase over --no-rebase — keeps history linear. If stash pop conflicts, resolve manually.
github-auth skill)# Determine which method to use throughout this workflow
if command -v gh &>/dev/null && gh auth status &>/dev/null; then
AUTH="gh"
else
AUTH="git"
# Ensure we have a token for API calls
if [ -z "$GITHUB_TOKEN" ]; then
if [ -f ~/.hermes/.env ] && grep -q "^GITHUB_TOKEN=" ~/.hermes/.env; then
GITHUB_TOKEN=$(grep "^GITHUB_TOKEN=" ~/.hermes/.env | head -1 | cut -d= -f2 | tr -d '\n\r')
elif grep -q "github.com" ~/.git-credentials 2>/dev/null; then
GITHUB_TOKEN=$(grep "github.com" ~/.git-credentials 2>/dev/null | head -1 | sed 's|https://[^:]*:\([^@]*\)@.*|\1|')
fi
fi
fi
echo "Using: $AUTH"Many curl commands need owner/repo. Extract it from the git remote:
# Works for both HTTPS and SSH remote URLs
REMOTE_URL=$(git remote get-url origin)
OWNER_REPO=$(echo "$REMOTE_URL" | sed -E 's|.*github\.com[:/]||; s|\.git$||')
OWNER=$(echo "$OWNER_REPO" | cut -d/ -f1)
REPO=$(echo "$OWNER_REPO" | cut -d/ -f2)
echo "Owner: $OWNER, Repo: $REPO"This part is pure git — identical either way:
# Make sure you're up to date
git fetch origin
git checkout main && git pull origin main
# Create and switch to a new branch
git checkout -b feat/add-user-authenticationBranch naming conventions:
feat/description — new featuresfix/description — bug fixesrefactor/description — code restructuringdocs/description — documentationci/description — CI/CD changesUse the agent's file tools (write_file, patch) to make changes, then commit:
# Stage specific files
git add src/auth.py src/models/user.py tests/test_auth.py
# Commit with a conventional commit message
git commit -m "feat: add JWT-based user authentication
- Add login/register endpoints
- Add User model with password hashing
- Add auth middleware for protected routes
- Add unit tests for auth flow"Commit message format (Conventional Commits):
type(scope): short description
Longer explanation if needed. Wrap at 72 characters.Types: feat, fix, refactor, docs, test, ci, chore, perf
If you want automatic PR creation for new feature branches, prefer a post-push hook or a wrapper command over a commit hook.
Why:
gh pr create failsSee references/auto-pr-hooks.md for the branch-to-PR check and guardrails.
git push -u origin HEADIf the repo supports auto-PR creation, this is where a post-push hook or wrapper may already have created the PR. Always check for an existing open PR before attempting a new one.
With gh:
gh pr create \
--title "feat: add JWT-based user authentication" \
--body "## Summary
- Adds login and register API endpoints
- JWT token generation and validation
## Test Plan
- [ ] Unit tests pass
Closes #42"Options: --draft, --reviewer user1,user2, --label "enhancement", --base develop
Pitfall — requesting a reviewer can fail the create: @copilot is not always a valid GitHub login; in some repos/orgs Copilot review is configured through repo settings rather than a user-reviewer. A bad reviewer login makes gh pr create --reviewer fail outright. Create the PR first, then request the reviewer as a separate step so a lookup failure can't block the PR:
gh pr edit <PR_NUMBER> --add-reviewer <reviewer-login>With git + curl:
BRANCH=$(git branch --show-current)
curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$OWNER/$REPO/pulls \
-d "{
\"title\": \"feat: add JWT-based user authentication\",
\"body\": \"## Summary\nAdds login and register API endpoints.\n\nCloses #42\",
\"head\": \"$BRANCH\",
\"base\": \"main\"
}"The response JSON includes the PR number — save it for later commands.
To create as a draft, add "draft": true to the JSON body.
If you want automatic PR creation for new feature branches, prefer a post-push hook or a wrapper command over a commit hook.
Why:
gh pr create failsSee references/auto-pr-hooks.md for the branch-to-PR check and guardrails.
With gh:
# One-shot check
gh pr checks
# Watch until all checks finish (polls every 10s)
gh pr checks --watchWith git + curl:
# Get the latest commit SHA on the current branch
SHA=$(git rev-parse HEAD)
# Query the combined status
curl -s \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/$OWNER/$REPO/commits/$SHA/status \
| python3 -c "
import sys, json
data = json.load(sys.stdin)
print(f\"Overall: {data['state']}\")
for s in data.get('statuses', []):
print(f\" {s['context']}: {s['state']} - {s.get('description', '')}\")"
# Also check GitHub Actions check runs (separate endpoint)
curl -s \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/$OWNER/$REPO/commits/$SHA/check-runs \
| python3 -c "
import sys, json
data = json.load(sys.stdin)
for cr in data.get('check_runs', []):
print(f\" {cr['name']}: {cr['status']} / {cr['conclusion'] or 'pending'}\")"# Simple polling loop — check every 30 seconds, up to 10 minutes
SHA=$(git rev-parse HEAD)
for i in $(seq 1 20); do
STATUS=$(curl -s \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/$OWNER/$REPO/commits/$SHA/status \
| python3 -c "import sys,json; print(json.load(sys.stdin)['state'])")
echo "Check $i: $STATUS"
if [ "$STATUS" = "success" ] || [ "$STATUS" = "failure" ] || [ "$STATUS" = "error" ]; then
break
fi
sleep 30
doneWhen CI fails, diagnose and fix. This loop works with either auth method.
With gh:
# List recent workflow runs on this branch
gh run list --branch $(git branch --show-current) --limit 5
# View failed logs
gh run view <RUN_ID> --log-failedWith git + curl:
BRANCH=$(git branch --show-current)
# List workflow runs on this branch
curl -s \
-H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$OWNER/$REPO/actions/runs?branch=$BRANCH&per_page=5" \
| python3 -c "
import sys, json
runs = json.load(sys.stdin)['workflow_runs']
for r in runs:
print(f\"Run {r['id']}: {r['name']} - {r['conclusion'] or r['status']}\")"
# Get failed job logs (download as zip, extract, read)
RUN_ID=<run_id>
curl -s -L \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/$OWNER/$REPO/actions/runs/$RUN_ID/logs \
-o /tmp/ci-logs.zip
cd /tmp && unzip -o ci-logs.zip -d ci-logs && cat ci-logs/*.txtAfter identifying the issue, use file tools (patch, write_file) to fix it:
git add <fixed_files>
git commit -m "fix: resolve CI failure in <check_name>"
git pushRe-check CI status using the commands from Section 4 above.
When asked to auto-fix CI, follow this loop:
read_file + patch/write_file → fix the codegit add . && git commit -m "fix: ..." && git pushAfter a PR is opened and reviewed (either by Copilot, another reviewer, or Jason), the reviewer may leave inline comments visible under the PR's "Files changed" tab. Use this workflow to find, understand, and address them.
Once a PR is open and being reviewed:
git commit -m "fix: ..." + git push)# ✅ Correct — PR is open, addressing a review comment:
git add <files>
git commit -m "[LKPR-N] fix: address reviewer comment — guard empty ids list"
git push
# ❌ Wrong — blows away comment anchors:
git commit --amend --no-edit
git push --force-with-leasegh pr view does NOT show inline comments. Use the GitHub API directly:
PR_NUMBER=8
gh api repos/$OWNER/$REPO/pulls/$PR_NUMBER/comments \
--jq '.[] | {path, body, line, commit_id}'This returns each inline comment with the file path, body text, and line number. Review these to understand what changes are needed.
Inline comments generally fall into a few categories:
log.warning() or log.exception() so silent failures become visiblefetch() with an existing helper like api() that checks res.okThe PR already exists on a feature branch. Check out or stay on that branch:
# If you're already on it:
git status
# If you need to switch to it:
gh pr checkout $PR_NUMBERMake the changes using patch or write_file, then:
git add <changed_files>
git commit -m "[TICKET-N] description: address PR review feedback"
git pushCommit message convention: use the ticket prefix (e.g. [LKPR-37]) followed by a description of what was addressed.
Pushing auto-updates the existing PR — no need to create a new one. Verify with:
gh pr view $PR_NUMBER --json state,headRefOidThe reviewer's inline comments will show as "outdated" if the lines they commented on changed. New review comments may appear.
Jason (Jessinra) reviews his own PRs and leaves inline comments. His feedback is always actionable. The pattern from experience:
gh api repos/$OWNER/$REPO/pulls/$PR_NUMBER/comments — new ones will appear on the latest commit. The previous gh pr view and gh pr review calls don't capture inline comments, so always use the REST API for this.except: return "unknown"): add log.exception(...) before the returnapi() helper for proper HTTP error checks"unknown") instead of empty catch(() => {})With gh:
# Squash merge + delete branch (cleanest for feature branches)
gh pr merge --squash --delete-branch
# Enable auto-merge (merges when all checks pass)
gh pr merge --auto --squash --delete-branchWith git + curl:
PR_NUMBER=<number>
# Merge the PR via API (squash)
curl -s -X PUT \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/$OWNER/$REPO/pulls/$PR_NUMBER/merge \
-d "{
\"merge_method\": \"squash\",
\"commit_title\": \"feat: add user authentication (#$PR_NUMBER)\"
}"
# Delete the remote branch after merge
BRANCH=$(git branch --show-current)
git push origin --delete $BRANCH
# Switch back to main locally
git checkout main && git pull origin main
git branch -d $BRANCHMerge methods: "merge" (merge commit), "squash", "rebase"
# Auto-merge requires the repo to have it enabled in settings.
# This uses the GraphQL API since REST doesn't support auto-merge.
PR_NODE_ID=$(curl -s \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/$OWNER/$REPO/pulls/$PR_NUMBER \
| python3 -c "import sys,json; print(json.load(sys.stdin)['node_id'])")
curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/graphql \
-d "{\"query\": \"mutation { enablePullRequestAutoMerge(input: {pullRequestId: \\\"$PR_NODE_ID\\\", mergeMethod: SQUASH}) { clientMutationId } }\"}"# 1. Start from clean main
git checkout main && git pull origin main
# 2. Branch
git checkout -b fix/login-redirect-bug
# 3. (Agent makes code changes with file tools)
# 4. Commit
git add src/auth/login.py tests/test_login.py
git commit -m "fix: correct redirect URL after login
Preserves the ?next= parameter instead of always redirecting to /dashboard."
# 5. Push
git push -u origin HEAD
# 6. Create PR (picks gh or curl based on what's available)
# ... (see Section 3)
# 7. Monitor CI (see Section 4)
# 8. Merge when green (see Section 7)| Action | gh | git + curl |
|---|---|---|
| List my PRs | gh pr list --author @me | curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$OWNER/$REPO/pulls?state=open" |
| View PR diff | gh pr diff | git diff main...HEAD (local) or curl -H "Accept: application/vnd.github.diff" ... |
| Add comment | gh pr comment N --body "..." | curl -X POST .../issues/N/comments -d '{"body":"..."}' |
| Request review | gh pr edit N --add-reviewer user | curl -X POST .../pulls/N/requested_reviewers -d '{"reviewers":["user"]}' |
| Close PR | gh pr close N | curl -X PATCH .../pulls/N -d '{"state":"closed"}' |
| Check out someone's PR | gh pr checkout N | git fetch origin pull/N/head:pr-N && git checkout pr-N |
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.