Skip to main content
Glama

audit_code_quality

Read-onlyIdempotent

Audit source code for complexity, code smells, duplicate blocks, and hallucinated imports to improve maintainability before refactoring or PR submission.

Instructions

Performs AST static code smell analysis, cyclomatic complexity profiling, duplicate code block detection, and AI coding hallucination validation, distinguishing from 'verify_security_guard' and 'analyze_code_dependencies' by scanning code maintainability and complexity rather than checking for credential leaks or analyzing module dependencies.

Parameters:

  • project_root (str, optional, default='.'): Root directory of the repository to audit (default: current directory).

  • check_type (str, optional, default='all'): Audit scope: 'all' for complete check, 'smells' for code complexity/smells, 'duplicity' for copy-paste blocks, 'hallucinations' for invalid imports/signatures.

  • file_path (str, optional, default=''): Optional path to a single file to audit.

Behavior:

  • Read-only: Inspects source syntax trees; does not modify or delete files.

  • Idempotent: Consistent diagnostic findings for the same code state.

  • 100% Offline: Pure AST inspection without network calls.

  • Auth & Rate Limits: Zero credentials or external linters required; completes in <500ms.

  • Error Handling: Gracefully skips unparseable binary files and continues scanning source trees.

Usage Guidelines:

  • When to use: Run before submitting PRs or executing refactors to catch long methods (>30 lines), excessive arguments (>5), missing docstrings, copy-pasted blocks (6+ lines), or hallucinated imports.

  • When NOT to use: Do not use for scanning hardcoded secrets or installing git pre-commit security guards (use 'verify_security_guard' instead); do not use for analyzing module import dependencies (use 'analyze_code_dependencies' instead).

Returns: Comprehensive diagnostic report with severity ratings (T-001 to T-004), exact file line references, and remediation guidance.

Input Schema

NameRequiredDescriptionDefault
file_pathNoOptional path to a single file to audit.
check_typeNoAudit scope: 'all' for complete check, 'smells' for code complexity/smells, 'duplicity' for copy-paste blocks, 'hallucinations' for invalid imports/signatures.all
project_rootNoRoot directory of the repository to audit (default: current directory)..

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv7.3.2
  2. Removedv7.0.1
  3. Addedv7.0.0

TDQS

A4.6/5.0
Behavior5/5

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

Beyond the annotations, the description discloses that the tool is fully offline, requires no credentials or external linters, completes quickly, skips unparseable binary files gracefully, and returns severity-rated diagnostics with line references. These are useful operational details that the annotations alone do not provide.

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?

The description is well organized and front-loads the purpose, then separates parameters, behavior, usage, and returns. However, some content duplicates the input schema and annotations rather than adding new value, so it is slightly longer than necessary.

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?

Given a complex multi-mode audit tool with rich annotations, full schema descriptions, and an output schema, the description provides enough context for correct invocation. It covers scope, alternatives, safety profile, error handling, and expected diagnostics without needing to fully restate return structures.

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 the schema already documents project_root, check_type, and file_path including defaults and enum-like values. The description repeats the same parameter meanings without adding substantial semantics beyond the structured schema.

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

Purpose5/5

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

The description states a specific verb and resource: audit_code_quality performs AST static code smell analysis, complexity profiling, duplicate detection, and hallucination validation. It also explicitly distinguishes itself from sibling tools 'verify_security_guard' and 'analyze_code_dependencies' by contrasting maintainability/complexity scanning with credential-leak checks and dependency analysis.

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

Usage Guidelines5/5

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

It gives explicit when-to-use guidance, including concrete examples such as long methods, excessive arguments, missing docstrings, copy-pasted blocks, and hallucinated imports. It also gives explicit when-not-to-use guidance and names the correct alternatives for security checks and dependency analysis.

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