Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 1, 2026

The Serena tool prompt lacked practical guidance optimized for AI agent decision-making. Analysis of 20 workflows revealed common patterns and anti-patterns. The file has been restructured from documentation-style to action-oriented agent prompt.

Changes

Redefined purpose and scope

  • Changed from vague "advanced static analysis" to precise "LSP MCP server for semantic code analysis"
  • Added explicit ✅ use cases: symbol analysis, call graphs, semantic patterns, refactoring opportunities
  • Added explicit ❌ anti-patterns: text operations, grep-suitable tasks, config files

Optimized for agentic planning

  • Reduced file size by 46% (323 → 173 lines) for faster agent processing
  • Restructured as action-oriented decision guide with Quick Decision section at top
  • Converted prose to scannable bullet points and numbered action sequences
  • Categorized tools by function (Navigation & Analysis, Code Editing, Project Management)
  • Replaced lengthy examples with concise step-by-step workflows

Documented production patterns

  • Extracted from go-fan (97.6% success), sergo (94.4% success), and 3 other workflows
  • Pattern 1: Find all function usages (3-step sequence)
  • Pattern 2: Code quality analysis (4-step sequence)
  • Pattern 3: Daily code analysis (5-step sequence with caching)

Tool reference

  • Navigation: find_symbol, get_symbols_overview, find_referencing_code_snippets
  • Editing: replace_symbol_body, insert_at_line, delete_lines
  • Analysis: search_for_pattern, activate_project, onboarding

Common pitfalls section

  • Using Serena for YAML/JSON/Markdown (use edit instead)
  • Forgetting activate_project first
  • Not combining with bash for file discovery
  • Missing language configuration

Decision tree

Requires code semantics/structure?
├─ NO → bash/edit/view
└─ YES
    ├─ Simple text/grep → bash/grep
    ├─ Config files → edit
    └─ Symbol/structure/patterns → Serena

Removed per feedback

  • Language detection section (agents can use standard file indicators)
  • Serena memory tools (write_memory, read_memory, list_memories) and related best practices

Result

File optimized from 87 to 173 lines (originally expanded to 323). Agents can now make instant YES/NO decisions using top-of-file criteria, with all essential information in a scannable, action-oriented format following the pattern of other agent prompts in .github/aw/.

Custom agent used: technical-doc-writer
AI technical documentation writer for GitHub Actions library using GitHub Docs voice

Original prompt

Update and optimize usage prompt in

https://github.com/githubnext/gh-aw/blob/main/.github/aw/serena-tool.md

  • review workflows usinf serena
  • Use the GitHub agentic workflows logs tool to collect information about the usage of Serena

Use audit to do a deeper dive.

Improve the prompt to make use of Serena more efficient

Custom agent used: technical-doc-writer
AI technical documentation writer for GitHub Actions library using GitHub Docs voice


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update and optimize usage prompt for Serena Optimize Serena tool usage guidance based on workflow analysis Feb 1, 2026
Copilot AI requested a review from pelikhan February 1, 2026 11:55

The first language is the default fallback.

## Detecting Repository Language
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot ignore section

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the "Detecting Repository Language" section. Fixed in 38b4c7b.

- `activate_project` - Activate Serena for a workspace
- `restart_language_server` - Restart LSP if needed

### Memory and State
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot do not use Serena memories

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed Serena memory tools (write_memory, read_memory, list_memories) from the tool reference. Fixed in 38b4c7b.

}
```

### 4. Leverage Memory for Insights
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot do not use see a memory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the "Leverage Memory for Insights" best practice section. Fixed in 38b4c7b.

…back

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan February 1, 2026 12:04
@@ -1,86 +1,323 @@
# Serena Language Server Tool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot optimize the content of the file for agentic planning (this is a prompt of an agent)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optimized for agentic planning. Reduced from 323 to 173 lines (46% reduction), restructured as action-oriented decision guide with:

  • Quick YES/NO decision criteria at top
  • Categorized tool lists with one-line descriptions
  • Step-by-step workflows instead of prose
  • Concise patterns as numbered action sequences
  • Scannable format with bold keywords and bullet points

Fixed in 194afe1.

…d and concise

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Optimize Serena tool usage guidance based on workflow analysis Optimize Serena tool usage guidance for agentic planning Feb 1, 2026
Copilot AI requested a review from pelikhan February 1, 2026 12:12
@pelikhan pelikhan marked this pull request as ready for review February 1, 2026 12:15
@pelikhan pelikhan merged commit ec4dcdc into main Feb 1, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/update-serena-usage-prompt branch February 1, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants