This skill should be used when the user asks to "find a symbol", "locate code", "refactor", "rename across codebase", or performs ANY coding task with Serena toolbox...
Serena provides IDE-like semantic code understanding through Language Server Protocol (LSP) integration. Use Serena's semantic tools instead of grep/read operations whenever possible for superior code navigation and editing.
ALWAYS prefer semantic operations over text-based operations.
This applies to ALL coding tasksβno exceptions for emergencies, simple tasks, or time pressure.
| Instead of... | Use Serena... |
|---|---|
| Grep for function name | find_symbol |
| Read entire file | get_symbols_overview + targeted reads |
| String replace across files | rename_symbol |
| Manual line counting for edits | insert_after_symbol / replace_symbol_body |
Semantic tools are FASTER when you account for total time:
find_symbol finds the actual definition β immediate precisionThe "emergency exception" is a trap: Using grep during a production incident doesn't save timeβit creates noise you must manually parse while under pressure. Semantic tools give precise answers when precision matters most.
Before using Serena tools, ensure the project is activated:
check_onboarding_performedonboarding to analyze project structureactivate_project with project pathSetup is mandatory, not optional: Even under time pressure or in emergencies, onboarding takes 2-3 minutes and prevents hours of mistakes. Do it once per project, benefit every session.
If LSP fails to initialize or language servers are missing:
This is the ONLY exception: Semantic tools being non-functional (not "slower" or "unfamiliar") permits fallback. If Serena works, use it.
Use these for understanding code:
| Tool | Purpose | When to Use |
|---|---|---|
find_symbol |
Locate symbols by name/substring | Finding classes, functions, variables |
find_referencing_symbols |
Find all usages of a symbol | Understanding impact before changes |
get_symbols_overview |
List top-level symbols in a file | Quick file structure understanding |
Use these instead of line-based edits:
| Tool | Purpose | When to Use |
|---|---|---|
insert_before_symbol |
Add code before a symbol | Adding imports, decorators |
insert_after_symbol |
Add code after a symbol | Adding related methods/functions |
replace_symbol_body |
Replace entire symbol definition | Rewriting functions/classes |
rename_symbol |
Rename across codebase | Refactoring with LSP support |
Use when symbol-level operations aren't applicable:
| Tool | Purpose |
|---|---|
read_file |
Read file contents |
create_text_file |
Create or overwrite files |
list_dir |
Browse directory structure |
find_file |
Locate files by path |
delete_lines / insert_at_line / replace_lines |
Line-based edits |
| Tool | Purpose |
|---|---|
activate_project |
Switch active project context |
onboarding |
Analyze project structure, find build/test commands |
get_current_config |
Show active configuration |
restart_language_server |
Reinitialize after external changes |
1. activate_project β Ensure project is active
2. onboarding β Get project overview, build/test commands
3. get_symbols_overview β Understand file structures
4. find_symbol β Locate specific entities
5. find_referencing_symbols β Trace dependencies
1. find_symbol β Locate where to add code
2. get_symbols_overview β Understand surrounding context
3. insert_after_symbol β Add new code semantically
4. find_referencing_symbols β Verify no breaking changes
1. find_symbol β Locate target symbol
2. find_referencing_symbols β Understand all usages
3. rename_symbol β Rename with LSP support (handles all references)
OR
3. replace_symbol_body β Rewrite implementation
1. find_symbol β Locate problematic function/class
2. find_referencing_symbols β Trace call chain
3. read_file β Read specific sections for context
4. replace_symbol_body β Fix the issue
onboarding for new projectsfind_symbol before read_file for targeted navigationreplace_symbol_body over line-based replacementsrename_symbol for refactoring (handles all references automatically)find_symbol would workrestart_language_server after external file changes| Rationalization | Reality |
|---|---|
| "Production emergency = different rules" | Emergencies need precision MORE, not less. grep noise wastes time. |
| "grep is faster when I'm familiar with it" | Familiarity with wrong tool doesn't make it right. find_symbol is 10 seconds. |
| "This is just a simple text search" | Symbol lookups are never "just text search"βcomments, strings, tests create noise. |
| "One-line change doesn't need semantic tools" | ALL code modifications benefit from LSP awareness. No exceptions. |
| "Setup overhead isn't worth it" | 2-minute onboarding saves hours across the project lifetime. Do it once. |
| "Senior said to use grep" | Authority suggests method, not mandate. Use the correct tool. |
| "I'm being pragmatic, not dogmatic" | Real pragmatism means using tools that prevent mistakes. That's semantic tools. |
| "When building is on fire, grab extinguisher" | False metaphor. Semantic tools ARE the fire extinguisherβthey put out fires faster. |
| "Setup overhead isn't worth it for one lookup" | Onboarding is 2-3 minutes once per project. You'll do dozens of lookups. Always worth it. |
| "I don't know Serena syntax well" | Syntax is documented. Learning once beats repeatedly using wrong tool. |
| "Project isn't activated yet" | Activate it now (3 minutes). Saves hours across all future work on this project. |
If you catch yourself thinking:
STOP. Use semantic tools. No exceptions (unless LSP is literally non-functional).
Serena supports 30+ languages via Language Server Protocol:
Use these for complex tasks:
| Tool | Purpose |
|---|---|
think_about_collected_information |
Verify you have enough context |
think_about_task_adherence |
Check you're still on track |
think_about_whether_you_are_done |
Assess task completion |
Serena significantly reduces token usage by:
For large codebases, always prefer Serena's semantic tools over text-based alternatives.