Serena#
Use Serena as the first choice for understanding and editing existing codebases when the necessary tools are available.
What this skill is for#
Use this skill when another agent needs to integrate Serena into its normal coding workflow instead of treating the repo as a pile of text files.
Aim for this behavior:
- activate the project once
- inspect structure semantically before reading large files
- trace references before editing
- prefer symbol-scoped edits when possible
- fall back to normal file tools only when Serena is missing a capability or fails
For extra examples and trigger patterns, read references/integration-patterns.md.
Core workflow#
- Resolve the target project path.
- Call
serena_activate_project.
- Start with structure discovery:
serena_project_overview
serena_find_symbol
serena_list_dir
serena_find_file
serena_session_status when you need to inspect active Serena sessions
- Narrow scope with:
serena_find_references
serena_search_pattern
serena_read_symbol
serena_read_file
- Prefer semantic edits when changing existing code:
serena_replace_symbol_body
serena_insert_before_symbol
serena_insert_after_symbol
serena_rename_symbol
- Use broader edit tools only when symbol-scoped tools are not a good fit:
serena_replace_content
serena_create_text_file
- Use
serena_execute_shell_command only as an advanced escape hatch when project-context shell execution is genuinely the right tool.
- Use
serena_call_tool only when the normalized surface does not cover the needed Serena capability.
- Fall back to ordinary file tools only when Serena cannot answer safely or reliably.
When Serena is worth the overhead#
Prefer Serena when:
- the project spans multiple files
- the user asks about references, call chains, or symbol relationships
- the user wants a precise edit to an existing class, function, method, or module
- reading whole files would be noisy or wasteful
- the repo already has real structure and semantic lookup is available
Skip or delay Serena when:
- the task is a tiny one-file change and the target location is already obvious
- you are creating a brand-new file with little dependency on existing code
- Serena is unavailable or failing and direct file tools are simpler
- the user already provided the exact file region and semantic lookup adds no value
For existing codebases, prefer this order:
serena_activate_project
serena_project_overview / serena_find_symbol / serena_find_file
serena_find_references / serena_search_pattern
serena_read_symbol / serena_read_file
- symbol-scoped edit tools
- broader Serena edit tools
serena_session_status for session inspection/debugging
serena_execute_shell_command only when semantic tools are not the right mechanism
- fallback to
read, edit, and exec only when needed
Integration guidance for agent authors#
When you want another agent to use Serena well, instruct it to:
- activate the project before semantic reads or edits
- inspect symbols and references before modifying code
- use normalized Serena tools first
- keep edits narrow and structured
- avoid whole-file rewrites when a symbol-scoped edit is possible
- treat passthrough as an escape hatch, not the default workflow
A good instruction pattern is:
Use Serena on the repo. Start with serena_activate_project, then narrow scope with serena_find_symbol, serena_find_references, and serena_read_symbol before editing.
Practical usage patterns#
Understand a repo area#
Use this sequence:
serena_activate_project
serena_find_file or serena_list_dir
serena_project_overview
serena_find_symbol
serena_read_symbol
Trace impact before changing code#
Use this sequence:
serena_find_symbol
serena_find_references
serena_search_pattern if naming or text-level usage matters
serena_read_symbol for the most relevant callers/callees
Make a targeted edit#
Use this sequence:
- locate the exact symbol
- read the symbol body
- inspect references if behavior changes could ripple outward
- choose the narrowest valid edit tool
- re-read the changed symbol or nearby references when confidence is low
Editing rules#
- Keep edits as narrow as possible.
- Prefer symbol-targeted edits over text replacement across a whole file.
- Prefer semantic rename over manual multi-file rename logic.
- Re-read the relevant symbol or references after a material edit when confidence is low.
- If semantic identity is ambiguous, do not guess; disambiguate using path or extra lookup.
- In read-only mode, do not attempt mutating Serena tools.
Safety and fallback behavior#
If Serena fails:
- Explain briefly what failed.
- Fall back to standard file-based workflow.
- Keep using the smallest possible read/edit scope.
- Do not pretend the semantic result was confirmed if it was not.
If a raw Serena passthrough tool is available:
- use it only when the normalized tool surface does not cover the needed capability
- prefer stable normalized tools for repeated workflows
- avoid passthrough for routine actions that already have a clear normalized tool