---
name: "VibeGuard: Cross Review"
description: "Dual-model adversarial review — Claude generates review reports, Codex does adversarial verification, and iterates until convergence"
category: VibeGuard
tags: [vibeguard, review, cross-review, adversarial, codex]
argument-hint: "<project directory or file path>"
---

<!-- VIBEGUARD:CROSS-REVIEW:START -->
**Core Concept**
- There are blind spots in single model review, and independent verification of the second model can detect omissions
- Claude is responsible for generating structured reviews, and Codex does adversarial questioning through a **structured lens**
- Review depth adapts to the size of the change: small changes focus on correctness, while large changes cover architecture and over-design
- Iterate to convergence: up to 3 rounds of revisions to ensure review quality
- Automatically downgrade to single model review when Codex is unavailable (`/vibeguard:review`)

**Reviewer Lenses**

Three complementary perspectives, each focusing on a different failure mode:

| Lens | Focus | Core Issues |
|------|--------|----------|
| **Skeptic** | Correctness | Destructive input? Unhandled error? Race condition? Untested hypothesis? Does "works on my machine" replace strict verification? |
| **Architect** (Architect) | Structural Integrity | Does the design actually achieve its goals? Coupling vulnerability? Boundary violation? Implicit assumptions about scale/concurrency/sequence? |
| **Minimalist** (minimalist) | Necessity | What can be deleted? Are you solving a hypothetical problem? Is it the easiest way to achieve your goal? Is there premature abstraction? |

**Lens Allocation Rules** (automatically selected based on change size):

| Change row count | Assigned shots | Reason |
|----------|-----------|------|
| < 50 lines | Skeptic | The biggest risk of small changes is correctness bugs |
| 50-200 lines | Skeptic + Architect | Moderate changes need to check the structural impact |
| 200+ lines | Skeptic + Architect + Minimalist | Big changes are easy to over-design |

**Steps**

1. **Check Codex Availability**
   - Run `which codex` to check if Codex CLI is installed
   - If it is not available, output the prompt and downgrade the complete process of executing `/vibeguard:review`, and end
   - If available, continue the dual model process

2. **Get guard baseline**
   - Run `bash guards/<language>/check_*.sh <target_dir>` to get the current guard status
   - Record existing issues as a baseline (no duplication of reports)

3. **Determine the scope and lens of the review**
   - If a file path is specified: review the file
   - If a directory is specified: review recently modified files (`git diff --name-only`)
   - If no parameters: review the files in the current git staging area
   - Remember the target directory as `$TARGET_DIR`
   - Count the number of changed lines: `git diff --stat` or `wc -l`
   - Determine the active lens based on row number (see table above)

4. **Claude generates review report (Round 1)**
   - Review by priority P0-P3 (consistent with `/vibeguard:review`):
     - P0 security: refer to `vibeguard/rules/security.md`, OWASP Top 10, key leakage, input verification
     - P1 logic: boundary conditions, error handling, concurrency safety, data consistency (U-11~U-14)
     - P2 quality: duplicate code, naming conventions, exception handling, file size
     - P3 performance: hot paths, N+1 queries, memory allocation
   - Write review report to `/tmp/vibeguard-cross-review-<timestamp>.md`
   - Report format:
     ```markdown
     ## Claude Review Report (Round N)

     ### Guard the baseline
     <Summary of guard script results>

     ### Scope of review
     - Change number of rows: <N>
     - Activate lens: <Skeptic / Skeptic+Architect / Skeptic+Architect+Minimalist>

     ### Discover
     | Priority | File:line number | Question | Suggestion |
     |--------|-----------|------|------|
     | P0     | ...       | ...  | ...  |

     ### Passed items
     - <Confirm that there are no problems>
     ```

5. **Codex Lens Review**
   - Construct a dedicated prompt for each activated lens and run the Codex (read-only sandbox):
     ```bash
     codex exec --skip-git-repo-check -a read-only -C "$TARGET_DIR" \
       "You are a code reviewer conducting adversarial reviews using the [LENS_NAME] lens.

        ## Your Lens: [LENS_NAME]
        [LENS_DESCRIPTION — see lens definition table]

        ## Review report (generated by another model)
        $(cat /tmp/vibeguard-cross-review-<timestamp>.md)

        ## Your task
        1. Validate each finding in the report through your lens (marked CONFIRMED / FALSE-POSITIVE)
        2. Check for missing issues from your camera’s perspective (list MISSED items, note camera source)
        3. Evaluate whether the repair proposal is reasonable

        ## Output format
        ### [LENS_NAME] review results
        #### verify
        - [Discovery 1]: CONFIRMED / FALSE-POSITIVE — Reason
        #### Omission
        - MISSED [LENS_NAME]: Description
        #### Judgment
        VERDICT: APPROVED / REVISE — reason" 2>/dev/null
     ```
   - Codex calls for multiple lenses merged into one execution (avoiding multiple startup overhead), listing all active lenses in prompt
   - Capture Codex output

