Skip to content

1F47E/rival

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rival

Dispatch prompts to external AI CLIs from Claude Code. Run GPT-5.4 via Codex, Gemini 3.1 Pro via Gemini CLI, or Claude Opus 4.6 via Claude Code CLI — as isolated subagents that keep your main context clean.

Install

Homebrew (recommended)

brew install 1F47E/tap/rival
rival install

From source

cd rival && make install
rival install

Note: go install is not supported due to the repo's subdirectory layout. Use Homebrew or build from source.

rival install copies the Claude Code skills (embedded in the binary) into ~/.claude/skills/. After that, /rival-codex, /rival-gemini, /rival-claude, and /rival-megareview are available in Claude Code.

Use rival install --force to overwrite without prompting.

Prerequisites

You only need the CLIs for the commands you use. Megareview uses all available CLIs.

Usage

Claude Code Skills

/rival-codex explain the auth flow in this project
/rival-codex -re xhigh find bugs in src/main.go
/rival-codex review                        — review (auto-detects changed files via git)
/rival-codex review src/api/               — review specific scope (bypasses git detection)
/rival-codex -re xhigh review src/api/     — review with xhigh reasoning
/rival-gemini explain the auth flow
/rival-gemini -re high analyze this complex algorithm
/rival-gemini review                       — review (auto-detects changed files via git)
/rival-gemini review src/api/              — review specific scope (bypasses git detection)
/rival-claude explain the auth flow
/rival-claude -re xhigh find code quality issues in src/
/rival-claude review                       — review (auto-detects changed files via git)
/rival-claude review src/api/              — review specific scope (bypasses git detection)
/rival-megareview                          — review with ALL CLIs (auto-detects changed files)
/rival-megareview src/api/                 — review specific scope (bypasses git detection)
/rival-megareview -re xhigh src/api/       — both CLIs, max reasoning effort

Reasoning effort (-re): low, medium, high (default), xhigh

How Reviews Work

When you run a review, Codex/Gemini get full access to your project. They don't just see a diff — they run as CLI tools inside your workdir with tool use enabled, so they can:

  • Read any file in the project
  • Follow imports and trace dependencies
  • Explore the full codebase to understand context
  • Run commands to inspect project structure

Smart scope detection. Running /rival-codex review with no arguments auto-detects what to review via git:

  1. Dirty files (staged + unstaged + untracked new files) → reviews those files
  2. Last commit (if working tree is clean) → reviews files from HEAD
  3. Full project → only if not a git repo or no changes found

The scope is a focus hint, not a restriction. review src/api/ tells the reviewer to focus on src/api/, but it can (and will) read other files to understand the code in context. Explicit scope bypasses git detection entirely.

This means you can use natural language for the scope:

/rival-codex review the files changed in the last commit
/rival-codex review the authentication middleware
/rival-megareview -re xhigh the new payment flow in src/billing/

The reviewer will figure out what to look at, explore the relevant code, and give you a review with full project understanding.

Roles & Consilium (megareview)

Megareview assigns specialized roles to each reviewer:

  • Codex → Bug Hunter — finds concrete code-level defects: logic bugs, broken state transitions, race conditions, missing edge cases. Optimizes for true positives with high confidence.
  • Gemini → Architecture & Security — attacks from angles a bug hunter misses: architectural regressions, broken cross-file flows, incomplete refactors, concurrency issues, security problems, silent failure gaps.
  • Claude → Code Quality & DX — focuses on readability, naming, unnecessary complexity, error message quality, API ergonomics, maintainability traps, developer footguns, and dead code.

All reviewers emit structured JSON with file, line, severity, category, confidence (1-10), and fix suggestions.

Role prompts can be customized via ~/.rival/config.yaml:

roles:
  bug_hunter: |
    Your custom bug hunter instructions...
  code_quality: |
    Your custom code quality instructions...

A third consilium judge (runs via Codex) then:

  • Merges duplicate findings (same file + line + problem → single finding with all reporters in found_by)
  • Applies consensus bonus (+2 confidence for findings reported by 2+ reviewers)
  • Filters by confidence threshold (default: ≥6)
  • Sorts by severity (critical first), then confidence
  • Produces a unified verdict: approve, request_changes, or comment
═══ RIVAL REVIEW ═══

Summary: ...

[CRITICAL] file.go:42 — Title
  Description...
  Fix: ...
  Found by: codex, gemini

[HIGH] file.go:100 — Title
  ...

Recommendation: request_changes — ...

