Stop skipping code reviews!
Enforced code review gate for OpenCode AI agents. Auto-attaches review notes to commits via git notes, blocks pushes of unreviewed commits.
No more "I'll review it later." No more "it's just a small change." Every commit gets reviewed, every push is gated.
flowchart LR
C["✏️ Commit"] --> R["🔍 /review <sha>"]
R --> P["🤖 Plugin attaches git note"]
P --> H["🛡️ Pre-push hook checks notes"]
H -->|"✅ All reviewed"| S["🚀 Push allowed"]
H -->|"❌ Missing review"| B["🚫 Push blocked"]
- Commit — Make your changes and commit
- Review — Run
/review <sha>in OpenCode TUI, or let your agent spawn a reviewer subagent - Attach — The plugin automatically attaches the review output as a git note to the commit
- Gate — The pre-push hook checks every commit in the push range for a review note
- Push — All reviewed → push allowed. Missing reviews → push blocked
# Create the .opencode directory structure
mkdir -p .opencode/plugins .opencode/commands .opencode/agents
# Copy the plugin, command, and agent
cp plugin/review-note.ts .opencode/plugins/
cp command/review.md .opencode/commands/
cp agent/reviewer.md .opencode/agents/Append hooks/pre-push-review-enforcement.sh to your existing .husky/pre-push:
cat hooks/pre-push-review-enforcement.sh >> .husky/pre-pushOr source it from your pre-push hook:
source ./hooks/pre-push-review-enforcement.shCreate .review-baseline containing the SHA of the oldest commit that should be exempt from review enforcement. Commits at or before this SHA are skipped.
git rev-parse HEAD > .review-baselineThis marks all existing commits as exempt. Only new commits after this point will require review notes.
The plugin is auto-discovered from .opencode/plugins/. Restart OpenCode to load it.
Type /review <sha> in the OpenCode TUI. The plugin automatically attaches the review output as a git note.
Spawn a reviewer subagent via the task tool:
task(
subagent_type: "reviewer",
description: "review commit abc1234",
prompt: "<Review Subagent Prompt with {INPUT} replaced by abc1234>"
)
The plugin detects the subagent_type: "reviewer" and attaches the note automatically.
Pass a PR number with # prefix:
/review #742
The plugin resolves the PR's head commit via gh pr view and attaches the note to that commit.
A file containing a single commit SHA. Commits at or before this SHA are exempt from review enforcement. Update this when branching from a new point:
git rev-parse origin/main > .review-baselineThe reviewer subagent (agent/reviewer.md) has restricted permissions — read-only access to git and gh. Adjust the bash patterns in the frontmatter to match your workflow.
The plugin uses Reviewed-by: opencode-review-subagent as the marker in git notes. The pre-push hook checks for this exact string. Change it in both plugin/review-note.ts and hooks/pre-push-review-enforcement.sh if needed.
- OpenCode 1.17+ (plugin API v1)
- Git (for git notes and rev-parse)
- gh CLI (for PR reviews — optional, commit reviews work without it)
The plugin hooks into OpenCode's tool.execute.after event. When a task tool call completes with subagent_type: "reviewer" or command: "review", it:
- Extracts the commit SHA from the task's
descriptionfield (e.g.,"review commit abc1234") - Falls back to
git rev-parse HEADif no SHA is found (ship-cycle always commits before reviewing) - Resolves PR numbers via
gh pr viewfor PR reviews - Attaches the review output as a git note with the marker and review status
| File | Purpose |
|---|---|
plugin/review-note.ts |
OpenCode plugin that hooks tool.execute.after |
command/review.md |
/review command for manual TUI usage |
agent/reviewer.md |
Reviewer subagent with restricted permissions |
hooks/pre-push-review-enforcement.sh |
Pre-push hook block for enforcement |
MIT