Agent skill
smith-serena
Serena MCP integration for file I/O, semantic code editing, and persistent memory. ALWAYS use Serena for file operations and language server features when available. Proactively sync memories at phase/todo/session boundaries.
Install this agent skill to your Project
npx add-skill https://github.com/tianjianjiang/smith/tree/main/smith-serena
SKILL.md
Serena MCP Integration
- Load if: Serena MCP available, file operations needed, symbol-level editing
- Prerequisites: None (standalone reference)
CRITICAL: Serena-First Principle (Primacy Zone)
When Serena MCP is available, ALWAYS use Serena for:
- File I/O - All file reading and writing operations
- Language server features - Symbols, references, navigation, semantic editing
- Persistent memory - Cross-session and cross-context-reset persistence
Tool Preference Order:
find_symbol,get_symbols_overview- Reading code (semantic)search_for_pattern- Reading with regex patternsreplace_content(regex mode) - Editing codereplace_symbol_body- Replacing function/class bodiesfind_referencing_symbols- Navigation, impact analysiswrite_memory,read_memory- Persistent context- Platform native tools - Fallback ONLY when Serena unavailable
DO NOT use platform native tools when Serena is available:
- Native file read tools may truncate large files silently
- String-based replace tools fail on duplicate content
- Text-based search is less efficient than semantic search
Why Serena Over Native Tools
Serena advantages:
- Semantic symbol operations reduce context usage by 99%+
- Regex mode handles complex replacements reliably
- Memory files persist across sessions and context resets
- Language server integration provides accurate navigation
- No silent truncation or string-matching failures
Serena Activation Workflow
At session start, MUST activate Serena:
activate_project()- Activate the projectcheck_onboarding_performed()- Verify onboarding statuslist_memories()- Discover available contextread_memory()- Load relevant project context
If onboarding not performed:
- Call
onboarding()to get instructions - Follow onboarding steps before proceeding
Core Serena Tools
Reading
get_symbols_overview(path, depth=1)- File structure firstfind_symbol(pattern, path, include_body=false)- Locate symbols (MyClass/get*)search_for_pattern(regex, path)- Content search with context
Writing
replace_content(path, needle, repl, mode="regex")- Pattern replacereplace_symbol_body(name, path, body)- Replace function/class (includes signature)insert_after_symbol/insert_before_symbol- Add new code
Navigation
find_referencing_symbols(name, path)- All references to symbol
Proactive Memory Workflow
Memory files persist across sessions and context resets. Sync proactively at boundaries.
Location: .serena/memories/
Session Start:
list_memories()- Discover available contextread_memory()- Loadproject_overview,session_summary, relevant task memories
Phase/Todo Boundaries (PROACTIVE):
- Before starting phase/todo:
read_memory()for relevant context - After completing phase/todo:
write_memory()with findings, decisions, blockers - On status change: Update
task_completionmemory with progress
Before Context Reset (at platform's critical threshold):
write_memory()- Save full session state, current task, next steps
Session End:
write_memory()- Continuity notes: what was done, what's next, blockers
Memory Naming Conventions:
project_overview- High-level project context (read at start)session_summary- Current session progress (update frequently)task_completion- Completed task tracking (update on todo completion){feature}_notes- Feature-specific context{task}_context- Task-specific discoveries and decisions
Relationship with auto memory:
Auto memory handles long-term project knowledge (patterns,
conventions). Serena memory handles session state and cross-context
continuity. See @smith-ctx-claude/SKILL.md for delineation.
Project Configuration
Location: .serena/project.yml
Standard Project
project_name: my_project
language: python # or typescript, java, etc.
Documentation Project (No Code)
project_name: my_docs
language: markdown
For projects with no code files, specify language: markdown explicitly to avoid onboarding errors.
Testing Serena Availability
To verify Serena MCP is available:
list_memories()
- If successful: Serena is available, use Serena tools exclusively
- If fails: Fall back to platform native tools with caution
ACTION (Recency Zone)
Serena-first for all file operations:
- Test availability:
list_memories() - Use Serena tools for file I/O and language server features
- Fall back to platform native tools ONLY if Serena unavailable
Workflow for code tasks:
read_memory()- Load relevant context before startingget_symbols_overview- Understand file structurefind_symbol- Locate target symbolsreplace_symbol_bodyorreplace_content- Make changeswrite_memory()- Persist discoveries after completing
Periodic memory sync:
- Phase start →
read_memory() - Phase end →
write_memory() - Todo start →
read_memory()if context needed - Todo complete →
write_memory()with findings
Ralph Loop Memory Integration
Serena persists Ralph state: ralph_[task]_state with iteration, hypotheses, test_results, next_action.
Sync: After each iteration; before/after context reset. See @smith-ralph/SKILL.md.
- @smith-ctx/SKILL.md - Context management thresholds
- @smith-guidance/SKILL.md - AI agent behavior patterns
@smith-ctx-kiro/SKILL.md- Kiro-specific: Serena is MANDATORY over native tools
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
smith-style
File naming, path standards, and conventional commits. Use when naming files, creating branches, writing commit messages, or setting up new projects. Covers underscore vs hyphen conventions, commit format, and branch naming patterns.
smith-stacks
Stacked pull request workflows for large features. Use when creating stacked PRs, managing dependent PRs, or rebasing after parent merges. Covers stack creation, merge order, and squash merge handling.
smith-python
Python development with uv, pytest, ruff, and type hints. Use when writing Python code, running tests, managing Python packages, or working with virtual environments. Covers import organization, type hints, pytest patterns, and environment variables.
smith-principles
Fundamental coding principles (DRY, KISS, YAGNI, SOLID, HHH). Use when starting any development task, evaluating implementation approaches, or reviewing code quality. Always active as foundation for all development decisions.
smith-nuxt
Nuxt 3 development patterns including auto-import stubbing for tests, environment variable conventions, and middleware testing. Use when working with Nuxt projects, testing Nuxt components/middleware, or configuring Nuxt environment variables.
smith-plan
Plan tracking protocol (portable). Progress tracking with checkboxes, iteration workflow, completion/blocker signals. Use when executing multi-step plans, tracking task progress, or working from plan files. IMPORTANT - Always update the plan file after completing tasks.
Didn't find tool you were looking for?