Regressguard

io.github.Bharath-code由 GitHub 帳號 Bharath-code 發布v0.2.4更新於 Oct 24, 2026

Deterministic API regression checks for AI agents: snapshot a baseline, catch broken contracts.

已驗證STDIO僅桌面開發者工具安全與監控

概覽

AI 產生的概覽

一個本機 MCP 伺服器,讓 AI 編碼代理對已儲存的基準執行確定性的 API 回歸檢查,並看出哪裡出了問題。

可以做什麼
執行回歸檢查,將目前的測試結果、路由狀態碼與回應結構和記錄的基準比對,回傳含嚴重等級與可能原因的結構化結果。讀取快速健康狀態,涵蓋快照時間、路由與掛鉤狀態,不執行測試。結果與命令列工具的 JSON 輸出相同,每次工具呼叫都會寫入專案 .regressguard 目錄下僅可追加的稽核日誌。
適用情境
當 AI 代理修改以 API 為基礎的應用程式、你希望它在交回變更前自行驗證時使用;也適合當作提交前或 CI 的關卡,在介面契約被破壞時阻擋提交。
執行需求
以本機程序執行,透過 regressguard mcp serve 指令啟動,因此須先安裝 regressguard 執行檔(macOS 或 Linux 安裝腳本)。專案需要包含測試指令與開發伺服器網址的設定檔,且開發伺服器應在執行中。支援的框架為 Next.js App Router、Express 與 Hono,測試執行器為 Vitest、Jest、Bun 或 npm test。
安裝前請注意
check 工具會執行專案的測試套件並向設定的路由送出 HTTP 請求,也就是執行程式碼並存取開發伺服器。基準快照預設由人掌控;在設定中啟用 allowSnapshot 會讓代理重新記錄基準,因而接受自己造成的回歸。設定中可能存放測試用的 bearer 權杖或 cookie 值。測試身分比對為盡力而為,陣列結構僅依第一個元素推斷,因此可能漏掉部分回歸。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Regressguard,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

RegressGuard

[Release] [License: MIT] [Go]

Before you commit, know what broke.

When an AI coding agent edits your app it can silently break an API contract — a removed field, a changed status code, a test that now fails — and still report success. RegressGuard records a known-good baseline and tells you (or the agent) exactly what regressed.

It is built to live inside the agent's own loop. RegressGuard ships as an MCP server, so agents like Claude Code and Cursor can verify their own work and self-correct before a human ever sees the diff — zero extra steps. The same engine also runs as a plain CLI for humans and CI.

# Agent-native (primary): the agent calls these as MCP tools in its loopcheck → status                  # see "Agent-native verification (MCP)" below                                 # the baseline stays yours: agents cannot re-record it
# Human / CI (also works): two commands, no test-writing, under 15 secondsregressguard snapshot   # record the known-good stateregressguard check      # compare after edits — see what broke

[RegressGuard demo: an AI agent breaks an API contract, regressguard check blocks the commit and names the culprit file, the agent fixes it, check goes green]

Break → detect → fix → green. Reproduce it yourself: ./demo/demo.sh.


Install

macOS / Linux (recommended)

sh
curl -fsSL https://raw.githubusercontent.com/Bharath-code/regressguard/main/install.sh | sh

Verify

sh
regressguard version   # first line must say "RegressGuard"

Upgrading from v0.1.x? The binary was renamed from rg to regressguard because rg collides with ripgrep. There is no rg shim and the old rg upgrade can't fetch v0.2.0: re-run the installer, delete the old rg, then run regressguard hook install (old hooks call rg; regressguard doctor flags them).


Quickstart (3 minutes)

1. Initialize your project

sh
cd your-projectregressguard init

RegressGuard detects your test command, framework, and dev server URL automatically.

2. Record the baseline before your AI session

Make sure your dev server is running, then:

sh
regressguard snapshot

Output:

Snapshot
OK Tests       42 passed, 0 failed       6.8sOK Routes      6 captured, 2 skippedOK Schemas     6 hashed
Saved:  .regressguard/snapshot.json
Next:  Ask your AI agent to make the code change, then run:  regressguard check

3. Run your AI agent

Let Claude Code, Cursor, or Codex make its changes.

