Skip to main content
Glama

find_dead_code

Locate unused, orphaned, or unreferenced functions and classes in a repository AST. Use it during technical debt cleanup to identify dead code ready for safe removal.

Instructions

Finds unused, orphaned, or unreferenced functions and classes across the codebase AST. Excludes all, main, dunder methods, and test functions.

Behavior:

  • Read-only: Computes symbol reference counts; does NOT delete or modify any source code files.

  • Idempotent: Consistent dead code candidate discovery for the same repository state.

  • 100% Offline: Local AST reference analysis.

Usage Guidelines:

  • When to use: Run during technical debt cleanup to locate deprecated, dead, or forgotten functions and classes ready for safe removal.

  • Sibling Routing: For copy-pasted duplicate logic blocks, use 'find_code_duplicity'. For general complexity and linting, use 'audit_codebase_quality'.

Returns: Markdown report listing candidate orphaned symbols with file paths, line numbers, and symbol types.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_rootNoRoot directory of the repository to scan for unreferenced symbols (default: current directory)..

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.1.1
    • addedInput schema / properties / project_root / description
      Added value: +"Root directory of the repository to scan for unreferenced symbols (default: current directory)."
  2. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/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 so: read-only (no source modification), idempotent, fully offline/local. It also discloses false-positive guards — exclusions for __all__, main, dunder methods, and test functions — which is exactly the behavioral context an agent needs.

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

Conciseness5/5

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

Front-loaded one-line purpose followed by clearly labeled Behavior, Usage Guidelines, and Returns sections. Every sentence adds distinct information with no redundancy.

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?

An output schema exists, yet the description still usefully previews the return shape (markdown report with file paths, line numbers, symbol types). Combined with the behavior and routing sections, nothing needed to call it correctly is missing.

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?

Single parameter with 100% schema description coverage, including the default of '.'. The description adds nothing beyond what the schema already documents, so the baseline 3 applies.

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?

States a specific verb + resource ('Finds unused, orphaned, or unreferenced functions and classes') plus the mechanism (AST). The exclusion list narrows the semantic scope and distinguishes it cleanly from audit_codebase_quality and find_code_duplicity.

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?

Explicit 'When to use' context (technical debt cleanup for safe removal) plus named sibling routing: find_code_duplicity for duplicate logic, audit_codebase_quality for complexity/linting. An agent can route without inference.

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