Pre-push review

Get a second opinion on every push without leaving the terminal: a git pre-push hook asks a review agent to look at what's about to go out and prints the findings.

note

The hook drives a running session, so keep the BeSwarm TUI open while you work. Without one, agent start fails with "no beswarm is running" and the hook below lets the push through.

The hook

Save as .git/hooks/pre-push and make it executable (chmod +x):

#!/usr/bin/env bash
# Ask a BeSwarm agent to review commits about to be pushed.
repo=$(git rev-parse --show-toplevel)
sha=$(git rev-parse --short HEAD)
name="review-$sha"
report="$repo/reports/review/$sha.md"
mkdir -p "$repo/reports/review"
 
beswarm agent start --name "$name" --agent claude --group prepush --no-focus \
  --prompt "In $repo, review the commits between origin/main and HEAD. Don't edit files. Write only actionable findings to $report. Start the file with BLOCKER if anything must be fixed before pushing, otherwise OK." \
  --wait --timeout 900 || exit 0   # no session or timeout: don't block the push
 
cat "$report" 2>/dev/null
beswarm agent close --group prepush >/dev/null 2>&1
 
if head -n1 "$report" 2>/dev/null | grep -q '^BLOCKER'; then
  echo "Review found blockers. Push with --no-verify to override."
  exit 1
fi

How it behaves

  • The prompt uses absolute paths, so it doesn't matter which directory the new tab opens in.
  • The agent name includes the commit, so it never clashes with an earlier review.
  • The report stays in reports/review/, so past reviews show in the Artifacts tab.
  • --no-focus keeps the review tab from stealing focus while you wait.

Tune it

  • Cap the wait with --timeout. A review that takes longer than you'll wait should let the push through.
  • Use a faster model for quick checks: add --model <model>.
  • Swap the prompt for a saved one with --prompt-id, so the team shares one review checklist.