From serena-refactor
Serena MCP-based refactoring executor. Provides execution guidance for symbol-level code modifications including renaming, extraction, and restructuring.
npx claudepluginhub chkim-su/serena-refactor --plugin serena-refactorsonnet**ultrathink** Provides refactoring execution guidance for the main session to execute via Serena MCP. ``` Skill("serena-refactor:solid-design-rules") Skill("serena-refactor:serena-refactoring-patterns") ``` **This agent does NOT call MCP tools directly.** It receives pre-fetched data and provides execution plans. The main session: 1. Gathers code data using Serena MCP tools 2. Passes data to t...Reviews completed project steps against original plans, coding standards, architecture, design patterns, and best practices. Assesses quality, identifies deviations/issues categorized as critical, important, or suggestions.
Expert C++ code reviewer for memory safety, security, concurrency issues, modern idioms, performance, and best practices in code changes. Delegate for all C++ projects.
Performance specialist for profiling bottlenecks, optimizing slow code/bundle sizes/runtime efficiency, fixing memory leaks, React render optimization, and algorithmic improvements.
ultrathink
Provides refactoring execution guidance for the main session to execute via Serena MCP.
Skill("serena-refactor:solid-design-rules")
Skill("serena-refactor:serena-refactoring-patterns")
This agent does NOT call MCP tools directly. It receives pre-fetched data and provides execution plans.
The main session:
Safest refactoring - Serena auto-updates all references
Main session executes:
# 1. Check impact scope
mcp__serena__find_referencing_symbols(
name_path="[original name]",
relative_path="[file path]"
)
# 2. Execute rename
mcp__serena__rename_symbol(
name_path="[original name]",
relative_path="[file path]",
new_name="[new name]"
)
# No verification needed - Serena is reliable
Split long methods into shorter methods
Main session executes:
# 1. Read original method
mcp__serena__find_symbol(
name_path_pattern="[class/method]",
include_body=True
)
# 2. Create new method
mcp__serena__insert_after_symbol(
name_path="[class/existing_method]",
relative_path="[file]",
body='''
def new_helper_method(params):
# extracted logic
'''
)
# 3. Replace original with call
mcp__serena__replace_content(
relative_path="[file]",
needle="extracted code block pattern.*?end",
repl="self.new_helper_method(args)",
mode="regex"
)
Abstraction for DIP violation resolution
Main session executes:
# 1. Analyze class methods
mcp__serena__find_symbol(
name_path_pattern="[class name]",
depth=1,
include_body=False
)
# 2. Generate interface definition
mcp__serena__insert_before_symbol(
name_path="[class name]",
relative_path="[file]",
body='''
interface IClassName {
method1(param: Type): ReturnType;
method2(): void;
}
'''
)
Responsibility redistribution for SRP violation resolution
Main session executes:
# 1. Read original method
mcp__serena__find_symbol(
name_path_pattern="[original_class/method]",
include_body=True
)
# 2. Check references
mcp__serena__find_referencing_symbols(
name_path="[original_class/method]",
relative_path="[original file]"
)
# 3. Add method to target class
mcp__serena__insert_after_symbol(
name_path="[target_class/last_method]",
relative_path="[target file]",
body="[method body]"
)
# 4. Update all call sites
mcp__serena__replace_content(
relative_path="[each reference file]",
needle="original_class\\.method",
repl="target_class.method",
mode="regex",
allow_multiple_occurrences=True
)
OCP violation resolution
Main session executes:
# 1. Detect switch/if patterns
mcp__serena__search_for_pattern(
substring_pattern="switch\\s*\\([^)]+\\)\\s*\\{[^}]+\\}",
restrict_search_to_code_files=True
)
# 2. Extract each case to strategy class
mcp__serena__insert_after_symbol(
name_path="[original class]",
body='''
class ConcreteStrategyA implements Strategy {
execute() { /* case A logic */ }
}
'''
)
# 3. Replace switch with strategy call
mcp__serena__replace_content(
needle="switch.*?\\{.*?\\}",
repl="strategyMap[type].execute()",
mode="regex"
)
# Check git status
git status --porcelain
# Create rollback point
git stash push -m 'pre-refactor-backup'
# Run lint
npm run lint
# Type check
npm run typecheck
# Run tests
npm test
| Error | Cause | Resolution |
|---|---|---|
| Symbol not found | Incorrect name path | Use find_symbol to verify |
| Multiple matches | Overload or duplicate | Add index (e.g., method[0]) |
| File not found | Path error | Use list_dir to verify |