Skip to main content
Glama

audit_code_snippet

Analyze source files for circular dependencies, coupling/instability, and production anti-patterns, then return a health score and prioritized findings.

Instructions

Analyze one or more source files for circular module dependencies (Tarjan SCC), coupling/instability metrics (Ca/Ce/I), and 12 production reliability/security/SOLID anti-patterns (N+1 loops, missing HTTP timeouts, unbounded caches, check-then-act races, missing idempotency keys, SQL/command injection, God classes). Returns a 0-100 health score, prioritized findings, and Mermaid dependency graph.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "files": "<files>"
    },
    "name": "audit_code_snippet"
  }
}

Input Schema

NameRequiredDescriptionDefault
filesYesList of files with relative paths and source text.
maxFileLinesNoOptional LOC threshold for God File detection (default 500).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does disclose substantive behavior: the specific detectors run, the returned artifacts (0-100 health score, prioritized findings, Mermaid graph), and the default 500-line God File threshold. It omits operational limits that matter for a tool ingesting full file contents — max file count/size, timeout, language support, and whether any analysis executes code.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the core action and scope, then the return contract. The long parenthetical anti-pattern list is dense but earns its place by telling the agent concretely what will be flagged, rather than gesturing at 'best practices'.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, and the description compensates by naming the return artifacts precisely (health score, prioritized findings, Mermaid graph). With only two well-documented parameters and no annotations to cover, the remaining need is behavioral, which the detector list largely satisfies.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so both parameters are already documented in the schema, including the 500 default for maxFileLines. The description adds only the framing that the threshold drives 'God File detection', which is close to restating the schema rather than adding new semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description gives a specific verb ('Analyze') and resource ('one or more source files') and enumerates the exact analyses performed (Tarjan SCC, Ca/Ce/I metrics, 12 named anti-patterns). It does not, however, distinguish itself from the sibling 'audit_codebase_architecture', which an agent could plausibly confuse with this file-level audit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is only implied through scope wording ('one or more source files' with path+content input), suggesting this is for targeted snippet/file analysis rather than whole-repo auditing. There is no explicit when-to-use, when-not-to-use, or routing to the sibling architecture tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.