nix-darwin/config/claude/skills/rust-analyzer-ssr/SKILL.md
Use rust-analyzer's Structural Search and Replace (SSR) to change lots of Rust code. SSR matches by AST structure and semantic meaning, understanding type resolution and path equivalence.
npx skillsauth add nubiv/my-nome rust-analyzer-ssrInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use rust-analyzer's SSR for semantic code transformations in Rust projects. SSR matches code by AST structure and semantic meaning, not text.
<search_pattern> ==>> <replacement_pattern>
Placeholders capture matched code:
$name — matches any expression/type/pattern in that position${name:constraint} — matches with constraintsfoo($a, $b) ==>> foo($b, $a)
Foo { a: $a, b: $b } ==>> Foo::new($a, $b)
Foo::method($receiver, $arg) ==>> $receiver.method($arg)
$receiver.method($arg) ==>> Foo::method($receiver, $arg)
Option<$t> ==>> Result<$t, Error>
$e.unwrap() ==>> $e.expect("TODO")
Some(${a:kind(literal)}) ==>> ...
Some(${a:not(kind(literal))}) ==>> ...
| Constraint | Matches |
| --------------- | ------------------------------------- |
| kind(literal) | Literal values: 42, "foo", true |
| not(...) | Negates inner constraint |
Write a comment containing an SSR rule, then trigger code actions:
// foo($a, $b) ==>> bar($b, $a)
Actions appear: "Apply SSR in file" or "Apply SSR in workspace"
{
"command": "rust-analyzer.ssr",
"arguments": [
{
"query": "foo($a) ==>> bar($a)",
"parseOnly": false
}
]
}
rust-analyzer ssr 'foo($a, $b) ==>> bar($b, $a)'
Path Resolution: Paths match semantically. foo::Bar matches Bar if imported from foo.
Auto-qualification: Replacement paths are qualified appropriately for each insertion site.
Parenthesization: Automatic parens added when needed (e.g., $a + $b becoming ($a + $b).method()).
Comment Preservation: Comments within matched ranges are preserved.
SSR can match code inside macro expansions, but with an important restriction: all matched tokens must originate from the same source.
macro_rules! my_macro {
($x:expr) => {
foo($x, 42) // "42" comes from macro definition
};
}
my_macro!(bar); // "bar" comes from call site
The expanded code is foo(bar, 42). Here:
bar originates from the call site (what the user wrote)foo, 42 originate from the macro definitionIf you search for foo($a, $b):
foo(bar, 42) because $a would capture bar (call site) but $b would capture 42 (definition site) — these cross the macro boundary.SSR can only generate edits for code the user actually wrote. If a match spans both user code and macro-generated code, SSR couldn't produce a valid edit — it would need to modify the macro definition, which is a different (and potentially shared) piece of code.
my_macro!(foo($a)) can match foo($a)my_macro!($x) workskind(literal) and not()foo ==>> bar) may be filtered if ambiguoususe declarations with braces$o.map_or(None, Some) ==>> $o
$s.foo ==>> $s.bar
Foo { a: $a, b: $b } ==>> Foo { b: $b, a: $a }
Vec<$t> ==>> SmallVec<[$t; 4]>
crates/ide-ssr/src/crates/ide/src/ssr.rscrates/ide-ssr/src/tests.rsdevelopment
Manage devlogs (session journal entries) under the active repo's `.claude/devlogs/`. Subcommands - `write` creates a new date-stamped entry, `read` loads existing entries into context. Use when the user invokes `/devlog <subcommand>` or asks to write, save, recall, or load today's/recent devlogs.
development
Run MY_WIKI operations (ingest, query, research, lint). Use when the user wants to add sources to the wiki, ask questions against it, research new topics from the web, or audit its quality.
testing
Create and edit Obsidian Flavored Markdown with wikilinks, embeds, callouts, properties, and other Obsidian-specific syntax. Use when working with .md files in Obsidian, or when the user mentions wikilinks, callouts, frontmatter, tags, embeds, or Obsidian notes.
tools
Interact with Obsidian vaults using the Obsidian CLI to read, create, search, and manage notes, tasks, properties, and more. Also supports plugin and theme development with commands to reload plugins, run JavaScript, capture errors, take screenshots, and inspect the DOM. Use when the user asks to interact with their Obsidian vault, manage notes, search vault content, perform vault operations from the command line, or develop and debug Obsidian plugins and themes.