원클릭으로
rmc-trait-audit
Audit a Rust trait.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Audit a Rust trait.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Preview a Rust symbol rename — exact reference set & refactor probe.
Audit a Rust crate's public API.
Enforce Rust crate-edge rules.
Audit Rust attributes and doc-comments.
Rust fn-level call graphs.
Task-conditioned workspace subgraph — nodes, edges, hierarchy.
| name | rmc-trait-audit |
| description | Audit a Rust trait. |
| argument-hint | <trait-qualified-name> |
| allowed-tools | Read, mcp__rust-code-mcp__* |
Layer 4 sweet spot. Trait declarations and their methods are first-class
graph nodes; x.method() and Type::method() resolve back to the trait
declaration. Scope: a single trait T.
For non-trait single-symbol analysis, use rmc-symbol-forensics. For
workspace-wide dispatch tracing, use rmc-call-graph. For test-only vs
production splits, use rmc-test-vs-prod.
build_hypergraph(directory=<absolute-path>)
find_definition(symbol_name=T) → file:line
module_tree(directory=..., krate=<crate>) → walk to T, expand methods
From module_tree, the trait Item has children: methods, assoc consts,
assoc types. List them.
For each method M on T:
who_uses_summary(directory=..., target=<crate>::T::M)
Sort results by total_count desc.
who_imports(directory=..., target=<crate>::T)
Modules that import T typically either implement it or take it as a
generic bound.
For each method M:
who_calls(directory=..., target=<crate>::T::M)
who_calls returns every fn body that contains a call resolving back to
T::M. Pre-Layer-10 these queries either errored or returned only same-fn
references; post-Layer-10 they return workspace-wide call sites attributed
to the enclosing fn — including dispatch through generic bounds and dyn T
receivers. Pair with the Step 3 results to sort methods by total call-site
count and to spot the method that dominates dispatch traffic (often the
"real" core of the abstraction).
| Pattern | Verdict |
|---|---|
who_uses(T) empty across all crates outside the defining one | Safe to delete or seal |
who_uses(T::M) empty for some method M | Safe to remove M (verify trait impls aren't hardcoding it) |
| Single importer + single implementer | Trait is doing nothing — inline |
| Multiple implementers + multiple consumers | Real abstraction boundary; keep |
For each pub trait in the crate's module_tree:
who_imports(directory=..., target=<crate>::T)
If importer count is 1 and the trait isn't a Send/Debug-style
supertrait, it's a candidate for inlining. The trait has one job: hide an
impl that nothing else substitutes — usually deletable.
| Finding | Action |
|---|---|
| Trait with one impl + one consumer | Inline; delete the trait |
| Trait with one impl + multiple consumers | Probably needed for substitution; verify generic param actually flows |
Trait method with empty who_uses_summary | Remove the method (verify impls don't keep it for hardcoded reasons) |
| Trait imported by many crates, methods used by few | Probably a generic-bound trait; safe |
| Trait method has all-Test fan-in | Test-only trait method; demote to #[cfg(test)] |
One method dominates who_calls traffic | Core method; treat others as candidate-thin API |
| Signal | Means |
|---|---|
who_uses(T::M) resolves to many call sites in unrelated crates | Trait is genuine substitution boundary |
Same call site for T::M and a single concrete Type::M | Trait dispatch may be vestigial; check if generic param flows through |
who_imports(T) count >> who_calls(T::M) aggregate | T is used mostly as a generic bound, not for dispatch |
| Many associated consts/types but few methods | T is a marker/type-witness trait, not a behavior boundary |
Trait: <crate>::T
Methods: <n> (with fan-in: <m>; dead: <k>)
Implementers: <n>
Importers: <n>
Top method by dispatch: T::<M> with <n> call sites
Verdict: <delete | seal | inline | keep | thin-out>
Recommended action: <...>
Per-method table:
| Method | who_uses_summary count | who_calls count | Test % | Verdict |
|---|
impl T for Type body) is
deferred (Layer 4c). who_calls(T::M) finds dispatched call sites;
functions_with_filter(self_kind=...) audits method-shape consistency.
Enumerating impl blocks as graph entities is not yet possible.dyn T may miss some sites; resolver is
type-based.who_uses on a popular trait can return thousands of rows; no
pagination cursor today.