6. **Parse Codex VERDICT**
   - Extract the `VERDICT:` line
   - If `APPROVED`: skip to step 8
   - If `REVISE`: proceed to step 7
   - If it cannot be parsed (Codex output exception): Treat it as APPROVED, and mark "Codex verification exception, the result is for reference only" in the report

7. **Iterative revision (up to 3 rounds)**
   - Claude revised review report based on Codex lens feedback:
     - Remove items marked with FALSE-POSITIVE
     - Add missing items of MISSED (mark the source lens)
     -Adjustment and repair suggestions
   - Update `/tmp/vibeguard-cross-review-<timestamp>.md`
   - Call Codex verification again (same as step 5)
   - If APPROVED is not achieved after 3 rounds: Mark as "Not Converged" and output the final report

8. **Output final report**

   ```markdown
   ## Dual model confrontation review report

   ### Verification status
   - Mode: Claude + Codex versus censorship
   - Activate lens: <Lens list>
   - Result: <APPROVED / not converged>
   - Number of iteration rounds: <N>

   ### Guard the baseline
   <Summary of guard script results>

   ### Confirmed findings
   | Priority | File:line number | Issues | Suggestions | Validation | Lenses |
   |--------|-----------|------|------|------|------|
   | P0     | ...       | ...  | ...  | CONFIRMED | Skeptic |

   ### Codex Lens Supplementary Discovery
   | Lens | Priority | File:line number | Questions | Suggestions |
   |------|--------|-----------|------|------|
   | Skeptic | P1 | ... | Untreated boundary conditions | ... |
   | Architect | P2 | ... | Module Coupling | ... |
   | Minimalist | P3 | ... | Unnecessary abstraction layer | ... |

   ### False positives excluded
   | Original findings | Excluded causes | Lenses |
   |--------|----------|------|
   | ...    | FALSE-POSITIVE: ... | Skeptic |

   ### Iteration history
   | Round | Codex Judgment | Revision Content |
   |------|-----------|----------|
   | 1    | REVISE    | +2 MISSED(Skeptic), -1 FALSE-POSITIVE(Minimalist) |
   | 2    | APPROVED  | — |

   ### Passed items
   - <Aspects confirmed by both parties that there are no problems>

   ### suggestion
   - <Improvement suggestions (optional)>
   ```

9. **Clean temporary files**
   - Delete `/tmp/vibeguard-cross-review-<timestamp>.md`

10. **Logging Events**
    - Write to `~/.vibeguard/events.jsonl`:
      ```bash
      echo "{\"ts\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"hook\":\"cross-review\",\"tool\":\"command\",\"decision\":\"complete\",\"reason\":\"cross-review finished\",\"detail\":\"rounds=<N>, verdict=<APPROVED/Unconverged>, lenses=<lens list>, findings=<count>\"}" >> ~/.vibeguard/events.jsonl
      ```

**Guardrails**
- Codex must be run in read-only mode, code modification is not allowed
- It is not recommended to add unnecessary abstraction (L5) - the Minimalist lens pays special attention to this
- Adding a backward compatibility layer (L7) is not recommended
- When duplicate code is found, it is recommended to extend the existing implementation rather than create a new one (L1)
- AI generated tags are not included in review reports
- When Codex times out or is abnormal, it is downgraded to a single model result without blocking the process.
- Lens allocation is strictly based on the number of changed rows and cannot be overwritten manually (to ensure consistency)

**Reference**
- Security rules: `vibeguard/rules/security.md`
- Universal rules: `vibeguard/rules/universal.md`
- Language rules: `vibeguard/rules/<lang>.md`
- Single model review: `.claude/commands/vibeguard/review.md`
<!-- VIBEGUARD:CROSS-REVIEW:END -->
