Skip to content

Using Rose in your own repository

Steven Blom edited this page Sep 12, 2026 · 1 revision

Using Rose in your own repository

An agent's default reflex for C# is grep plus manual editing, and a semantic tool only wins if reaching for it is cheaper than that reflex. Three things carry that, in descending order of effect:

  1. Server instructions (ServiceCollectionExtensions.Instructions). Sent during initialize, so the model reads them before choosing an approach -- unlike tool descriptions, which are only read once a tool is already under consideration. Keep them short and framed around what goes wrong with the default approach, not around what the tools do.

  2. No setup call. Every tool finds its own solution, from a supplied path or from the working directory. A tool that needs workspace_open first loses to grep before it is ever tried.

  3. Registration in the consuming repo. Add to that project's CLAUDE.md:

    ## C# navigation and refactoring
    
    Use the Roslyn-backed `rose_*` MCP tools rather than grep or find-and-replace for C# in
    this repo. Every one of them addresses code by name -- `Namespace.Type.Member`, with a
    parameter list for an overload -- so nothing needs a line and column found by grepping
    first, and nothing goes stale when an earlier edit moves a line.
    
    Reading: `rose_outline` for what a type or a file contains, `rose_symbol_info` with
    `includeSource` for one member and its code, `rose_find_references` for usages (grouped by
    the member each is inside), `rose_find_implementations` for the other direction,
    `rose_project_graph` for what depends on what. None of these ends in a file read, which
    matters: once the file is open the next edit goes through a text tool.
    
    Writing: `rose_add_file` starts a new file, in the right project, with the namespace its
    folder implies and the imports its code needs. `rose_replace_member`, `rose_add_member` and
    `rose_delete_member` change a member; `rose_replace_body` changes one, and takes `find` and
    `replace` for a change too small to re-emit the whole body for, or `position` to insert at
    one end. `rose_replace_doc_comment` and `rose_set_attribute` change the prose and the
    attributes without touching the code. `rose_change_signature` adds, removes or retypes a
    parameter across every override, implementation and call site at once, and
    `rose_move_member` moves one between types with its call sites. All of them refuse code
    that does not parse, format what they write, and report what the edit broke -- so there is
    no build in the edit loop.
    
    Imports are worked out for you: a written member's unresolved names are looked up and the
    unambiguous ones imported, with the rest reported as a choice rather than guessed at. Pass
    `usings` to be explicit, `rose_add_using` for code written another way, and
    `rose_resolve_name` to search for a namespace without committing to one.
    
    Before running anything out of `bin`, `rose_build_freshness` says whether it is this code.
    Source-generated code is only readable via `rose_list_generated_documents` /
    `rose_read_generated_document`.

Register the server with:

claude mcp add rose -- <path>/RoseMcp.Server.exe

Clone this wiki locally