danny-sg/internals-viewer / .claude/skills/unused-code
unused-code
VerifiedFinds unused types and members in Internals Viewer projects by Roslyn reachability from production code, where code reached only from tests or from other unused code counts as unused, then removes them without losing test coverage. Use whenever the user asks whether a type or member is used, asks to find, review or remove unused, dead, leftover or test-only code in a project, or says unused types keep being missed, even when they name only one type.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.7 KB |
| scripts/MemberRemover/LeadingBlankLineRemover.cs | other | 1.6 KB |
| scripts/MemberRemover/MemberRemover.csproj | other | 379 B |
| scripts/MemberRemover/Program.cs | other | 981 B |
| scripts/MemberRemover/Removal.cs | other | 94 B |
| scripts/MemberRemover/RemovalResult.cs | other | 162 B |
| scripts/MemberRemover/SourceFile.cs | other | 4.7 KB |
| scripts/UnusedCodeAnalyser/Analysis.cs | other | 4.8 KB |
| scripts/UnusedCodeAnalyser/Declaration.cs | other | 972 B |
| scripts/UnusedCodeAnalyser/IsolatedOutput.cs | other | 3.6 KB |
| scripts/UnusedCodeAnalyser/Program.cs | other | 1.5 KB |
| scripts/UnusedCodeAnalyser/ReferenceGraph.Report.cs | other | 10.2 KB |
| scripts/UnusedCodeAnalyser/ReferenceGraph.cs | other | 10.3 KB |
| scripts/UnusedCodeAnalyser/SymbolReferences.cs | other | 7.2 KB |
| scripts/UnusedCodeAnalyser/UnusedCodeAnalyser.csproj | other | 487 B |
scripts/UnusedCodeAnalyser/IsolatedOutput.cs
View on GitHubusing System.Diagnostics;
using System.Text.RegularExpressions;
namespace UnusedCodeAnalyser;
internal static partial class IsolatedOutput
{
public const string OutDir = @"bin\analysis\";
public const string IntermediateOutputPath = @"obj\analysis\";
private const string FolderName = "analysis";
public static HashSet<string> Find(string solutionDirectory)
=> [.. Directory.EnumerateDirectories(solutionDirectory, FolderName, SearchOption.AllDirectories)
.Where(d => Path.GetFileName(Path.GetDirectoryName(d)) is "bin" or "obj")];
public static bool BuildAnalyzers(string solutionDirectory)
{
var analyzers = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (var project in Directory.EnumerateFiles(solutionDirectory, "*.csproj", SearchOption.AllDirectories))
{
var text = File.ReadAllText(project);
foreach (Match reference in ProjectReference().Matches(text))
{
if (!reference.Value.Contains("OutputItemType=\"Analyzer\"", StringComparison.OrdinalIgnoreCase)
|| IncludeAttribute().Match(reference.Value) is not { Success: true } include)
{
continue;
}
analyzers.Add(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(project)!, include.Groups[1].Value)));
}
}
foreach (var analyzer in analyzers)
{
Console.WriteLine($"Building {Path.GetFileNameWithoutExtension(analyzer)}");
using var process = Process.Start(new ProcessStartInfo("dotnet",
["build",
analyzer,
"-c",
"Release",
$"-p:OutDir={OutDir}",
$"-p:IntermediateOutputPath={IntermediateOutputPath}",
"-v",
"q",
"-nologo"])
{
RedirectStandardOutput = true,
RedirectStandardError = true
})!;
var output = process.StandardOutput.ReadToEnd() + process.StandardError.ReadToEnd();
process.WaitForExit();
if (process.ExitCode != 0)
{
Console.Error.WriteLine(output);
return false;
}
}
return true;
}
public static void Remove(string solutionDirectory, HashSet<string> existing)
{
foreach (var directory in Find(solutionDirectory).Where(d => !existing.Contains(d)))
{
try
{
Directory.Delete(directory, recursive: true);
}
catch (Exception exception) when (exception is IOException or UnauthorizedAccessException)
{
Console.Error.WriteLine($"Could not remove {directory}: {exception.Message}");
}
}
}
[GeneratedRegex(@"<ProjectReference\b[^>]*>", RegexOptions.IgnoreCase)]
private static partial Regex ProjectReference();
[GeneratedRegex("Include=\"([^\"]+)\"", RegexOptions.IgnoreCase)]
private static partial Regex IncludeAttribute();
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |