Audit Codebase Quality and Static Code Smells
audit_code_qualityAudit source code with static AST analysis to detect complexity, code smells, duplicate blocks, and invalid imports or signatures before PRs or refactoring.
Instructions
Performs AST static code smell analysis, cyclomatic complexity profiling, copy-paste duplicate detection, and 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: Root directory of the repository to audit; scans supported source files recursively.check_type: Audit scope selector: 'all' performs full comprehensive audit; 'smells' profiles cyclomatic complexity, method length (>30 lines), and argument counts (>5); 'duplicity' detects copy-pasted blocks (6+ identical lines); 'hallucinations' validates import existence and function call signatures against repository AST.file_path: Optional path to scope audit to a single source file rather than scanning the full workspace.
Behavior:
Mutability: Strictly read-only; parses syntax trees without modifying or deleting files.
Idempotency: Deterministic; returns identical diagnostic findings for the same codebase state.
Privacy & Network: 100% offline local AST parsing; zero external linter dependencies or network requests.
Performance & Resources: Audits 1,000 files in <500ms using <50MB RAM; thread-safe with zero rate limits.
Auth: Zero authentication or cloud credentials required.
Return Structure: Emits diagnostic Markdown report categorized by severity (T-001 to T-004) with exact file line numbers and remediation suggestions.
Error Handling: Skips unparseable binary files gracefully and continues auditing remaining source files.
Usage Guidelines:
When to use: Run before submitting PRs, merging branches, or refactoring code to detect complex methods, missing docstrings, duplicate code blocks, or invalid hallucinated imports.
When NOT to use: Do not use for detecting hardcoded secrets or installing git pre-commit security hooks (use 'verify_security_guard' instead); do not use for mapping whole-repository module 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.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "audit_code_quality"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | No | Optional path to a single file to audit. | |
| check_type | No | Audit scope: 'all' for complete check, 'smells' for code complexity/smells, 'duplicity' for copy-paste blocks, 'hallucinations' for invalid imports/signatures. | all |
| project_root | No | Root directory of the repository to audit (default: current directory). | . |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |