
Rust Trait Explorer
Invoke when you need to map who implements a Rust trait or which traits a struct implements using LSP instead of manual grep spelunking.
Overview
Rust Trait Explorer is an agent skill for the Build phase that discovers Rust trait implementations and type trait bounds using LSP navigation and workspace search.
Install
npx skills add https://github.com/zhanghandong/rust-skills --skill rust-trait-explorerWhat is this skill?
- Accepts trait or struct names via /rust-trait-explorer with optional argument hint
- Uses LSP goToImplementation and goToDefinition to list trait implementors
- Combines Grep for impl blocks with documentSymbol for per-type method detail
- Supports bilingual triggers including trait 实现 and 谁实现了
- Allowed tools: LSP, Read, Glob, Grep—no shell execution required
- Four-step workflow: find definition, goToImplementation, documentSymbol per impl, generate implementation map
Adoption & trust: 694 installs on skills.sh; 1.2k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are staring at a trait bound in Rust and cannot quickly see every implementor or every trait your struct satisfies across a multi-crate repo.
Who is it for?
Solo developers in rust-analyzer-backed editors exploring unfamiliar codebases or validating trait coverage before a backend change.
Skip if: Greenfield Rust learners with no project open, or teams needing automated trait impl generation rather than navigation.
When should I use this skill?
Triggers on /trait-impl, find implementations, who implements, trait 实现, 谁实现了, 实现了哪些trait, or /rust-trait-explorer with TraitName or StructName.
What do I get? / Deliverables
You get a structured implementation map listing implementors or implemented traits with method context so you can refactor or extend polymorphic code confidently.
- Trait implementor list or per-struct trait inventory
- Implementation map with method-level symbol context
- Pointers to source files for each impl site
Recommended Skills
Journey fit
Trait exploration is a Build-phase code comprehension task while you implement or refactor Rust services and libraries. Backend is the canonical shelf because trait-heavy polymorphism shows up most in Rust service cores, handlers, and domain crates—not landing pages.
How it compares
Use as an LSP-guided exploration skill instead of raw ripgrep alone when polymorphic impl graphs sprawl across files.
Common Questions / FAQ
Who is rust-trait-explorer for?
Indie and solo Rust backend builders using LSP-capable agents who need fast answers about trait implementors and type trait sets without clicking through every file manually.
When should I use rust-trait-explorer?
During Build backend work when you ask who implements a trait, what traits a struct has, or when /trait-impl-style discovery beats blind search.
Is rust-trait-explorer safe to install?
Check the Security Audits panel on this Prism page; the skill only declares LSP, Read, Glob, and Grep—no network or shell— but review the repo before installing any skill.
SKILL.md
READMESKILL.md - Rust Trait Explorer
# 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 │ └───────┬───────┘ └─────┘ └───────┬───────┘ │ │ ┌───────▼───────┐ ┌──