rust-trait-explorer
actionbook/rust-skills
Explore Rust trait implementations and polymorphic designs using LSP.
What is rust-trait-explorer?
Rust Trait Explorer helps you discover which types implement a given trait, and which traits a type implements. Use it when navigating trait hierarchies, understanding polymorphic code, or analyzing implementation coverage in Rust projects.
- Find all implementors of a trait using LSP goToImplementation
- Discover all traits implemented by a struct or type via grep pattern matching
- Display trait implementation details with source locations and method signatures
- Generate implementation maps and trait hierarchy visualizations
- Check trait implementation coverage and blanket implementations
- Support both English and Chinese trigger phrases
How to install rust-trait-explorer
npx skills add https://github.com/actionbook/rust-skills --skill rust-trait-explorer- LSP server running for the Rust project
- Rust source code accessible in the workspace
How to use rust-trait-explorer
- 1.Invoke the skill with a trait name or struct name: `/rust-trait-explorer Handler`
- 2.The skill uses LSP goToImplementation to find the trait definition
- 3.For trait queries, it retrieves all implementors and displays them in a table with locations
- 4.For struct queries, it greps for `impl * for StructName` patterns to find trait implementations
- 5.Review the generated implementation map showing trait names, locations, and method details
- 6.Check the trait hierarchy visualization if applicable to understand super-trait relationships
Use cases
- Understand polymorphic designs by finding all Handler implementations in a codebase
- Verify that a custom struct implements required traits like Display, Clone, or Serialize
- Navigate trait hierarchies to see parent-child trait relationships
- Check implementation coverage to ensure all trait methods are properly implemented
- Analyze blanket implementations to understand automatic trait derivations
- Rust developers refactoring polymorphic code
- Contributors exploring unfamiliar codebases with complex trait systems
- Code reviewers verifying trait implementation completeness
- Developers designing trait-based APIs
rust-trait-explorer FAQ
Use `/rust-trait-explorer TraitName` where TraitName is the trait you want to explore. The skill will use LSP goToImplementation to find all implementors and display them in a table with file locations and notes.
Yes, use `/rust-trait-explorer StructName`. The skill will search for `impl * for StructName` patterns and list all traits that struct implements, organized by category (standard library, external crates, project-specific).
The skill generates implementation tables with type names and locations, trait hierarchy visualizations, implementation coverage matrices, and blanket implementation analysis.
Yes, the skill distinguishes between derived traits (marked with #[derive]) and manually implemented traits, and shows both in the output.
Yes, the skill supports Chinese trigger phrases like `trait 实现`, `谁实现了`, and `实现了哪些trait` in addition to English commands.
Full instructions (SKILL.md)
Source of truth, from actionbook/rust-skills.
name: rust-trait-explorer description: "Explore Rust trait implementations using LSP. Triggers on: /trait-impl, find implementations, who implements, trait 实现, 谁实现了, 实现了哪些trait" argument-hint: "<TraitName|StructName>" allowed-tools: ["LSP", "Read", "Glob", "Grep"]
Rust Trait Explorer
Discover trait implementations and understand polymorphic designs.
Usage
/rust-trait-explorer <TraitName|StructName>
Examples:
/rust-trait-explorer Handler- Find all implementors of Handler trait/rust-trait-explorer MyStruct- Find all traits implemented by MyStruct
LSP Operations
Go to Implementation
Find all implementations of a trait.
LSP(
operation: "goToImplementation",
filePath: "src/traits.rs",
line: 10,
character: 11
)
Use when:
- Trait name is known
- Want to find all implementors
- Understanding polymorphic code
Workflow
Find Trait Implementors
User: "Who implements the Handler trait?"
│
▼
[1] Find trait definition
LSP(goToDefinition) or workspaceSymbol
│
▼
[2] Get implementations
LSP(goToImplementation)
│
▼
[3] For each impl, get details
LSP(documentSymbol) for methods
│
▼
[4] Generate implementation map
Find Traits for a Type
User: "What traits does MyStruct implement?"
│
▼
[1] Find struct definition
│
▼
[2] Search for "impl * for MyStruct"
Grep pattern matching
│
▼
[3] Get trait details for each
│
▼
[4] Generate trait list
Output Format
Trait Implementors
## Implementations of `Handler`
**Trait defined at:** src/traits.rs:15
```rust
pub trait Handler {
fn handle(&self, request: Request) -> Response;
fn name(&self) -> &str;
}
```
### Implementors (4)
| Type | Location | Notes |
|------|----------|-------|
| AuthHandler | src/handlers/auth.rs:20 | Handles authentication |
| ApiHandler | src/handlers/api.rs:15 | REST API endpoints |
| WebSocketHandler | src/handlers/ws.rs:10 | WebSocket connections |
| MockHandler | tests/mocks.rs:5 | Test mock |
### Implementation Details
#### AuthHandler
```rust
impl Handler for AuthHandler {
fn handle(&self, request: Request) -> Response {
// Authentication logic
}
fn name(&self) -> &str {
"auth"
}
}
```
#### ApiHandler
```rust
impl Handler for ApiHandler {
fn handle(&self, request: Request) -> Response {
// API routing logic
}
fn name(&self) -> &str {
"api"
}
}
```
Traits for a Type
## Traits implemented by `User`
**Struct defined at:** src/models/user.rs:10
### Standard Library Traits
| Trait | Derived/Manual | Notes |
|-------|----------------|-------|
| Debug | #[derive] | Auto-generated |
| Clone | #[derive] | Auto-generated |
| Default | manual | Custom defaults |
| Display | manual | User-friendly output |
### Serde Traits
| Trait | Location |
|-------|----------|
| Serialize | #[derive] |
| Deserialize | #[derive] |
### Project Traits
| Trait | Location | Methods |
|-------|----------|---------|
| Entity | src/db/entity.rs:30 | id(), created_at() |
| Validatable | src/validation.rs:15 | validate() |
### Implementation Hierarchy
```
User
├── derive
│ ├── Debug
│ ├── Clone
│ ├── Serialize
│ └── Deserialize
└── impl
├── Default (src/models/user.rs:50)
├── Display (src/models/user.rs:60)
├── Entity (src/models/user.rs:70)
└── Validatable (src/models/user.rs:85)
```
Trait Hierarchy Visualization
## Trait Hierarchy
┌─────────────┐
│ Error │ (std)
└──────┬──────┘
│
┌────────────┼────────────┐
│ │ │
┌───────▼───────┐ ┌──▼──┐ ┌───────▼───────┐
│ AppError │ │ ... │ │ DbError │
└───────┬───────┘ └─────┘ └───────┬───────┘
│ │
┌───────▼───────┐ ┌───────▼───────┐
│ AuthError │ │ QueryError │
└───────────────┘ └───────────────┘
Analysis Features
Coverage Check
## Trait Implementation Coverage
Trait: Handler (3 required methods)
| Implementor | handle() | name() | priority() | Complete |
|-------------|----------|--------|------------|----------|
| AuthHandler | ✅ | ✅ | ✅ | Yes |
| ApiHandler | ✅ | ✅ | ❌ default | Yes |
| MockHandler | ✅ | ✅ | ✅ | Yes |
Blanket Implementations
## Blanket Implementations
The following blanket impls may apply to your types:
| Trait | Blanket Impl | Applies To |
|-------|--------------|------------|
| From<T> | `impl<T> From<T> for T` | All types |
| Into<U> | `impl<T, U> Into<U> for T where U: From<T>` | Types with From |
| ToString | `impl<T: Display> ToString for T` | Types with Display |
Common Patterns
| User Says | Action |
|---|---|
| "Who implements X?" | goToImplementation on trait |
| "What traits does Y impl?" | Grep for impl * for Y |
| "Show trait hierarchy" | Find super-traits recursively |
| "Is X: Send + Sync?" | Check std trait impls |
Related Skills
| When | See |
|---|---|
| Navigate to impl | rust-code-navigator |
| Call relationships | rust-call-graph |
| Project structure | rust-symbol-analyzer |
| Safe refactoring | rust-refactor-helper |
Related skills
More from actionbook/rust-skills and the wider catalog.

unsafe-checker
Detects and reviews unsafe Rust code patterns, FFI calls, and memory safety issues.

coding-guidelines
Reference for Rust code style, naming conventions, and best practices from 50 core rules.

core-actionbook
Internal support skill for actionbook MCP selectors in Rust documentation research workflows.

core-agent-browser
Internal browser automation CLI for agent workflows requiring interactive page testing and form filling.

esp32-firmware-engineer
ESP32 firmware engineering for ESP-IDF projects. Write, review, and debug embedded C/C++ code involving FreeRTOS tasks/queues/timers, GPIO/I2C/SPI/UART/ADC/PWM peripherals, TWAI/CAN, Wi-Fi/BLE networking, OTA updates, Secure Boot and flash encryption, LVGL display integration, build/flash/monitor workflows, logging, crash analysis, memory/code-size optimization, low-power sleep/wakeup design, on-device USB/serial service terminals, and board bring-up. Use when an agent is asked to implement ESP-IDF firmware features, review embedded changes for correctness or race conditions, investigate boot/runtime failures or Guru Meditation panics, interpret serial logs, fix build/link/flash problems, optimize RAM/flash usage, tune deep sleep/light sleep behavior, harden firmware for production, add a service console/CLI, integrate a display with LVGL, or diagnose hardware-software integration issues on ESP32-class devices.

api-and-interface-design
Design stable, hard-to-misuse APIs and interfaces with proven principles and patterns.