Claude-skill-registry CSharpener
C# static analysis tool for call graphs, unused code detection, impact analysis, HTML documentation generation, and Graphviz diagram export
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/csharpener-lawless-m-earwig" ~/.claude/skills/majiayu000-claude-skill-registry-csharpener-68ae2f && rm -rf "$T"
skills/data/csharpener-lawless-m-earwig/SKILL.mdCSharpener - C# Code Analysis
CSharpener is a Roslyn-based static analysis tool that analyzes C# codebases to build call graphs, identify unused code, and help with refactoring decisions.
Quick Start for Claude
ALWAYS use this exact command format when invoking CSharpener:
"Y:/CSharpDLLs/CSharpener/CSharpener.exe" <command> --solution "<path-to-solution>" --format console
Key Requirements:
- Use forward slashes for the executable path:
Y:/CSharpDLLs/CSharpener/CSharpener.exe - Use double quotes around paths
- Use backslashes for Windows paths in --solution parameter
- Don't search for the executable - use the path above directly
Common Commands:
- Full analysis with call graphanalyze --solution <path> --format console --include-call-graph
- Find unused methodsunused --solution <path> --format console
- Find who calls a methodcallers --solution <path> --method <name> --format console
- Find method dependenciesdependencies --solution <path> --method <name> --format console
- Analyze removal impactimpact --solution <path> --method <name> --format console
Executable Location
Primary:
Y:\CSharpDLLs\CSharpener\CSharpener.exe (use Y:/ with forward slashes in bash)
Fallback: If the Y: drive is not available, the source code can be built from:
- GitHub: https://github.com/lawless-m/CSharpener
- Build:
dotnet build -c Release - Output:
CSharpCallGraphAnalyzer\bin\Release\net9.0\win-x64\csharp-analyzer.exe
Available Commands
1. analyze - Full Analysis
Performs comprehensive analysis including call graph, unused methods, and statistics.
Y:\CSharpDLLs\CSharpener\CSharpener.exe analyze --solution <path> --format console
Options:
(required): Path to .sln or .csproj file--solution, -s
: Output format (json, console, dot, graphviz, html) [default: json]--format, -f
: Output file path (stdout if not specified)--output, -o
: Include full call graph in output [default: true]--include-call-graph
: Namespaces to exclude from analysis--exclude-namespace
2. unused - Find Unused Methods
Quickly scans for potentially unused methods with confidence levels.
Y:\CSharpDLLs\CSharpener\CSharpener.exe unused --solution <path> --format console
Options:
(required): Path to .sln or .csproj file--solution, -s
: Output format (json, console, dot, graphviz) [default: json]--format, -f
: Output file path--output, -o
: Namespaces to exclude--exclude-namespace
Confidence Levels:
- High: Private methods never called (safe to remove)
- Medium: Internal methods not called within assembly
- Low: Public methods (might be external API, use with caution)
3. callers - Find Who Calls a Method
Finds all methods that call a specific method.
Y:\CSharpDLLs\CSharpener\CSharpener.exe callers --solution <path> --method <method-name> --format console
Options:
(required): Path to .sln or .csproj file--solution, -s
(required): Fully qualified or partial method name to search for--method, -m
: Output format [default: json]--format, -f
Example:
Y:\CSharpDLLs\CSharpener\CSharpener.exe callers -s MySolution.sln -m "BuildCallGraphAsync" -f console
4. dependencies - Find Method Dependencies
Finds all methods that a specific method calls (its dependencies).
Y:\CSharpDLLs\CSharpener\CSharpener.exe dependencies --solution <path> --method <method-name> --format console
Options:
(required): Path to .sln or .csproj file--solution, -s
(required): Method name to analyze--method, -m
: Output format [default: json]--format, -f
5. impact - Analyze Removal Impact
Analyzes what would break if you removed a method (safety check before deletion).
Y:\CSharpDLLs\CSharpener\CSharpener.exe impact --solution <path> --method <method-name> --format console
Options:
(required): Path to .sln or .csproj file--solution, -s
(required): Method to analyze--method, -m
: Output format [default: json]--format, -f
Shows:
- Direct callers (methods that immediately call this method)
- Transitive callers (methods that indirectly depend on it)
- Entry points affected (would break Main methods or public APIs)
6. document - Generate Documentation
Generates HTML documentation with cross-referenced code, call graphs, and navigation.
Y:\CSharpDLLs\CSharpener\CSharpener.exe document --solution <path> --output docs/analysis.html
Options:
(required): Path to .sln or .csproj file--solution, -s
(required): Output HTML file path--output, -o
: Include unused methods in documentation--include-unused
: Include test projects--include-tests
Usage Examples for Claude
Example 1: Find Unused Methods
User Request: "Find unused methods in my solution"
Claude Action:
Y:\CSharpDLLs\CSharpener\CSharpener.exe unused --solution "C:\path\to\solution.sln" --format console
Interpretation:
- High confidence = Safe to delete
- Medium confidence = Review carefully
- Low confidence = Might be public API, investigate before removing
Example 2: Analyze Impact Before Deletion
User Request: "What would break if I deleted the ProcessData method?"
Claude Action:
Y:\CSharpDLLs\CSharpener\CSharpener.exe impact --solution "C:\path\to\solution.sln" --method "ProcessData" --format console
Interpretation:
- 0 direct callers = Safe to delete
- Entry points affected > 0 = Breaking change, requires API updates
- Many transitive callers = Ripple effect, consider refactoring instead
Example 3: Find Who Uses a Method
User Request: "Who calls the BuildAsync method?"
Claude Action:
Y:\CSharpDLLs\CSharpener\CSharpener.exe callers --solution "C:\path\to\solution.sln" --method "BuildAsync" --format console
Example 4: Generate Documentation
User Request: "Generate HTML documentation for my project"
Claude Action:
Y:\CSharpDLLs\CSharpener\CSharpener.exe document --solution "C:\path\to\solution.sln" --output docs/csharpener-analysis.html
Then open the generated HTML file in a browser.
Example 5: Full Analysis
User Request: "Analyze my solution and show me statistics"
Claude Action:
Y:\CSharpDLLs\CSharpener\CSharpener.exe analyze --solution "C:\path\to\solution.sln" --format console
Performance Tips
- First Run Creates Cache: Initial analysis is slow, subsequent runs are faster
- Exclude Test Projects: Use
for large solutions--exclude-namespace "*.Tests,*.Test" - Cache Location:
in solution directory (can be deleted to force refresh).csharpener-cache/ - Large Solutions: Analyze individual projects instead of full solution for faster results
Common Patterns
Refactoring Workflow
- Find unused methods:
unused --solution MySolution.sln - For each suspicious method, check impact:
impact --method MethodName - If safe (0 callers), delete the method
- Repeat until clean
Understanding Code Flow
- Start with entry points:
callers --method Main - Explore dependencies:
dependencies --method ProcessRequest - Generate visualization:
(use Graphviz to render)analyze --format dot
Code Review
- Generate documentation:
document --output review.html - Share HTML file with team
- Review unused methods list together
- Make cleanup decisions
Troubleshooting
"Solution file not found"
- Use absolute paths, not relative
- Ensure .sln or .csproj file exists
- Check for typos in path
"No methods found"
- Solution might not be building
- Try
first to ensure it compilesdotnet build - Check that it's a C# project (not F#, VB.NET, etc.)
Analysis Taking Too Long
- Exclude test projects with
--exclude-namespace - Analyze smaller projects first
- Check for large auto-generated code files
"Method not found" in callers/dependencies
- Use partial names (e.g., "BuildAsync" instead of full qualified name)
- Method name is case-insensitive
- Try shortening the method name
Output Formats
- console: Human-readable output for terminal
- json: Machine-readable for scripting/automation
- html: Interactive documentation (document command only)
- dot: Graphviz format for visualization
- graphviz: Same as dot
Integration with CI/CD
# Example GitHub Actions workflow - name: Analyze for unused code run: | Y:\CSharpDLLs\CSharpener\CSharpener.exe unused \ --solution MySolution.sln \ --format json \ --output unused-methods.json - name: Upload results uses: actions/upload-artifact@v3 with: name: code-analysis path: unused-methods.json
Notes
- CSharpener uses Roslyn for analysis (same as Visual Studio)
- Detects reflection usage and warns about false positives
- Recognizes DI patterns (AddTransient, AddScoped, etc.)
- Thread-safe and can be run in parallel on different solutions
- Cache is solution-specific and invalidates on file changes