Skip to main content
Glama

Find Dead Code

find_dead_code
Read-onlyIdempotent

Detect unused C# types with no incoming references and private methods with no callers, skipping framework-invoked code, to identify removal candidates.

Instructions

List dead-code suspects on two axes. kinds='type': types with no incoming reference in the reverse type fan-in, the source find_usages reads. kinds='method' (the default): PRIVATE methods whose recorded caller list is empty. kinds='all': both.

The default axis skips a private method a framework may call ([RelayCommand] or other framework attributes, partial methods, markup or designer event handlers, static Main, record PrintMembers, ShouldSerialize/Reset) or whose callers were not measured (unresolved references, explicit interface implementations). A nameof in a method's attribute (CanExecute) is a call. *.Designer.cs and *.g.cs files are read for references, never judged.

Returns scope, a 'note' first when there is one, methodsScanned, deadMethods and - when the type axis ran - typesScanned and deadTypes: at most 200 items each (methods: name, declaringType, namespace; types: name, kind, accessibility, namespace). Counters, each omitted at zero: what was not judged - methodsIneligible (split into methodsIneligibleNotPrivate, methodsIneligibleFrameworkInvoked and methodsIneligibleUnanalyzedCallers), typesIneligible (split into typesIneligibleStructural, typesIneligibleTestScaffolding, typesIneligibleFrameworkActivated, typesIneligibleMarkupReferenced), typesUnexamined (types the type axis would have judged had it run) - and the candidates the test filter removed, testMethodsFiltered and testTypesFiltered.

A listed candidate is a suspect: the note names what a zero fan-in does not prove and how to confirm one. The type axis exempts what it cannot see being used: interfaces, static classes, types named *Extensions, test scaffolding, framework- or reflection-activated types and markup-referenced types. An empty answer without a note means at least one axis judged an eligible population and found nothing; for the method axis read methodsIneligible against methodsScanned.

Read-only; works on a recalled session. Test projects are excluded by default. Any other non-blank kinds value runs both axes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kindsNo'method' (default): private methods with a measured, empty caller list - see the description for what that axis does not judge; 'type': types with no incoming reference; 'all': both.method
scopeNo'solution' (default) or a namespace prefix (e.g. 'MyApp.Core') to narrow scope.solution
sessionIdYesThe session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use.
includeTestsNoInclude test-project methods/types (default false - production dead-code; a private test-helper without callers is not production dead code).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.5.46513
    • changedInput schema / properties / kinds / description
      Previous value: -"'method' (default) private methods with no caller · 'type' types with no incoming reference · 'all' both."New value: +"'method' (default): private methods with a measured, empty caller list - see the description for what that axis does not judge; 'type': types with no incoming reference; 'all': both."
    • changedInput schema / properties / sessionId / description
      Previous value: -"The session_id returned by analyze_solution."New value: +"The session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use."
  2. First observed

TDQS

A4.4/5.0
Behavior5/5

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

Annotations already carry read-only/idempotent/non-destructive, and the description goes well beyond them: it discloses the 200-item cap, that a listed candidate is only a suspect rather than proof, the exact exemptions (framework attributes, partial methods, Designer/generated files, static Main, PrintMembers, ShouldSerialize/Reset), which caller scenarios are not measured, and how to read an empty result against methodsIneligible. That is rich behavioral context rather than a restatement of the hints.

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?

Front-loads the purpose and organizes the body by axis, exemptions, then return shape, so the structure is sound. It is nonetheless dense and uses long run-on sentences (the eligibility/exemption sentence in particular), which costs some readability even though most sentences carry distinct information.

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?

There is no output schema, so the description must carry the return contract, and it does: it names every returned field (scope, note, methodsScanned, deadMethods, typesScanned, deadTypes), the per-item shape, the counters and their zero-omission behavior. Combined with the exemption rules and the semantics of an empty result, an agent has enough to invoke and interpret the tool correctly.

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 kinds, scope, sessionId and includeTests; baseline is 3. The description adds only marginal meaning beyond that — notably that an empty answer without a note implies an eligible population was judged, and that any other non-blank kinds value runs both axes — while not adding scope syntax or sessionId behavior beyond what the schema states.

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 and resource ('List dead-code suspects') and enumerates the two distinct axes it operates on (types with no incoming reference vs. private methods with empty caller lists). It also names the related sibling 'find_usages' as the source of the reverse type fan-in, letting an agent place it relative to siblings without opening the schema.

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

Usage Guidelines4/5

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

Gives clear selection guidance for the `kinds` axis, states the default (method), explains when to widen to 'all', and documents that test projects are excluded by default and what happens when other kinds values are passed. It does not, however, explicitly contrast the tool against plausible alternatives such as coverage_gaps or impact_of_change for a 'is this safe to delete' decision.

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