A command-line tool for C# code analysis and refactoring using Roslyn APIs. Provides fast, accurate, token-efficient operations for working with C# codebases.
- 18 Commands across 7 categories for comprehensive code analysis
- Symbol-aware operations that understand C# semantics
- Safe refactoring with preview mode
- Multiple output formats: JSON, Text, Markdown
- Fast and accurate using Roslyn compiler APIs
git clone <repository-url>
cd csharp-skill
dotnet builddotnet run -- [command] [options]
# Or after building, use the executable directly:
./bin/Debug/net10.0/csharp-skill [command] [options]--solution, -s <path>- Path to .sln file (optional - auto-discovers if not specified)--project, -p <path>- Path to .csproj file (alternative to solution, also auto-discovers)--output, -o <format>- Output format: json, text, or markdown (default: json)--verbose, -v- Enable verbose logging
Auto-Discovery: If you don't specify -s or -p, the tool automatically searches the current directory for a .sln file (preferred) or .csproj file. Perfect for running commands from your project root!
Find where a symbol (class, method, property, etc.) is defined.
csharp-skill -s MySolution.sln find-definition UserService --type class
csharp-skill -s MySolution.sln find-definition GetById --type method --in-namespace MyApp.ServicesOptions:
--type, -t- Filter by symbol type: class, method, property, field, interface, enum--in-file, -f- Search only in specific file--in-namespace, -n- Search only in specific namespace
Find all references/usages of a symbol throughout the solution.
csharp-skill -s MySolution.sln find-references GetById --type method
csharp-skill -s MySolution.sln find-references IUserRepository --type interfaceOptions:
--type, -t- Symbol type to search for--in-namespace, -n- Symbol namespace
Get the signature and documentation of a symbol.
csharp-skill -s MySolution.sln signature GetById --type method --include-overloads
csharp-skill -s MySolution.sln signature UserService --type classOptions:
--type, -t- Type of symbol--include-overloads- Show all overloads for methods--include-docs- Include XML documentation comments (default: true)
List all members (methods, properties, fields) of a type.
csharp-skill -s MySolution.sln list-members UserService
csharp-skill -s MySolution.sln list-members User --kind method --accessibility publicOptions:
--kind, -k- Filter by member kind: method, property, field, event--accessibility, -a- Filter by accessibility: public, private, protected, internal--include-inherited- Include inherited members
Safely rename a symbol across the entire solution.
# Preview mode (show changes without applying)
csharp-skill -s MySolution.sln rename UserService UserManager --preview
# Apply rename
csharp-skill -s MySolution.sln rename UserService UserManager --type class --rename-file
# Rename method
csharp-skill -s MySolution.sln rename GetById FindById --type methodOptions:
--type, -t- Type of symbol being renamed--in-namespace, -n- Limit scope to namespace--preview- Show changes without applying them--rename-file- Also rename the file if renaming a type
Get all compilation errors, warnings, and info messages.
csharp-skill -s MySolution.sln diagnostics --severity error
csharp-skill -s MySolution.sln diagnostics --file src/UserService.cs --severity warning
csharp-skill -s MySolution.sln diagnostics --code CS0246Options:
--severity, -s- Filter by severity: error, warning, info--file, -f- Get diagnostics only for specific file--code, -c- Filter by diagnostic code (e.g., CS0246)
Quickly verify if a symbol exists and is accessible.
csharp-skill -s MySolution.sln check-symbol-exists UserDto --type class
csharp-skill -s MySolution.sln check-symbol-exists GetById --type method --in-namespace MyApp.ServicesOptions:
--type, -t- Expected symbol type--in-namespace, -n- Expected namespace
Find all implementations of an interface or abstract class.
csharp-skill -s MySolution.sln find-implementations IUserRepository
csharp-skill -s MySolution.sln find-implementations IDisposableShow inheritance hierarchy (ancestors and descendants).
csharp-skill -s MySolution.sln inheritance-tree UserService
csharp-skill -s MySolution.sln inheritance-tree BaseService --direction downOptions:
--direction, -d- Show ancestors, descendants, or both (default: both)
Find all methods that call a specific method.
csharp-skill -s MySolution.sln find-callers GetById
csharp-skill -s MySolution.sln find-callers ProcessOrderFind all methods called by a specific method.
csharp-skill -s MySolution.sln find-callees GetUser
csharp-skill -s MySolution.sln find-callees ProcessOrderAnalyze what types/namespaces a file or type depends on.
csharp-skill -s MySolution.sln dependencies src/Controllers/UserController.cs
csharp-skill -s MySolution.sln dependencies UserServiceFind potentially unused code (methods, classes, properties).
csharp-skill -s MySolution.sln unused-codeExtract an interface from a class.
csharp-skill -s MySolution.sln generate-interface UserService
csharp-skill -s MySolution.sln generate-interface UserService -o textGenerate implementation stubs for an interface.
csharp-skill -s MySolution.sln implement-interface IUserRepository
csharp-skill -s MySolution.sln implement-interface IDisposableList all types in a namespace or file.
csharp-skill -s MySolution.sln list-types --namespace MyApp.Services
csharp-skill -s MySolution.sln list-typesOptions:
--namespace- Filter by namespace
Show the namespace hierarchy of the solution.
csharp-skill -s MySolution.sln namespace-tree
csharp-skill -s MySolution.sln namespace-tree -o markdownQuick comprehensive analysis of a single file.
csharp-skill -s MySolution.sln analyze-file src/Services/UserService.cs
csharp-skill -s MySolution.sln analyze-file src/Program.cs -o markdowncsharp-skill -s MySolution.sln find-definition UserService -o json{
"symbol": "UserService",
"kind": "class",
"location": {
"file": "src/Services/UserService.cs",
"line": 15,
"column": 18
},
"namespace": "MyApp.Services",
"accessibility": "public"
}csharp-skill -s MySolution.sln find-definition UserService -o textSymbol: UserService
Kind: class
Location: File: src/Services/UserService.cs
Line: 15
Column: 18
Namespace: MyApp.Services
Accessibility: public
csharp-skill -s MySolution.sln find-definition UserService -o markdown**Symbol**: UserService
**Kind**: class
**Location**: ...# 1. Check current usage
csharp-skill -s MySolution.sln find-references GetById --type method
# 2. Preview rename
csharp-skill -s MySolution.sln rename GetById FindById --type method --preview
# 3. Execute rename
csharp-skill -s MySolution.sln rename GetById FindById --type method
# 4. Verify no errors
csharp-skill -s MySolution.sln diagnostics --severity error# 1. Find where it's defined
csharp-skill -s MySolution.sln find-definition UserService
# 2. See its members
csharp-skill -s MySolution.sln list-members UserService
# 3. Check inheritance
csharp-skill -s MySolution.sln inheritance-tree UserService
# 4. See what it depends on
csharp-skill -s MySolution.sln dependencies UserService# 1. Check for compilation errors
csharp-skill -s MySolution.sln diagnostics --severity error
# 2. Find unused code
csharp-skill -s MySolution.sln unused-code
# 3. Analyze specific file
csharp-skill -s MySolution.sln analyze-file src/Services/UserService.cs0- Success1- General error (exception, invalid arguments)2- Not found (symbol not found, file not found)
- .NET 10.0 Runtime - Required to run the tool
- Download: https://dotnet.microsoft.com/download/dotnet/10.0
- The binaries are framework-dependent and require .NET 10.0 to be installed
- Solution or project file to analyze
The tool is built on three main components:
- RoslynApiClient - Wrapper around Roslyn APIs for symbol operations
- Command Handlers - 18 command implementations using System.CommandLine
- Output Formatters - JSON/text/markdown output generation
All source code is located in src/CSharpExpertCli/.
Microsoft.CodeAnalysis.CSharp.Workspaces(v5.0.0)Microsoft.CodeAnalysis.Workspaces.MSBuild(v5.0.0)Microsoft.Build.Locator(v1.8.1)System.CommandLine(v2.0.0-beta4.22272.1)
- Uses Roslyn's
SymbolFinderfor accurate symbol lookups - Leverages
SemanticModelfor type information - Safe renaming via
RenamerAPI - Compilation diagnostics from full solution analysis
This tool implements all 18 commands specified in SPEC.md.
[Your License Here]
For issues or questions, please refer to the specification document or open an issue.