name: build-knowledge description: "Build and manage a persistent knowledge base (second brain) using Markdown files. Use when you need to store, retrieve, or link complex concepts, project context, or 'remember' information across sessions. Triggers on: (1) 'Remember this', (2) 'Build a knowledge base', (3) 'Document this concept', (4) Summarizing findings into long-term memory."
Build Knowledge
You are the curator of a persistent knowledge base stored in .agent_memory. Your goal is to create a densely linked "second brain" that avoids information silos.
Core Principles
- The Golden Rule of Linking: NEVER create orphaned files. Every new note MUST be linked from at least one other note (usually
000_Index.mdor a related topic). - Search Before Write: Always search for existing topics before creating a new node to prevent duplication.
- Wikilinks: Use
[[Note_Name]]for internal links.
Librarian Tool (Scripts)
Use the Librarian script via uv to manage the knowledge base.
1. Search for existing knowledge
Finds files containing specific keywords using case-insensitive grep and synonym expansion.
uv run python .agent/skills/build-knowledge/scripts/librarian.py search --keywords "keyword1" "keyword2"
2. Read a note
Retrieves the full content of a specific note.
uv run python .agent/skills/build-knowledge/scripts/librarian.py read --filename "Note_Name.md"
3. Create a new note
Stores new information. Fails if the file already exists.
uv run python .agent/skills/build-knowledge/scripts/librarian.py create --filename "Note_Name.md" --content "# Title\nContent here..."
4. Append to a note
Adds details to an existing topic.
uv run python .agent/skills/build-knowledge/scripts/librarian.py append --filename "Note_Name.md" --content "Additional info..."
Dual-Write Protocol (Graph Sync)
To ensure the Agent's "active memory" matches the "archived memory", you MUST synchronize key concepts to the MCP Graph Memory if the tools are available.
Triggers:
- Creating a Note -> Create a corresponding Entity.
- Linking Notes -> Create a corresponding Relation.
Procedure:
- Check if
mcp_memory_create_entitiesis available. - Files First: Execute the
librarian.pyfile operations as usual. - Graph Second:
- Create an Entity for the main topic (Name = Note Title, Type = Concept/Topic).
- Add an Observation summarizing the content (approx. 1 sentence).
- Create Relations linking it to other entities (e.g.,
NewTopicrelates_toIndex).
Standard Workflow
- Analyze: User says "Remember X".
- Search:
search --keywords "X"to check for existing context. - Branching Logic:
- If exists:
readit, thenappendnew info. Update Graph with new Observation. - If new:
createthe node. Create Entity in Graph.
- If exists:
- Link:
readthe parent/index note andappenda link[[X]]to ensure discovery. Create Relation in Graph. - Confirm: Tell the user where the knowledge is stored (File + Graph).
Troubleshooting & Setup
If using for the first time or if the script fails due to missing dependencies, see references/setup.md.