Skip to content

Commit f282849

Browse files
committed
docs(agents): enrich Serena MCP directives with memories and refactoring tools
1 parent bebefac commit f282849

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

roles/dotfiles/files/agents/AGENTS.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,27 @@ it is available and supports the task; use native tools for small, direct operat
1717

1818
## serena: semantic navigation and edits
1919

20-
- Locate symbols with `find_symbol` and inspect file or directory structure with
21-
`get_symbols_overview`. Use `find_symbol` with `include_body=True` or
22-
`find_declaration` to inspect declarations and bodies. Use `find_implementations`
23-
when concrete implementations matter.
24-
- Before deleting a symbol or changing a contract or behavior that affects callers,
25-
audit callers and call relationships with `find_referencing_symbols`.
26-
LSP results may omit dynamic usages and unsupported files. Supplement them with
27-
`search_for_pattern` or targeted `rg` for text, config keys, and paths.
28-
- For symbol renames and structured modifications, prefer `rename_symbol`,
29-
`replace_symbol_body`, `insert_after_symbol`, or `insert_before_symbol`.
30-
Verify the resulting diff; a successful tool response does not prove files changed.
31-
- After a coherent set of edits, check for regressions using `get_diagnostics_for_file`.
32-
Distinguish new errors from existing ones and run the relevant compiler, linter,
33-
or tests before reporting completion.
20+
- **Mandatory on LSP-enabled codebases** (Python, Rust, Go, TS/JS, etc.): Always query Serena BEFORE falling back to broad file reading (`view_file`). Never dump whole source files when exploring or modifying symbols.
21+
- **Symbol Exploration**:
22+
- Inspect file or module structure with `get_symbols_overview`.
23+
- Locate targets with `find_symbol` (use `include_body=False` to inspect structure/signatures, `include_body=True` only for the target body).
24+
- Use `find_declaration` and `find_implementations` to trace definitions and implementations.
25+
- **Impact Analysis & Safe Refactoring**:
26+
- Before modifying contracts or deleting code, audit callers with `find_referencing_symbols`. Supplement with `search_for_pattern` or `rg` for dynamic usages and config references.
27+
- Prefer `rename_symbol` to rename symbols atomically across definitions and references.
28+
- Prefer `safe_delete_symbol` to delete unused symbols safely (verifies absence of references).
29+
- **Symbolic Editing vs. File Editing**:
30+
- Prefer `replace_symbol_body` when replacing an entire function, method, or class.
31+
- Use `insert_before_symbol` or `insert_after_symbol` to inject new top-level declarations or methods.
32+
- For repeated edits across multiple files, prefer `replace_in_files` (always with `dry_run=True` first).
33+
- Use `replace_content` (Serena) or native line-replacement tools (`replace_file_content` in agy, `apply_patch` in Codex) for small, localized tweaks inside a body or in non-symbolic files.
34+
- **Diagnostics & Quality**:
35+
- After code modifications, check for regressions using `get_diagnostics_for_file` before running project linters, compilers, or tests.
36+
- **Project Memories**:
37+
- Consult `list_memories` and `read_memory` for project context and architecture decisions.
38+
- Store durable patterns, gotchas, or workspace conventions with `write_memory`.
39+
- **Non-LSP Boundary**:
40+
- For plain text, config files (YAML, TOML, JSON), shell scripts, and templates lacking structured LSP symbols, use targeted native tools (`grep_search`, `rg`, native file editing).
3441

3542
## Context efficiency
3643

@@ -53,8 +60,8 @@ Minimize unnecessary context usage while preserving enough evidence for correct
5360
verification is necessary. Batch independent lookups; keep dependent steps sequential.
5461
- Expand retrieved context progressively when current evidence is insufficient.
5562
Read a larger coherent section when it avoids repeated fragmented reads or guesses.
56-
- Use native editing tools for persistent changes, such as `apply_patch` in Codex
57-
or `replace_file_content` in agy.
63+
- For small localized edits or in files without active LSP support, use native editing
64+
tools such as `apply_patch` in Codex or `replace_file_content` in agy.
5865

5966
## Context7: dependency documentation
6067

0 commit comments

Comments
 (0)