skills_categorized/code-quality/serena/SKILL.md
This skill provides symbol-level code understanding and navigation using Language Server Protocol (LSP). Enables IDE-like capabilities for finding symbols, tracking references, and making precise code edits at the symbol level.
npx skillsauth add activer007/ordinary-claude-skills serenaInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Navigate and manipulate code at the symbol level using IDE-like semantic analysis powered by Language Server Protocol (LSP).
You may have Serena available in one or both of these ways:
Option 1: Direct MCP Tools (if configured by your orchestrator) Check your available tools for:
find_symbol, find_referencing_symbols - Symbol lookuprename_symbol, replace_symbol_body - Refactoringinsert_after_symbol, insert_before_symbol - Precise insertionsonboarding, activate_project - Project understandingwrite_memory, read_memory - Save contextIf you see these tools, use them directly - they provide full Serena capabilities!
Option 2: CLI Commands (always available via execute_command) You can run serena commands using:
execute_command("uvx --from git+https://github.com/oraios/serena serena <command>")
This skill focuses on CLI usage patterns. If you have direct MCP tools, prefer those for better integration.
The serena skill provides access to Serena, a coding agent toolkit that transforms text-based LLMs into symbol-aware code agents. Unlike traditional text search (ripgrep) or structural search (ast-grep), Serena understands code semantics through LSP integration.
Key capabilities:
Serena operates at the symbol level rather than the text or syntax level, providing true IDE-like understanding of code structure, scope, and relationships.
Use the serena skill when you need symbol-level code understanding:
Code Navigation:
Code Understanding:
Code Refactoring:
Choose serena over file-search (ripgrep/ast-grep) when:
Still use file-search when:
Serena uses LSP servers for semantic analysis. Most common languages are supported out-of-the-box:
The LSP servers provide symbol information for the language you're working with.
find_symbol)Locate where a symbol is defined in your codebase.
Note: All examples below use the short form serena <command>. The full command is:
uvx --from git+https://github.com/oraios/serena serena <command>
# Find a class definition
execute_command("uvx --from git+https://github.com/oraios/serena serena find_symbol --name 'UserService' --type class")
# Find a function definition
execute_command("uvx --from git+https://github.com/oraios/serena serena find_symbol --name 'authenticate' --type function")
# Find a variable definition
execute_command("uvx --from git+https://github.com/oraios/serena serena find_symbol --name 'API_KEY' --type variable")
Use cases:
Output format:
File: src/services/user_service.py
Line: 42
Symbol: UserService (class)
Context: class UserService(BaseService):
find_referencing_symbols)Discover all locations where a symbol is used, imported, or referenced.
# Find all usages of a class
execute_command("serena find_referencing_symbols --name 'UserService'")
# Find all call sites of a function
execute_command("serena find_referencing_symbols --name 'authenticate'")
# Find all reads/writes of a variable
execute_command("serena find_referencing_symbols --name 'API_KEY'")
Use cases:
Output format:
Found 12 references to 'authenticate':
1. src/api/routes.py:34
authenticate(user_credentials)
2. src/middleware/auth.py:18
from services import authenticate
3. tests/test_auth.py:56
mock_authenticate = Mock(spec=authenticate)
...
insert_after_symbol)Insert code at specific symbol locations with surgical precision.
# Add a method to a class
execute_command("""serena insert_after_symbol --name 'UserService' --type class --code '
def get_user_by_email(self, email: str) -> Optional[User]:
return self.db.query(User).filter_by(email=email).first()
'""")
# Insert error handling after a function call
execute_command("""serena insert_after_symbol --name 'database_query' --code '
if result is None:
raise DatabaseError("Query returned no results")
'""")
# Add a field to a dataclass
execute_command("""serena insert_after_symbol --name 'User' --type class --code '
email_verified: bool = False
'""")
Use cases:
Safety features:
When changing a function signature or behavior:
# Step 1: Find the function definition
serena find_symbol --name 'process_payment' --type function
# Step 2: Find all call sites
serena find_referencing_symbols --name 'process_payment'
# Step 3: Analyze impact (review output)
# [Review all usage locations to understand impact]
# Step 4: Make changes with confidence
# [Update function and all call sites based on findings]
When extending a class with new methods:
# Step 1: Locate the class
serena find_symbol --name 'PaymentProcessor' --type class
# Step 2: Verify no conflicts
serena find_symbol --name 'process_refund' --type function
# Step 3: Insert new method
serena insert_after_symbol --name 'PaymentProcessor' --type class --code '
def process_refund(self, payment_id: str, amount: float) -> bool:
# Implementation here
pass
'
When analyzing code relationships:
# Step 1: Find class definition
serena find_symbol --name 'DatabaseManager' --type class
# Step 2: Find all usages
serena find_referencing_symbols --name 'DatabaseManager'
# Step 3: For each usage, find what symbols use that code
# [Repeat reference tracking to build dependency graph]
When identifying unused code:
# Step 1: Find symbol definition
serena find_symbol --name 'legacy_auth_handler'
# Step 2: Check references
serena find_referencing_symbols --name 'legacy_auth_handler'
# Step 3: If zero references (except definition), mark for removal
# [If output shows only the definition, symbol is unused]
Serena and file-search (ripgrep/ast-grep) are complementary tools. Use them together:
Use ripgrep THEN serena:
# 1. Find potential matches with ripgrep (fast, broad)
rg "authenticate" --type py
# 2. Narrow to specific symbol with serena (precise)
serena find_symbol --name 'authenticate' --type function
serena find_referencing_symbols --name 'authenticate'
Use serena THEN ripgrep:
# 1. Find symbol definition with serena
serena find_symbol --name 'UserService'
# 2. Search for related patterns with ripgrep
rg "UserService\(" --type py # Find direct instantiations
rg "class.*UserService" --type py # Find subclasses
| Task | Best Tool | Why | |------|-----------|-----| | Find string literals | ripgrep | Text-based, fast | | Find TODOs/comments | ripgrep | Text-based | | Find symbol definition | serena | Symbol-aware | | Find all references | serena | Semantic understanding | | Find code patterns | ast-grep | Syntax-aware | | Insert at symbol | serena | Precise positioning | | Search across languages | ripgrep | Language-agnostic | | Understand scope | serena | LSP semantic info |
Always locate the symbol definition first:
# GOOD: Find definition, then references
serena find_symbol --name 'MyClass'
serena find_referencing_symbols --name 'MyClass'
# AVOID: Searching for references without confirming definition exists
Narrow searches with --type when possible:
# GOOD: Specific type reduces ambiguity
serena find_symbol --name 'User' --type class
# LESS PRECISE: May match User function, User variable, etc.
serena find_symbol --name 'User'
Always find the symbol before inserting code:
# GOOD: Verify target exists first
serena find_symbol --name 'PaymentService' --type class
# [Review output to confirm correct class]
serena insert_after_symbol --name 'PaymentService' --code '...'
# RISKY: Inserting without verification
serena insert_after_symbol --name 'PaymentService' --code '...'
Check reference output for impact analysis:
# Find references and assess impact
serena find_referencing_symbols --name 'deprecated_function'
# If 50+ references, plan careful migration
# If 0 references, safe to remove
After insertions, verify changes:
serena insert_after_symbol --name 'MyClass' --code '...'
git diff # Review actual changes before committing
Serena supports 30+ languages through LSP integration:
Tier 1 (Fully tested):
Tier 2 (Community tested):
Tier 3 (Experimental):
For the complete list and setup instructions, see Serena language support docs.
Searching text/comments: Use ripgrep instead
# WRONG TOOL: Serena doesn't search comments
serena find_symbol --name "TODO"
# RIGHT TOOL: Use ripgrep for text
rg "TODO"
Generated code: LSP may not index auto-generated files
Very large codebases: Symbol indexing can be slow
Dynamic languages without types: Limited semantic info
Serena is designed for token-efficient code navigation:
# Traditional approach (inefficient)
execute_command("cat entire_file.py") # 1000+ tokens
# [Search for symbol manually in output]
# Serena approach (efficient)
serena find_symbol --name 'MyClass' # 50 tokens
# [Get precise location immediately]
Comparison with alternatives:
If find_symbol returns no results:
Verify symbol exists: Use ripgrep to confirm
rg "class MyClass" --type py
Check language server: Ensure LSP is configured for the language
serena status # Check LSP server status
Try case variations: Symbol names are case-sensitive
serena find_symbol --name 'myclass' # Try different cases
Rebuild index: Force LSP to re-index
serena reindex # Rebuild symbol index
If find_referencing_symbols returns hundreds of results:
Use file-search first: Narrow scope with ripgrep
rg "MyClass" src/services/ # Limit to specific directory
serena find_referencing_symbols --name 'MyClass' --path src/services/
Filter by reference type: Focus on specific usage patterns
# Look for imports only
rg "from .* import.*MyClass" --type py
Prioritize recent changes: Check git history first
git log --all -p -S 'MyClass' --since="1 week ago"
If insert_after_symbol fails:
tools
Generate typed TypeScript SDKs for AI agents to interact with MCP servers. Converts verbose JSON-RPC curl commands to clean function calls (docs.createDocument() vs curl). Auto-detects MCP tools from server modules, generates TypeScript types and client methods, creates runnable example scripts. Use when: building MCP-enabled applications, need typed programmatic access to MCP tools, want Claude Code to manage apps via scripts, eliminating manual JSON-RPC curl commands, validating MCP inputs/outputs, or creating reusable agent automation.
testing
Generate structured task lists from specs or requirements. IMPORTANT: After completing ANY spec via ExitSpecMode, ALWAYS ask the user: "Would you like me to generate a task list for this spec?" Use when user confirms or explicitly requests task generation from a plan/spec/PRD.
tools
Create compelling story-format summaries using UltraThink to find the best narrative framing. Support multiple formats - 3-part narrative, n-length with inline links, abridged 5-line, or comprehensive via Foundry MCP. USE WHEN user says 'create story explanation', 'narrative summary', 'explain as a story', or wants content in Daniel's conversational first-person voice.
testing
Navigate through the original three-world shamanic technology. Deploy when soul retrieval, power animal guidance, or journey between realms emerges. Deeply respectful of Tungus, Buryat, Yakut, Evenki traditions. Use for consciousness navigation, NOT cultural appropriation.