agent-audit
Audit agents spawned in the current/last run against the agent-selection taxonomy
Catch Resend-class bug (isError: false on HTTP 4xx/5xx) across all MCP server tool handlers
> /plugin marketplace add heymegabyte/claude-skillsHow it fires
How this command gets triggered: by you, by Claude, or both.
/audit-mcp-error-semanticsContext preview
What this command does when you run it.
Catch Resend-class bug (isError: false on HTTP 4xx/5xx) across all MCP server tool handlers
description: Catch Resend-class bug (isError: false on HTTP 4xx/5xx) across all MCP server tool handlers argument-hint: [--server=<name>] [--fix]
<!-- <SUBAGENT-STOP>: skip this skill when running inside a subagent. Meta-skills must not leak into spawned subagent contexts. --> <SUBAGENT-STOP/>
Audit every MCP server tool handler for the silent-failure anti-pattern: `fetch()` calls that return HTTP 4xx/5xx but still resolve `isError: false`, so Claude reads a garbage success instead of a typed error. Catches the Resend-class bug. [[mcp-error-semantics]] [[mcp-server-hardening]] [[verification-loop]]
**When to use** — after adding a new MCP server; after any fetch-heavy handler ships; before a load-bearing session; CI gate (wire as pre-deploy check).
**Inputs**
---
Glob in order of precedence:
~/.claude/mcp-servers/*/mcp-server/src/index.ts ~/.claude/mcp-servers/*/src/index.ts ~/.claude/mcp-servers/*/index.ts
Apply `--server=<name>` filter if provided (match the directory one level below `mcp-servers/`).
If no files found, emit:
No MCP server source trees found under ~/.claude/mcp-servers/ Nothing to audit.
Exit 0.
Also read the helper reference — do not fail if absent:
~/.claude/mcp-servers/template/utils/mcp-error-response.ts
If that file exists, capture the exported function signature (name, parameters, return type) for use in `--fix` mode rewrites.
---
For each source file, extract **tool handler functions** — the callback body passed to `server.tool(...)`, `server.addTool(...)`, or `tool(...)`.
Within each handler body, locate every `fetch(` call. For each `fetch` call, capture:
---
**Anti-pattern A — Missing ok check:** `fetch()` result bound to a variable, followed by a `return { content: [...] }` with no `res.ok` guard on any code path between them.
**Anti-pattern B — Unconditional isError: false:** Handler that always returns `{ isError: false }` (or omits `isError` which defaults false) regardless of HTTP status. Catch with regex:
return \{[^}]*content:[^}]*\}where no `isError: true` branch exists in the same function scope.
**Anti-pattern C — Swallowed status in text:** Handler that reads `await res.text()` or `await res.json()` and returns the body as content text regardless of `res.ok`. The HTTP error message becomes Claude's "success" response.
For each hit, record:
{
server: string // directory name
file: string // absolute path
line: number // line of the return statement (not the fetch call)
fetch_line: number // line of the fetch() call
pattern: 'A' | 'B' | 'C'
snippet: string // 3-line context around the return
}---
Print a table grouped by server:
Server: resend-mcp (src: ~/.claude/mcp-servers/resend-mcp/mcp-server/src/index.ts)
────────────────────────────────────────────────────────────────────────
# Pattern Line Fetch@ Violation
1 A L142 L138 return { content } with no res.ok guard
2 C L201 L197 await res.text() returned as content regardless of status
────────────────────────────────────────────────────────────────────────
2 violations
Server: stripe-mcp (src: ~/.claude/mcp-servers/stripe-mcp/src/index.ts)
────────────────────────────────────────────────────────────────────────
# Pattern Line Fetch@ Violation
1 A L89 L85 return { content } with no res.ok guard
────────────────────────────────────────────────────────────────────────
1 violation
SUMMARY
Servers audited : 8
Servers clean : 6
Total violations: 3If zero violations found, print:
All MCP server tool handlers check res.ok before returning content. No error-semantics violations found.
Exit 0 either way.
---
For each violation, print a before/after diff block (even without `--fix`):
// ~/.claude/mcp-servers/resend-mcp/mcp-server/src/index.ts L138-L145
- const res = await fetch(url, opts)
- const body = await res.json()
- return { content: [{ type: 'text', text: JSON.stringify(body) }] }
+ const res = await fetch(url, opts)
+ if (!res.ok) return mcpHttpError(res.status, await res.text())
+ const body = await res.json()
+ return { content: [{ type: 'text', text: JSON.stringify(body) }] }If `template/utils/mcp-error-response.ts` was not found, use this inline fallback in diffs:
// inline fallback — copy to a shared utils file and import
function mcpHttpError(status: number, body: string) {
return {
isError: true,
content: [{ type: 'text' as const, text: `HTTP ${status}: ${body}` }],
}
}---
Only runs when `--fix` is passed.
For each violation:
1. Show the diff from Step 5. 2. Ask: `Apply fix to <file>:<line>? [y/N]` 3. On `y`:
14-category autonomous product-building OS for 32+ AI coding tools. One-line prompts → deployed products.
Repo: heymegabyte/claude-skills
Audit agents spawned in the current/last run against the agent-selection taxonomy
Run the Agent Diversity Review gate and emit the result table
Meta-analyze the effectiveness of a /loop arc — per-iteration metrics, LOC delta trend, saturation detection, and a keep/lengthen/delete recommendation.
Audit the rules/ directory for missing foundational principles; output gap list with priority and justification
Validate ~/.claude/settings.json hooks block — event names, file existence, executability, matcher syntax; --fix repairs common issues
Healthcheck + drift detect + rotation-reminder across all MCP servers in ~/.claude/mcp-registry.json