AgentSkillsCN

serena-memory

当用户请求“保存项目上下文”、“加载记忆”、“持久化知识”、“为下次会话记住这些”、“更新架构笔记”,或提及 Serena 的 write_memory、read_memory、list_memories、edit_memory 等工具时,可使用此技能。

SKILL.md
--- frontmatter
name: serena-memory
description: |
  This skill should be used when the user asks to "save project context",
  "load memories", "persist knowledge", "remember this for next session",
  "update architecture notes", or mentions Serena's write_memory, read_memory,
  list_memories, edit_memory tools.

Serena Memory Management

Memory Operations

OperationTool
Save knowledgewrite_memory(key, content)
Update existingedit_memory(key, content)
Load knowledgeread_memory(key)
List alllist_memories()
Removedelete_memory(key)

Recommended Memory Keys

KeyPurpose
architecture_overviewSystem architecture
code_conventionsCoding standards
recent_changesLatest commits
known_issuesBugs and workarounds
test_patternsTesting conventions
session_contextCurrent task (preserved during compaction)

When to Update Memories

  1. After exploration: Save architectural insights
  2. After debugging: Document root causes and fixes
  3. After refactoring: Record successful patterns
  4. Before compaction: Preserve current task context
  5. After commits: Summarize significant changes

Example: Architecture Memory

code
write_memory(
  key="architecture_overview",
  content="""
# Project Architecture

## Layers
- API: FastAPI routes in src/api/
- Services: Business logic in src/services/
- Models: SQLAlchemy models in src/models/

## Key Patterns
- Dependency injection via FastAPI Depends
- Repository pattern for data access

## Entry Points
- Main app: src/main.py
- CLI: src/cli.py
"""
)

Example: Code Conventions Memory

code
write_memory(
  key="code_conventions",
  content="""
# Code Conventions

- snake_case for functions/variables
- PascalCase for classes
- Type hints required for public functions
- Docstrings in Google style
- Tests in tests/ mirror src/ structure
"""
)