Skip to main content
Glama

Find Dead Code

find_dead_code
Read-onlyIdempotent

Identify suspected dead code in C#/.NET solutions by listing private methods with no measured callers and types with no incoming references, with scope and test filtering.

Instructions

List dead-code suspects on two axes. kinds='type': types with no incoming reference find_usages sees. kinds='method' (the default): PRIVATE methods with an empty recorded caller list (private nested types' too, not overrides or interface implementations). kinds='all': both.

The method axis skips a 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 an attribute (CanExecute) or a reflection lookup (GetMethod) counts as a use. *.Designer.cs and *.g.cs are read for references, never judged.

Returns scope, a 'note' first if any, methodsScanned, deadMethods and - when the type axis ran - typesScanned and deadTypes: max 200 each (methods: name, declaringType, namespace; types: name, kind, accessibility, namespace, publicApi:true on a library's public type (publicApiNote); alike rows add declaringTypeFullName, signature, fullName or project). Counters, omitted at zero: methodsIneligible and typesIneligible, split by reason (methodsIneligibleNotPrivate, -FrameworkInvoked, -UnanalyzedCallers; typesIneligibleStructural, -TestScaffolding, -FrameworkActivated, -MarkupReferenced), methodsJudged/typesJudged (scanned minus ineligible; per type and project, not per row), typesUnexamined (what the type axis would have judged), testMethodsFiltered and testTypesFiltered (removed by the test filter).

A listed candidate is a suspect (the note: what zero fan-in does not prove, how to check). The type axis exempts types it cannot see in use: interfaces, static classes, *Extensions types, test scaffolding, framework- or reflection-activated and markup-referenced types. An empty answer without a note: an axis judged an eligible population and found nothing.

Read-only; works on a recalled session.

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": {
      "sessionId": "<sessionId>"
    },
    "name": "find_dead_code"
  }
}

Input 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; any other non-blank value runs both axes.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. Changed1 schema field changedv0.5.46521
    • changedInput schema / properties / kinds / description
      Previous 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."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; any other non-blank value runs both axes."
  2. 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."
  3. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Beyond the read-only and idempotent annotations, the description discloses detailed eligibility rules, framework and unresolved-reference exemptions, designer/generated file handling, row limits, counters, and the important caveat that candidates are suspects rather than confirmed dead code. This is unusually thorough behavioral context for a mutation-free analysis tool.

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 definition is front-loaded with purpose and axis behavior, then proceeds through eligibility, return shape, and caveats. It is dense and parenthetical-heavy, but the length is largely justified by the absence of an output schema and the complexity of the analysis.

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?

For a complex dead-code analyzer with no output schema, the description covers return fields, result caps, omitted counters, empty-answer interpretation, and session requirements. An agent has enough information to invoke it correctly and understand the result shape.

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

Parameters4/5

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

Schema coverage is 100%, so the schema already documents all four parameters. The description still adds useful meaning, especially by explaining how the kinds axes differ and how test filtering affects results, though it does not add much independent detail for sessionId or includeTests.

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: list dead-code suspects on two axes. It explicitly distinguishes the kinds modes and even contrasts the type axis with find_usages, so an agent can identify the tool's role 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?

The description gives clear context for the default method axis and the type/all modes, including what each axis does and does not judge. It stops short of explicitly routing the agent between this tool and sibling alternatives such as find_usages or find_unresolved_bindings, so it is clear but not fully prescriptive.

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