← ClaudeAtlas

02-core-use-serena-lsp-for-symbol-navigation-and-editslisted

CORE — never delete. HARD MANDATE: trigger before any precise CODE EDIT, rename, refactor, or cross-reference lookup (callers/implementations/definitions). serena is a real Language-Server-backed MCP — symbol-accurate navigation and surgical symbol-body edits, far cheaper and safer than reading whole files and hand-patching. Defines the active-root scoping trap, the TIER-A absolute-path write gate, and the full tool taxonomy. Use it for all edits and 'who calls/implements this?' queries.
markkennethbadilla/public-agent-provisioning · ★ 0 · AI & Automation · score 72
Install: claude install-skill markkennethbadilla/public-agent-provisioning
# Use Serena LSP for Symbol Navigation & Edits (CORE) **Why:** Serena talks to a real language server — it knows true symbol boundaries, references, and definitions across the whole repo. Edits target a symbol's body precisely (no fragile string-matching), and cross-ref queries are exact (not grep guesses). Native Read/Edit/Grep are gate-removed (rule 20b), so Serena is not a preference — it is the only path. ## Before you start 1. **Call `initial_instructions` first** — before any coding task, call `initial_instructions` to load Serena's own manual and tool schema. Skip this and you are guessing at tool names. 2. **Call `activate_project` if cwd isn't picked up** — Serena auto-detects the project from cwd, but only if the working directory is inside a known root. If it isn't, call `activate_project` on the directory containing your target file before doing anything else. ## The active-root trap (read carefully) Serena is scoped to one active root at a time. A path outside that root produces: ``` points to path outside of the repository root ``` **Fix:** call `activate_project` on the directory that owns the file, then retry. Re-activate as many roots as a task needs, switching before each out-of-root edit. **The subtle danger:** a stale active root (or a relative path resolving against it) silently creates a new file or modifies the wrong one. The absolute-path gate below closes this. Out-of-repo targets (e.g. memory files under the agent home d