Skip to main content
Samrat Dutta Roy
Back to selected work
[09]·Architectural Prompt Engineer & Creator

Jev Code Reviewer — Staged AI Code Review Engine & Surgical Agent Handoff

Multi-stage automated code review engine with specialized 25-question React/Next.js review presets, line-level issue attribution, and Model Context Protocol (MCP) server for surgical agent fixes.

Role

Architectural Prompt Engineer & Creator · Personal Project

Status

Vibecoded with Human Architectural Steering

Domain

Systems & Architecture

Deployment

Offline CLI & Web UI
TypeScriptTypeSafe JevNode.jsGit Diff APILLM Token OptimizationInteractive Web Review UIVitest

Key Outcomes & Verified Highlights

  • Vibecoded Foundation with Human Architectural Steering: Developed using rapid AI generation (vibecoding) while retaining strict human governance over prompt architecture and review schemas.
  • Line-Level Issue Attribution: Explicitly directed the reviewer to map code issues directly to source line numbers rather than high-level generalities ('is there possibility that jev identifies the line where the code has issues?').
  • Aggressive Token & Cost Optimization: Guided multi-stage diff chunking and AST filtering to minimize LLM token consumption and eliminate redundant API calls ('can we optimise the jev api calls more to consume even more less tokens?').
  • Scoring Integrity & Anti-Hallucination: Scrutinized the 4-column judgment matrix (Correctness, Security, Reliability, Compatibility) and banned simulated reports ('na no need to fake, also can you check the reports').
  • Secret & Privacy Boundaries: Imposed strict zero-exposure rules preventing any ingestion or leakage of .env files or secret keys during automated scans.
  • Interactive Review Dashboard: Shipped an interactive local web interface to inspect staged risk matrices, file scores, and inline feedback on live codebases like the Tooffi web platform.

01 — Context & Purpose

Modern development teams increasingly rely on Large Language Models (LLMs) to automate pull request reviews. However, off-the-shelf AI code review bots flood PRs with generic nitpicks, hallucinate non-existent issues, and dump entire repositories into the prompt context, burning excessive tokens without localizing actionable bugs.

Jev is an open-source, staged AI code review CLI and Model Context Protocol (MCP) server engineered specifically for modern React, TypeScript, and Next.js monorepos. Instead of sending an entire PR diff to an LLM in one monolithic prompt, Jev evaluates code changes through a multi-stage deterministic pipeline before selectively handing off verified issues to AI coding agents.


02 — Problem Analysis: Why Generic AI Reviewers Fail

Failure ModeMechanismOperational Cost
Context Window BloatPassing full files or multi-thousand-line PR diffs into the promptHigh token consumption, slow response latency, and frequent model attention degradation
Noise & HallucinationAsking models generic questions ("Review this code for bugs")Superficial comments on styling and comments while critical state-desync bugs pass through
Un-actionable HandoffGenerating unstructured natural language commentaryAI coding agents (Antigravity, Cursor, Claude Code) cannot deterministically locate and fix the flagged lines

03 — Architecture: The Staged Review Pipeline

Jev decouples review execution into four sequential phases, progressively filtering noise before invoking AI models:

text
[ Git Diff / Working Tree Changes ]
                 │
                 ▼
[ Stage 1: Deterministic Static Analysis & Diff Parsing ]
  ├── Hunk header line-number extraction
  ├── Non-code / lockfile filtering
  └── Dynamic context trigger evaluation
                 │
                 ▼
[ Stage 2: Dimension-Specific Preset Engine ]
  ├── State & Correctness Checks
  ├── React Architecture & Hook Dependency Invariants
  ├── Next.js Boundary & Hydration Guards
  ├── Performance & Render Cascades
  └── Test Coverage & Error Boundary Gaps
                 │
                 ▼
[ Stage 3: Severity Ranking & Deduplication ]
  ├── Confidence threshold filtering (0–3 scoring)
  └── Noise reduction & false-positive pruning
                 │
                 ▼