4. Check for regressions before committing

sh
regressguard check

Clean — safe to commit:

Check
OK No regressions detected
  Tests       42 passed, 0 failed  Routes      6 unchanged  Timing      within tolerance
Safe to commit.

Regression found — commit blocked:

Check
X 2 regressions detected
  Route                                 Before    After     Change  GET /api/users                        schema    schema    schema    - role (string, removed)    + age (number, added)  POST /api/user/update                 200       500       status
Likely cause:  Auth/session behavior or routing changed during the last code edit.
Changed files since snapshot:  app/api/users/route.ts  internal/auth/session.go
Next:  regressguard check --verbose  git diff
Commit blocked.

Exit code 1 on critical — works with git hooks and CI.


Git Hook (auto-protect every commit)

sh
regressguard hook install

Now regressguard check runs automatically before every git commit. When a critical regression is detected, the commit is blocked with a compact output:

RegressGuard pre-commit
X 1 regression detected  POST /api/user/update status changed from 200 to 500
Run:  regressguard check --verbose
Commit blocked. Use --no-verify only if you accept the risk.

Bypass with git commit --no-verify only when you accept the risk.


Agent-native verification (MCP)

This is RegressGuard's primary mode. Instead of waiting for a human to run regressguard check, the AI agent calls it as a tool inside its own edit loop — so it catches and fixes regressions it just introduced, before handing the change back to you.

Start the server (stdio transport):

sh
regressguard mcp serve

Register with Claude Code:

sh
claude mcp add regressguard -- regressguard mcp serve

Register with Cursor (.cursor/mcp.json):

json
{  "mcpServers": {    "regressguard": { "command": "regressguard", "args": ["mcp", "serve"] }  }}

The agent then has two tools:

ToolPurpose
checkCompare current state against the snapshot; returns structured findings with severity
statusSub-second health check (snapshot age, route/config/hook status) — no tests run

The baseline is human-owned. Agents get no snapshot tool by default. If they could re-record the baseline, an agent could accept its own regression (check fails → snapshot → check passes). You record the baseline with regressguard snapshot. To let agents re-baseline anyway, set this in .regressguard/config.json and restart the MCP server:

json
{ "mcp": { "allowSnapshot": true } }

Tool responses are the same machine-readable payload as regressguard check --json — see docs/json-contract.md. Every tool call is recorded to an append-only audit log under .regressguard/ (tool, status, duration, timestamp).

A typical loop: the agent edits code → calls check → reads the structured findings → fixes the regression → calls check again → only then reports done.


Commands

CommandPurpose
regressguard initConfigure RegressGuard for this project
regressguard quickstartAuto-configure and snapshot in one command
regressguard snapshotRecord the current passing state
regressguard checkCompare current state against the snapshot
regressguard statusSub-second health check (snapshot age, routes, hook) — no tests run
regressguard explain <route>Show before/after diff for a specific route
regressguard watchWatch files and auto-run check on changes
regressguard mcp serveRun the MCP server so AI agents can self-verify (see above)
regressguard hook installInstall the pre-commit git hook
regressguard hook uninstallRemove the git hook
regressguard config get <key>Read a config value
regressguard config set <key> <value>Write a config value
regressguard doctorDiagnose setup issues
regressguard upgradeUpdate regressguard to the latest version
regressguard completion <shell>Generate shell autocompletions (bash, zsh, fish)
regressguard versionPrint version and build metadata

Run regressguard <command> --help for flags, examples, and exit codes.


Configuration

Config lives in .regressguard/config.json (human-readable, git-ignoreable).

json
{  "version": 1,  "testCommand": "npm test",  "serverUrl": "http://localhost:3000",  "auth": {    "mode": "bearer",    "testToken": "your-test-token",    "headerName": "Authorization",    "prefix": "Bearer"  },  "ignoreFields": ["requestId", "traceId"],  "routes": [    { "method": "GET", "path": "/api/health" },    { "method": "GET", "path": "/api/users" },    { "method": "GET", "path": "/api/admin", "skip": true }  ]}

Auth modes: bearer (Authorization header), cookie (Cookie header), or omit for public routes only.

ignoreFields: Fields to exclude from schema comparison — useful for volatile app-specific values like requestId or traceId.


