AI chat logs are a goldmine of project context, decisions, and hard-won lessons. But this knowledge is often ephemeral, lost in the scrollback. This lesson demonstrates a powerful workflow to automatically extract and structure this information into a persistent, queryable knowledge base directly within your project.
By using a custom "extractor" prompt, you can teach an AI agent to read your conversations and organize the key takeaways into structured notes for plans, knowledge, decisions, and lessons_learned. This turns your chat history from a fleeting record into a lasting asset, ensuring you never lose valuable insights and can bootstrap future AI tasks with a rich, historical context.
The Problem: Transient AI Knowledge
- Valuable insights, architectural decisions, and solutions to problems are generated during AI conversations.
 - This knowledge is typically trapped in chat history, making it difficult to find and reuse later.
 - Without a system, you and your AI agent are prone to repeating past mistakes or re-solving the same problems.
 
The Solution: Automated Knowledge Extraction
This workflow uses a master prompt to instruct an AI agent to act as a "knowledge extractor." The agent systematically reads a conversation transcript, identifies important information, and uses tools to create or update structured markdown files within a dedicated memories directory.
How It Works
- Create an Extractor Prompt: A detailed markdown file (
extract-conversation.md) instructs the agent on its goal: to scan a conversation for specific categories of information (plans, knowledge, decisions, lessons learned). - Define Memory Folders: The prompt specifies the target directories where notes should be stored (e.g., 
memories/plans/,memories/knowledge/). - Invoke the Extractor: In a new chat, you reference the extractor prompt and the target conversation log you want to process.
 - Agent Executes: The AI agent reads the conversation, identifies relevant content, and uses tools like 
write_noteandsearch_notesto persist the information into the correct folders. It also attempts to update existing notes to avoid duplication. - Build the Knowledge Base: Repeat this process for any significant conversation to continuously build your project's memory.
 - Query the Knowledge: In future sessions, you can ask the agent questions that leverage this accumulated knowledge, allowing it to provide summaries of past issues, recall previous solutions, and make more informed decisions.
 
Key Benefits
- Persistent Memory: Create a lasting, structured record of your project's evolution.
 - Avoid Repeating Mistakes: Easily reference "lessons learned" to guide future development.
 - Improved Context: Bootstrap new AI tasks with a rich foundation of historical knowledge and decisions.
 - Efficient Knowledge Retrieval: Quickly query your project's memory instead of manually searching through old chat logs.
 
Spoken Prompts
Key Prompts and Invocations
The core of this workflow is the "extractor" prompt, which defines the task for the AI agent.
To run the extraction process, you reference the extractor prompt and the target conversation in the chat input. Using XML tags helps the agent clearly identify the conversation file.