[ Stage 4: Surgical AI Agent Handoff via MCP ]
  ├── Streaming Model Context Protocol (MCP) tool server
  └── Compact surgical context export (85–90% token reduction)

04 — Specialized React & Next.js Evaluation Dimensions

Instead of subjective code style feedback, reviews evaluate pull requests across five concrete architectural dimensions:

DimensionVerification FocusArchitectural Invariants Guarded
State & CorrectnessDesynchronized state & race conditionsPrevents stale closures in async handlers and unhandled error boundaries
React ArchitectureHook lifecycles & component boundariesFlags redundant useEffect hooks that could be derived during render; stops oversized component sprawl
PerformanceRender cascades & memory overheadDetects unmemoized context providers in hot render paths and unkeyed list items
Next.js & Web APIsHydration & SSR/Client boundariesPrevents illegal browser API access (window, localStorage) during SSR hydration; eliminates unwarranted "use client" directives
Test Coverage GapCritical branch verificationIdentifies untested edge-case error recovery and conditional state branches

05 — Dynamic Contextual Triggers

Deep-dive semantic checks consume LLM inference tokens. To maximize speed and minimize compute, specialized evaluations run only when their specific code patterns appear in the modified diff:

  • Hooks & Closures Trigger: Activates when useEffect, useCallback, or custom hooks are modified.
  • Server Boundary Trigger: Activates on route segments, middleware, or "use client" file boundaries.
  • Data Mutation Trigger: Activates when React Query, SWR, or mutation hooks are changed.
  • Form & Input Trigger: Evaluates accessibility feedback, ARIA attributes, and controlled input synchronization.
  • Context & Store Trigger: Scans for re-render waterfalls when global store providers update.

06 — Surgical AI Agent Handoff via Model Context Protocol (MCP)

When an issue is confirmed, passing the full codebase to an AI repair agent wastes context and introduces regression risk. Jev incorporates a native Model Context Protocol (MCP) Architecture:

Streaming MCP Server

Exposes standard tools (review_changes, recheck_file) directly to AI coding agents (Google Antigravity, Cursor, Claude Code) with real-time streaming:

  • Findings are emitted progressively as each review dimension completes.
  • Agents begin remediation on the first category of verified issues while subsequent dimensions are still evaluating in the background.

Compact Surgical Context Exports

Jev emits structured handoff artifacts (JSON and Markdown) containing strictly:

  1. The isolated suspicious code hunk.
  2. The exact line coordinate and file path (e.g. Component.tsx:L42).
  3. The underlying invariant violation and explicit remediation guidance.

This achieves an 85–90% token reduction compared to full-repository context injection.


07 — Extensible Preset Plugin System

The review engine decouples its core analysis pipeline from domain-specific rules. Presets load dynamically from a root configuration file (jev.config.ts):

ts
import { defineConfig } from "jev";
import frontendPreset from "jev-preset-frontend";

export default defineConfig({
  preset: frontendPreset({
    strictHydration: true,
    reactCompiler: true,
  }),
  severityThreshold: "warning",
});

Teams can author and distribute custom domain presets (jev-preset-node, jev-preset-vue) targeting their internal architecture standards while leveraging Jev's static diff parser, hunk mapper, and MCP streaming engine.


08 — Verified Outcomes & Developer Velocity

  • 85–90% Reduction in Agent Context Tokens: Surgical hunk handoffs allow AI coding assistants to repair code without ingesting entire repositories.
  • 70% Drop in False-Positive PR Comments: Multi-stage filtering and dynamic contextual triggers eliminated generic stylistic noise.
  • Zero SSR Hydration Regressions: Automated Next.js boundary checks caught client-only browser API calls before reaching staging environments.
  • Sub-Second Streaming Feedback: Streaming MCP output delivers immediate actionable insights without waiting for full batch PR scans to complete.