Reviewed by: codex (bug_hunter), gemini (arch_security), claude (code_quality)
Judge: codex (consilium)
Findings: 5 (threshold: 6)

If only one CLI is available, the consilium judge falls back to whichever CLI is present.

Direct CLI

# Run with prompt from stdin
echo 'explain the auth flow' | rival command codex --workdir .
echo 'explain the auth flow' | rival command gemini --workdir .
echo 'explain the auth flow' | rival command claude --workdir .

# Review via megareview (both CLIs in parallel)
echo 'src/api/' | rival command megareview --workdir .

TUI Dashboard

Monitor running and past sessions in a full-screen terminal UI:

rival tui

List view shows all sessions with status, CLI (◈ codex / ✦ gemini / ● claude / ◈✦● mega), model, effort, elapsed time, workdir, and prompt preview. Megareview sessions are grouped into a single row.

Detail view shows full metadata, prompt, and live-streaming log output. For megareview groups, both Codex and Gemini logs are shown side by side.

Keys

Key List View Detail View
j/k or ↑/↓ Navigate sessions
Enter Open detail view
Esc Back to list
g / G Jump to top / bottom
p Toggle full prompt
o Open log file in editor
x Kill running session
q Quit Quit

Session Management

rival sessions              # all sessions as JSON
rival version               # show version

Architecture

Claude Code main session
    │
    │ /rival-codex review src/
    ▼
Claude skill (context: fork)
    │
    │ stdin heredoc → rival command codex --workdir $(pwd)
    ▼
rival binary
    ├─ parses arguments (-re flag, review/prompt mode)
    ├─ builds review prompt with scope injection
    ├─ spawns codex/gemini via subprocess
    ├─ pipes prompt to stdin, tees stdout to log file
    ├─ writes session JSON + live log to ~/.rival/sessions/
    └─ returns output to skill → back to Claude Code

Megareview (roles + consilium):
    rival binary
    ├─ generates shared GroupID (UUID)
    ├─ assigns roles: codex=bug_hunter, gemini=arch_security, claude=code_quality
    ├─ spawns all available CLIs concurrently with role-specific prompts
    ├─ parses structured JSON output from each reviewer
    ├─ spawns codex again as consilium judge
    │   ├─ merges duplicates, applies consensus bonus
    │   ├─ filters by confidence threshold (≥6)
    │   └─ produces unified verdict with found_by attribution
    ├─ prints formatted review to stdout
    └─ TUI groups all sessions by GroupID

Second terminal:
    rival tui
      ├─ watches ~/.rival/sessions/ via fsnotify (.json + .log)
      ├─ groups sessions by GroupID for megareview display
      ├─ live-refreshes every second while sessions are running
      └─ x key sends SIGTERM to kill stuck sessions

Key design decisions

  • Full project access: reviewers run as AI CLI tools with tool use — they explore your codebase, not just diffs
  • Isolated execution: skills use context: fork — runs in subagent, zero impact on your Claude context
  • Stdin piping: prompts passed via heredoc, never shell-quoted into argv (prevents injection)
  • Env filtering: child processes get a sanitized environment (blocks proxy/preload vars from .env)
  • Fault tolerant: megareview continues if one CLI fails, reports the error inline

Docker Mode (Claude)

Run Claude via Docker with a separate Anthropic subscription. This is an internal setting — skills and commands stay the same, the executor switches transparently.

Setup

  1. Generate a token on the second account:

    claude setup-token   # → sk-ant-oat01-...
  2. Set the env var:

    export RIVAL_CLAUDE_TOKEN=sk-ant-oat01-YOUR-TOKEN-HERE
  3. Enable Docker mode in ~/.rival/config.yaml:

    claude:
      mode: docker
  4. First run auto-builds the rival-claude Docker image. Subsequent runs reuse it.

Now /rival-claude, megareview, and all claude commands run inside Docker using the second subscription. Set mode: native (or remove the key) to switch back.

Notes

  • OAuth tokens can expire — re-run claude setup-token if you get 401 errors
  • The Docker image is node:22-slim + @anthropic-ai/claude-code (auto-built, ~200MB)
  • Your workdir is mounted as /workspace inside the container
  • To rebuild the image: docker rmi rival-claude, next run rebuilds automatically

Uninstall

rm -rf ~/.claude/skills/rival-codex ~/.claude/skills/rival-gemini ~/.claude/skills/rival-claude ~/.claude/skills/rival-megareview
brew uninstall rival        # if installed via brew
# or: rm "$(go env GOPATH)/bin/rival"   # if installed from source

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages