Serena
Use Serena-backed semantic code navigation and editing when working in existing software projects with non-trivial structure, especially multi-file repos whe...
Like a lobster shell, security has layers — review code before you run it.
License
SKILL.md
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_overviewserena_find_symbolserena_list_dirserena_find_fileserena_session_statuswhen you need to inspect active Serena sessions
- Narrow scope with:
serena_find_referencesserena_search_patternserena_read_symbolserena_read_file
- Prefer semantic edits when changing existing code:
serena_replace_symbol_bodyserena_insert_before_symbolserena_insert_after_symbolserena_rename_symbol
- Use broader edit tools only when symbol-scoped tools are not a good fit:
serena_replace_contentserena_create_text_file
- Use
serena_execute_shell_commandonly as an advanced escape hatch when project-context shell execution is genuinely the right tool. - Use
serena_call_toolonly 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
Tool preference order
For existing codebases, prefer this order:
serena_activate_projectserena_project_overview/serena_find_symbol/serena_find_fileserena_find_references/serena_search_patternserena_read_symbol/serena_read_file- symbol-scoped edit tools
- broader Serena edit tools
serena_session_statusfor session inspection/debuggingserena_execute_shell_commandonly when semantic tools are not the right mechanism- fallback to
read,edit, andexeconly 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 withserena_find_symbol,serena_find_references, andserena_read_symbolbefore editing.
Practical usage patterns
Understand a repo area
Use this sequence:
serena_activate_projectserena_find_fileorserena_list_dirserena_project_overviewserena_find_symbolserena_read_symbol
Trace impact before changing code
Use this sequence:
serena_find_symbolserena_find_referencesserena_search_patternif naming or text-level usage mattersserena_read_symbolfor 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
Files
2 totalComments
Loading comments…
