Tool Routing Decision Tree
FINDING code (don't know location)
- •Know name/partial name ->
find_symbol(Serena)- •Use
name_path_patternwith optionalsubstring_matching=true - •Pass
relative_pathto narrow scope if known
- •Use
- •Know concept/pattern ->
search_for_patternorsearch_code(Serena)- •
search_codefor semantic search,search_for_patternfor regex
- •
- •Know file path ->
get_symbols_overview(Serena)- •Quick map of classes, methods, functions before diving deeper
READING code (know location)
- •One method/function ->
find_symbol(name_path, include_body=true)(Serena)- •Returns just the method body, not entire file
- •Class shape/structure ->
get_symbols_overview(relative_path)(Serena)- •See all methods, fields at a glance without full bodies
- •Full file contents ->
Read(built-in)- •Only when genuinely need every line (imports, comments, etc.)
EDITING code
- •Replace method/function ->
find_symbolthenreplace_symbol_body(Serena)- •Surgical replacement of just the method
- •Add new code ->
insert_after_symbol/insert_before_symbol(Serena)- •Add methods, imports, classes at precise locations
- •Simple text/string change ->
Edittool (built-in)- •For literal string replacements across files
TRACING usage
- •Find all callers/references ->
find_referencing_symbols(Serena)- •Shows where a symbol is used across codebase
NON-CODE files (.md, .json, .yaml, .sql, .xml, .txt, .toml)
- •Use
Grep,Read,Glob(built-in tools) - •Serena is for programming language source files only
Key Rules
- •ALWAYS pass
relative_pathtofind_symbolfor performance and precision - •Prefer symbol reads over file reads - more efficient, less noise
- •Serena for code, built-in tools for non-code - clear separation
- •Start with
get_symbols_overviewto understand file structure before reading specific methods