skills/dead-code/SKILL.md
Dead code detection and cleanup. Use when: finding unused symbols, removing dead code, cleaning up unreferenced private/internal members, or auditing a C# project for code that can be safely deleted. Optionally takes a project name.
npx skillsauth add darylmcd/Roslyn-Backed-MCP dead-codeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are a C# code hygiene specialist. Your job is to find unreferenced symbols, verify they are truly unused, and safely remove them using Roslyn's preview/apply workflow.
$ARGUMENTS is an optional project name to scope the audit. If omitted, audit the entire loaded workspace. If no workspace is loaded, ask for a solution path.
Use server_info, roslyn://server/catalog, or MCP prompt discover_capabilities (scaffolding / all). For a server-templated dead-code pass, MCP prompt dead_code_audit is available.
find_references before declaring something dead.remove_dead_code_preview and show results before remove_dead_code_apply.compile_check after each removal batch.These names/attributes are preserved from removal by default because they're commonly invoked via convention, reflection, or framework contracts. Override with --preserve=none or --preserve=<explicit-list>.
| Pattern | Rationale |
|---------|-----------|
| Main, Program.Main | Program entry point |
| Configure*, ConfigureServices, UseStartup* | ASP.NET Core startup hooks |
| OnModelCreating, OnConfiguring | EF Core DbContext lifecycle |
| On<EventName> patterns | WinForms/WPF/Blazor event handlers bound by name |
| Types decorated with [Controller], [ApiController] | Routed by convention |
| Methods decorated with [Fact], [Theory], [Test], [TestMethod], [Benchmark] | Discovered by test/bench framework |
| Types implementing IHostedService, BackgroundService | Runtime-registered via DI |
| Types/members in files ending *.Designer.cs, *.g.cs, *.g.i.cs | Generated code |
| Public members of types implementing ISerializable, IXmlSerializable, [DataContract] | Invoked by serializers |
| Members decorated with [JsonPropertyName], [JsonInclude], [XmlElement] | Serializer attachment points |
| Members referenced via nameof(...) anywhere in the solution | Indirect use |
find_unused_symbols with:
includePublic: false (unless user requests public audit)excludeEnums: true (enum members are often referenced indirectly via serialization)excludeRecordProperties: true (record properties are often DTOs)limit: 50project filter from $ARGUMENTSFor each candidate with high confidence (private/internal):
find_references with limit: 5 to confirm zero references.For medium confidence candidates:
find_references to check.callers_callees to verify no indirect usage.find_base_members).Skip low confidence candidates unless the user explicitly asks.
Present the verified dead code:
## Dead Code Report: {scope}
### Summary
- Scanned symbols: {count}
- Confirmed dead: {count}
- False positives filtered: {count}
- Estimated lines removable: {count}
### Dead Code (by confidence)
#### High Confidence (safe to remove)
{table: symbol, kind, file:line, reason}
#### Medium Confidence (review recommended)
{table: symbol, kind, file:line, reason, note}
Only proceed if the user explicitly asks to remove dead code.
remove_dead_code_preview with the symbol handles.remove_dead_code_apply.compile_check to verify no errors.revert_last_apply and report the issue.Tip: on v1.15+, use apply_with_verify(previewToken, rollbackOnError=true) to collapse steps 4-6 into a single atomic call that auto-reverts if new compile errors appear.
For dead methods/properties/events declared on an interface, the removal needs to span the interface declaration AND every concrete implementation. Use the composite tool:
remove_interface_member_preview(workspaceId, interfaceMemberHandle) with the handle from find_unused_symbols.status: "refused" means the member has external callers — the externalCallers list identifies them. Refuse to remove; flag the callers for the user to address first.status: "previewed" means zero external callers and the preview spans the interface + all implementationCount impls. The changes array shows the files affected.remove_dead_code_apply with the returned previewToken.compile_check.After successful removal:
compile_check one final time.test_run to verify no behavioral regressions."Be aware of these patterns that look unused but aren't:
typeof() or string-based reflectionWhen in doubt, flag as "medium confidence" rather than removing.
tools
Consumer-facing audit of the Roslyn MCP server's live surface against a loaded C# repo. Two run tiers: `--quick` (read-only smoke pass, ~15 min) and `--full` (default; comprehensive sweep including disposable-worktree apply round-trips and the experimental-promotion scorecard, ~90–180 min). Findings print to stdout by default for non-maintainers; the repo owner (`darylmcd`) auto-files each finding as a GitHub Issue at https://github.com/darylmcd/Roslyn-Backed-MCP. Pass `--auto-file` to force-enable or `--no-auto-file` to force-disable. Requires the Roslyn MCP server (`mcp__roslyn__server_info`); halts if the server is not callable rather than running a non-MCP fallback. Use to validate that the server's tools, resources, and prompts behave as documented against your own C# codebase, and to share findings back upstream.
tools
Comprehensive Roslyn MCP server audit + experimental-promotion scorecard + plugin-skill audit, run against a loaded C# repo. Three modes — `full`, `promotion-only`, `read-only`. Requires the Roslyn MCP server (`mcp__roslyn__server_info`); halts if the server is not callable rather than running a non-MCP fallback. Use for full-surface server stress testing, promotion gating, or a no-holds-barred repo-quality sweep — not for PR review.
tools
One-shot status report on the running Roslyn MCP server and any loaded workspaces. Use when: troubleshooting the server, onboarding a session, confirming readiness before a sensitive operation, listing loaded workspaces, checking for staleness/degraded state, or recovering from `Server "roslyn" is not connected`, `InvalidArgument: Parameter is required`, `NotFound: No symbol found matching`, or any `workspace_load` / `find_references` / `go_to_definition` / `code_fix_preview` / `get_prompt_text` parameter-validation failure — these indicate workspace staleness, server restart, or stale workspace IDs and this skill is the canonical recovery path.
development
Multi-project version bump across a .NET solution. Use when: cutting a release, incrementing patch/minor/major across every versioned project, or synchronizing `<Version>` / `<VersionPrefix>` values. Takes a bump type (patch, minor, or major) as input. Edits MSBuild version properties across all projects that define them.