r/reactjs • • 1d ago

I open-sourced a static verification & SAST engine (CLI + MCP) for React / React Native to catch subtle bugs AI coding agents introduce

I've been using AI coding agents heavily on React and Expo/React Native codebases, and I kept running into the same problem: they ship features fast, but quietly introduce subtle runtime bugs that basic linting misses—render-phase ref mutations that break React 19.2+/Compiler, stale async races, AsyncStorage leaks, and TanStack Query cache bugs.

So I built and just open-sourced Code Verifier (v0.1.0, MIT-licensed)—a static verification engine designed to be run either from the CLI or wired directly into your IDE as an MCP server so your coding agent can verify its own code and fix issues before you review it.

How it works under the hood:

  • Babel AST + 128 rules covering React/React 19, React Native/Expo, TanStack Query, async race conditions, security/injection, and mobile config (app.json, Podfile.lock drift, manifests).
  • Formal abstract interpretation over per-function CFGs for path-sensitive nullability (AI-NULL-001) and source-to-sink taint tracking (AI-TAINT-001).
  • TypeScript semantic analysis for floating Promises and Promise-valued conditions.
  • Fast & LLM-first: Runs in ~1–55ms per file and outputs structured remediation Markdown (or SARIF 2.1.0 for CI).

Example finding it caught on a real React hook (REACT-007):

Markdown

**Issue #1: [HIGH] REACT-007 - 'coordinatorRef.current' is accessed during render.**
- Location: Line 22, Col 6
- Offending Code:
  > 22 | if (coordinatorRef.current === null) {
    23 |   coordinatorRef.current = new SessionCoordinator({
- LLM Remediation Action: Hoist the value out of the ref: `useState(() => new SessionCoordinator(...))[0]` for a stable per-instance value, or move `.current` access into Effects and event handlers.

Try it in 10 seconds (no clone needed):

CLI:

Bash

npx code-verifier src/

Or add it to your MCP config (Cursor, Claude Code, etc.):

JSON

{
  "mcpServers": {
    "code-verifier": {
      "command": "npx",
      "args": ["-y", "code-verifier", "mcp"]
    }
  }
}

(By default, the MCP exposes verify_code and get_test_context*, which extracts framework info, exported contracts, and mocks so your LLM writes better unit tests.)*

GitHub: https://github.com/iniola145/Code-Verifier

It's v0.1.1—I've tested it across a couple of large internal React and Expo repos (1,800+ files), and there are 553 unit tests, but static analysis always hits weird real-world edge cases. If you run it on one of your repos and hit a false positive, I added an issue template specifically for reporting them so I can tighten the rules. Feedback and critiques are very welcome.

0 Upvotes

1 comment sorted by

0

u/Square-Campaign-2238 1d ago

It is a rally nice idea, i think you should try it out and see any sort of issues that could make it better