@capybearista/opencode-adversarial-review
v1.0.0
Published
Adversarial code review plugin
Readme
opencode-adversarial-review
Why?
Provides an adversarial code review agent that challenges implementation approach and design choices, not just finding bugs. Uses a clean-context subagent so the review is unbiased by conversation history.
Philosophy: Extending OpenCode
OpenCode is designed to be highly extensible. This plugin hooks into the OpenCode lifecycle to provide additional functionality seamlessly into your workflows. This plugin is modeled after the Codex CLI's adversarial review system, focusing on "breaking confidence" rather than validating changes.
Architecture
graph TB
subgraph Host [OpenCode Host]
User([User]) -->|/adversarial-review| Command[Command Template]
end
subgraph Injection [Context Injection]
direction LR
Command -->|!git status| S[Status]
Command -->|!git log| L[Commits]
Command -->|!git diff| D[Diff Summary]
Command -->|!cat| U[Untracked]
end
subgraph Adversary [Adversarial Subagent]
direction TB
Reviewer{Adversarial Reviewer}
S & L & D & U --> Reviewer
Reviewer -->|Self-Collect| Tools[Explorer Tools]
Tools -->|Source Code| Reviewer
end
Reviewer -->|Structured JSON| User
classDef host fill:#bbf,stroke:#333,stroke-width:2px;
classDef collection fill:#dfd,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;
classDef adversary fill:#f9f,stroke:#333,stroke-width:2px;
class Host host;
class Collection collection;
class Adversary adversary;The plugin uses a stateless subagent architecture. When the command is invoked, a deterministic shell script collects git metadata (diff stat, untracked files, recent commits) and injects it into a fresh subagent session. This ensures the review is unbiased by the primary agent's conversation history.
Features
- Adversarial Persona: A specialized subagent prompted to find reasons not to ship, prioritizing auth gaps, race conditions, and data loss.
- Dynamic Context Collection: Automatically switches between full-inline diff (for 1-2 files) and high-level stat (for larger changes).
- Subagent Self-Collection: The subagent uses whitelisted git and file tools to "pull" the specific file contents it needs based on the initial diff summary.
- Structured JSON Output: Returns findings with severity, file locations, confidence scores, and concrete recommendations.
- Configurable Scope: Support for
--base <ref>,--scope branch, and--scope working-tree.
Install
Add the plugin to opencode.json or opencode.jsonc:
{
"plugin": ["@capybearista/opencode-adversarial-review"]
}You can also install it through the CLI:
opencode plugin -g @capybearista/opencode-adversarial-review # global install
opencode plugin @capybearista/opencode-adversarial-review # project-local installUsage
Run a review on your current working tree changes:
/adversarial-reviewArguments
| Argument | Values | Description |
| :--- | :--- | :--- |
| --scope | auto, working-tree, branch | The range of changes to review. Defaults to auto. |
| --base | <git-ref> | The base reference (branch or commit) to compare against when using branch scope. |
auto: Reviews using the broadest context the provided information supports.working-tree: Reviews staged and unstaged changes againstHEAD.branch: Reviews all changes on the current branch since it diverged from the upstream or main branch.focus ...: Any trailing text is treated as a focus area for the review.
Examples
Force review of only working tree changes (ignoring branch history):
/adversarial-review --scope working-treeReview all changes on the current branch (automatically finds the fork point):
/adversarial-review --scope branchReview a specific branch against its fork point from main:
/adversarial-review --base mainReview with a specific focus area:
/adversarial-review --base main focus on race conditions in the auth middlewareConfiguration
| Property | Type | Description |
| :--- | :--- | :--- |
| agent.adversarial-review.model | string | The model to use for the subagent (defaults to openai/gpt-5.4). |
| agent.adversarial-review.temperature | number | Sampling temperature (defaults to 0.1 for deterministic review). |
| command.adversarial-review.template | string | The shell-injected template used to gather git context. |
This plugin requires no manual configuration out of the box, but you can override the subagent model in your local opencode.json.
Permissions & Security
This plugin is designed with a "least privilege" security model. The adversarial subagent is strictly sandboxed to prevent accidental or malicious modifications to your codebase:
- Edit: Explicitly denied (
edit: deny). - Bash: Restricted to a read-only whitelist of 12 Git patterns (e.g.,
git diff,git log,git status). All other shell commands are blocked. - Read/Grep/Glob: Allowed (read-only) to enable code inspection.
- Network: Web fetch and search are disabled to ensure the review remains focused on the files at hand.
Troubleshooting
- "No changes to review": Ensure you have staged or unstaged changes, or use
--baseto review a committed branch. - Model timeouts: Large diffs may require a model with a larger context window or more time. The subagent is whitelisted to
readfiles if the diff stat is too long to include. - Git errors: Ensure you are running within a git repository. The command relies on
gitbeing available in your PATH.
Contributing
This package lives in the opencode-plugins monorepo.
- Run
bun run build,bun run typecheck,bun run lint, andbun testbefore opening a PR. - Keep the plugin focused on the adversarial code review function.
- Prefer small, direct changes.
Please open an issue or check for existing ones before creating a pull request.
