Skip to content
GitHub Agentic Workflows

Using Serena

This guide covers using Serena, a powerful coding agent toolkit that provides semantic code retrieval and editing capabilities to agentic workflows.

Serena is an MCP server that enhances AI agents with IDE-like tools for semantic code analysis and manipulation. It supports 30+ programming languages through Language Server Protocol (LSP) integration, enabling agents to find symbols, navigate relationships, edit at symbol level, and analyze code structure - all without reading entire files or performing text-based searches.

Add Serena to your workflow using the short syntax with a list of languages:

---
engine: copilot
permissions:
contents: read
tools:
serena: ["go", "typescript", "python"]
---

This enables Serena for Go, TypeScript, and Python code analysis.

---
engine: copilot
permissions:
contents: read
tools:
serena: ["go"]
github:
toolsets: [default]
---
# Code Quality Analyzer
Analyze Go code for quality improvements:
1. Find all exported functions and check for missing documentation
2. Identify code patterns and suggest improvements

Short syntax (recommended for most cases):

tools:
serena: ["go", "typescript"]

Long syntax for language-specific options:

tools:
serena:
version: latest
args: ["--verbose"]
languages:
go:
version: "1.21"
go-mod-file: "go.mod" # Use "backend/go.mod" if in subdirectory
gopls-version: "v0.14.2"
python:
version: "3.12"

Key configuration fields: version (Serena version), args (CLI arguments), and languages (per-language settings).

Serena supports 30+ programming languages through Language Server Protocol (LSP):

CategoryLanguages
SystemsC, C++, Rust, Go, Zig
JVMJava, Kotlin, Scala, Groovy (partial)
WebJavaScript, TypeScript, Dart, Elm
DynamicPython, Ruby, PHP, Perl, Lua
FunctionalHaskell, Elixir, Erlang, Clojure, OCaml
ScientificR, Julia, MATLAB, Fortran
ShellBash, PowerShell
OtherC#, Swift, Nix, Markdown, YAML, TOML

Serena provides semantic code tools organized into three categories:

CategoryTools
Symbol Navigationfind_symbol, find_referencing_symbols, get_symbol_definition, list_symbols_in_file
Code Editingreplace_symbol_body, insert_after_symbol, insert_before_symbol, delete_symbol
Project Analysisfind_files, get_project_structure, analyze_imports

These tools enable agents to work at the symbol level rather than the file level, making code operations more precise and context-aware.

Serena caches language server indexes for faster operations. Create the cache directory in your workflow:

Terminal window
mkdir -p /tmp/gh-aw/cache-memory/serena

Optionally configure cache-memory in frontmatter:

tools:
serena: ["go"]
cache-memory:
key: serena-analysis
---
engine: copilot
tools:
serena: ["go"]
github:
toolsets: [default]
---
# Find Unused Code
1. Configure memory: `mkdir -p /tmp/gh-aw/cache-memory/serena`
2. Use `find_symbol` and `find_referencing_symbols` to identify unused exports
3. Report findings
---
engine: claude
permissions:
contents: write
tools:
serena: ["python"]
edit:
---
# Add Type Hints
1. Find functions without type hints
2. Add annotations using `replace_symbol_body`
3. Verify correctness

Configure cache directory early (mkdir -p /tmp/gh-aw/cache-memory/serena) for faster operations. Prefer symbol-level operations (replace_symbol_body) over file-level edits. For Go projects, explicitly set go-mod-file location. Combine Serena with other tools like github, edit, and bash for complete workflows. For large codebases, start with targeted analysis of specific packages before expanding scope.

Language server not found: Install required dependencies (e.g., go install golang.org/x/tools/gopls@latest for Go).

Memory permission issues: Ensure cache directory exists with proper permissions: mkdir -p /tmp/gh-aw/cache-memory/serena && chmod 755 /tmp/gh-aw/cache-memory/serena

Go module path not found: Explicitly configure go-mod-file: "path/to/go.mod" in language settings.

Slow initial analysis: Expected behavior as language servers build indexes. Subsequent runs use cached data. Enable cache-memory for persistence or run on schedule to maintain warm cache.