using-serena-for-exploration
Use when exploring codebases with Serena MCP tools for architectural understanding and pattern discovery - guides efficient symbolic exploration workflow minimizing token usage through targeted symbol reads, overview tools, and progressive narrowing
What this skill does
# Using Serena for Exploration
Use this skill when exploring codebases with Serena MCP tools for architectural understanding and pattern discovery.
## Core Principles
- Start broad, narrow progressively
- Use symbolic tools before reading full files
- Always provide file:line references
- Minimize token usage through targeted reads
## Workflow
### 1. Initial Discovery
**Use `list_dir` and `find_file`** to understand project structure:
```bash
# Get repository overview
list_dir(relative_path=".", recursive=false)
# Find specific file types
find_file(file_mask="*auth*.py", relative_path="src")
```
### 2. Symbol Overview
**Use `get_symbols_overview`** before reading full files:
```python
# Get top-level symbols in a file
get_symbols_overview(relative_path="src/auth/handler.py")
```
Returns classes, functions, imports - understand structure without reading bodies.
### 3. Targeted Symbol Reading
**Use `find_symbol`** for specific code:
```python
# Read a specific class without body
find_symbol(
name_path_pattern="AuthHandler",
relative_path="src/auth/handler.py",
include_body=false,
depth=1 # Include methods list
)
# Read specific method with body
find_symbol(
name_path_pattern="AuthHandler/login",
relative_path="src/auth/handler.py",
include_body=true
)
```
**Name path patterns:**
- Simple name: `"login"` - matches any symbol named "login"
- Relative path: `"AuthHandler/login"` - matches method in class
- Absolute path: `"/AuthHandler/login"` - exact match within file
- With index: `"AuthHandler/login[0]"` - specific overload
### 4. Pattern Searching
**Use `search_for_pattern`** when you don't know symbol names:
```python
# Find all JWT usage
search_for_pattern(
substring_pattern="jwt\\.encode",
relative_path="src",
restrict_search_to_code_files=true,
context_lines_before=2,
context_lines_after=2,
output_mode="content"
)
```
**Pattern matching:**
- Uses regex with DOTALL flag (. matches newlines)
- Non-greedy quantifiers preferred: `.*?` not `.*`
- Escape special chars: `\\{\\}` for literal braces
### 5. Relationship Discovery
**Use `find_referencing_symbols`** to understand dependencies:
```python
# Who calls this function?
find_referencing_symbols(
name_path="authenticate_user",
relative_path="src/auth/handler.py"
)
```
Returns code snippets around references with symbolic info.
## Reporting Format
Always structure findings as:
```markdown
## Codebase Findings
### Current Architecture
- **Authentication:** `src/auth/handler.py:45-120`
- JWT-based auth with refresh tokens
- Session storage in Redis
### Similar Implementations
- **User management:** `src/users/controller.py:200-250`
- Uses similar validation pattern
- Can reuse `validate_credentials()` helper
### Integration Points
- **Middleware:** `src/middleware/auth.py:30`
- Hook new auth method here
- Follows pattern: check → validate → attach user
```
## Anti-Patterns
❌ **Don't:** Read entire files before understanding structure
✅ **Do:** Use `get_symbols_overview` first
❌ **Don't:** Use full file reads for symbol searches
✅ **Do:** Use `find_symbol` with targeted name paths
❌ **Don't:** Search without context limits
✅ **Do:** Use `relative_path` to restrict search scope
❌ **Don't:** Return findings without file:line references
✅ **Do:** Always include exact locations: `file.py:123-145`
## Token Efficiency
- Overview tools use ~500 tokens vs. ~5000 for full file
- Targeted symbol reads use ~200 tokens per symbol
- Pattern search with `head_limit=20` caps results
- Use `depth=0` if you don't need child symbols
## Example Session
```python
# 1. Find auth-related files
files = find_file(file_mask="*auth*.py", relative_path="src")
# → Found: src/auth/handler.py, src/auth/middleware.py
# 2. Get overview of main handler
overview = get_symbols_overview(relative_path="src/auth/handler.py")
# → Classes: AuthHandler
# → Functions: authenticate_user, validate_token
# 3. Read specific method
method = find_symbol(
name_path_pattern="AuthHandler/authenticate_user",
relative_path="src/auth/handler.py",
include_body=true
)
# → Got full implementation of authenticate_user
# 4. Find who calls this
refs = find_referencing_symbols(
name_path="authenticate_user",
relative_path="src/auth/handler.py"
)
# → Called from: middleware.py:67, api/routes.py:123
```
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.