How it works

  1. regressguard snapshot runs your test suite and hits each configured route. It records pass/fail counts, HTTP status codes, and a normalized schema hash for each response.

  2. regressguard check reruns the same tests and routes, then diffs against the snapshot:

    • CRITICAL: test suite newly failing, status code changed, response schema changed (e.g. field removed/added/changed)
    • WARNING: response time increased >200ms and >50% of baseline
    • PASS: everything within acceptable variance
  3. Schema comparison automatically normalizes JSON payloads:

    • Default Dynamic Keys: Strips 16 common dynamic keys (id, uuid, token, nonce, timestamp, createdAt, updatedAt, deletedAt, created_at, updated_at, deleted_at, sessionId, accessToken, refreshToken, expiresAt, expires_at) before hashing.
    • Pattern Detection: Automatically detects ISO-8601 date strings, UUIDs, and JWTs, replacing them with generic type representations ("date", "uuid", "token").
    • User Customization: Respects custom ignoreFields defined in config.

    This ensures the shape integrity of endpoints remains stable across runs even when database IDs and timestamps change.

  4. A route whose only change is a non-blocking WARNING (e.g. a timing regression) is reported on its own line and is not counted in the "Routes: N unchanged" summary or in summary.passed of --json output.

Known limitations

These are deliberate trade-offs in v1 — favoring zero false positives over exhaustive detection. They are on the roadmap, not accidental:

  • Test identity comparison is best-effort. regressguard check records failing test names (jest, vitest, bun, go test output) and flags a CRITICAL when a test that passed at baseline starts failing — even if the net failure count is unchanged. When names cannot be parsed from your runner's output (or the baseline predates name recording), it falls back to count comparison: a CRITICAL only when the number of failing tests increases. Pair regressguard check with your normal test runner in CI for exhaustive per-test assertions.
  • Array schemas are inferred from the first element. The schema normalizer represents a JSON array's shape using its first element. If later elements have a different shape (heterogeneous arrays), that divergence is not reflected in the schema hash and will not be flagged.

Exit codes

CodeMeaning
0Pass or warnings only — safe to commit
1Critical regression detected — commit blocked
2Usage, config, or runtime error

Scripting and CI

sh
# JSON output for scripts and agentsregressguard check --json | jq .status
# Verbose diagnostics on stderr (stdout stays clean JSON)regressguard check --json --verbose
# Disable color for CINO_COLOR=1 regressguard check

GitHub Action — runs regressguard check on every PR and comments the findings:

yaml
- uses: Bharath-code/regressguard@v0  with:    server-command: npm run dev

On pull requests the action compares against the snapshot committed on the base branch (regressguard check --base origin/main), so a PR that edits .regressguard/snapshot.json to hide a regression still fails. Require a human approval when the baseline changes with a CODEOWNERS rule:

/.regressguard/snapshot.json  @your-handle

Commit .regressguard/snapshot.json (regressguard init adds .regressguard/* + !.regressguard/snapshot.json to .gitignore); everything else in .regressguard/ stays local.

See action.yml for all inputs (version pinning, working directory, server URL).


Supported stacks (v1)

  • Frameworks: Next.js App Router, Express, Hono
  • Test runners: Vitest, Jest, Bun test, npm test
  • Package managers: npm, pnpm, yarn, bun
  • Auth: Bearer token, Cookie header, public routes

Python, FastAPI, and Django support is planned for v2.


Demo fixture

A minimal Next.js API fixture is included in fixtures/nextjs-app for demos and testing. See fixtures/README.md.


Open core

This repo — the CLI and MCP server — is free and MIT, forever. A hosted team layer (cross-repo dashboard, history retention, compliance export) is scoped in docs/paid-layer-spec.md. Anything that runs on one machine for one repo stays free; the paid layer is strictly additive.


Changelog

See CHANGELOG.md for release history.


License

MIT — see LICENSE.


From the same developer as git-scope.

來源:README.md,提交 74a3c1f

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

5
  1. v0.2.4最新Oct 3, 2026
  2. v0.2.3Oct 3, 2026
  3. v0.2.1Oct 1, 2026
  4. v0.2.0Oct 1, 2026
  5. v0.1.1Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分