Extract: Mining AI Insights from Chat Logs with MCP-Powered Analysis

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

  1. 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).
  2. Define Memory Folders: The prompt specifies the target directories where notes should be stored (e.g., memories/plans/, memories/knowledge/).
  3. Invoke the Extractor: In a new chat, you reference the extractor prompt and the target conversation log you want to process.
  4. Agent Executes: The AI agent reads the conversation, identifies relevant content, and uses tools like write_note and search_notes to persist the information into the correct folders. It also attempts to update existing notes to avoid duplication.
  5. Build the Knowledge Base: Repeat this process for any significant conversation to continuously build your project's memory.
  6. 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

Please use basic memory to summarize some of the issues I've had with TypeScript, and I think there were some server errors in there or something.

Key Prompts and Invocations

The core of this workflow is the "extractor" prompt, which defines the task for the AI agent.

# Extract Conversation into memories/ using Basic Memory MCP ## Goal Extract important information from a referenced conversation into the following folders using the available tools: ### Folders - `plans` - action plans, roadmaps, to-do lists - `knowledge` - stable reference facts, policies, domain docs - `decisions` - architecture / product choices & rationale - `lessons_learned` - retrospectives, what-went-well, mistakes to avoid ### Tasks 1. **Scan the `conversation_log`** for the following: - `#Plans` - any clearly stated tasks, next steps, or roadmaps - `#Knowledge` - stable facts, policies, formulas, specs - `#Decisions` - explicit choices made and their justification - `#Lessons Learned` - mistakes, insights, or heuristics expressed 2. **For each extracted item:** - Choose a clear, concise `title`. - Run `write_note` with the `folder` set to the target directory. 3. **Link and relate:** - Use wiki links (`[[Other Note]]`) to connect to existing notes when relevant. 4. **Verify and report:** - After all writes/edits, call `sync_status()` to confirm memory health. - Provide a summary list of the notes you created or updated.

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.

@extract-conversation.md <conversation> @script-generator-2025-05-29-09-37-troubleshooting-server-errors-and-api-issues.md </conversation>
Create an AI-Automated MCP-Driven Markdown Knowledge Base
Lesson 3 of 10

Create an AI-Automated MCP-Driven Markdown Knowledge Base

Share with a coworker

Transcript

[00:00] Now that we have our long conversation saved, let's use a prompt to extract information from the conversation into various folders in our memory. So this prompt defines the folders to use, lists out all of the MCP tools available through basic memory, and tells it to take that conversation and essentially break it down into these various notes. So if I reference extract conversation, and then I like to add a XML tag like this, conversation, and then add the conversation I'm targeting, and then close the tag, just to help the agent know where the conversation starts and ends, and we'll send it, sit back, let the agent call the MCP and read through the conversation and start reading and generating notes. And this will search through existing notes as well to attempt to update them if we already have information on this. So you'll see it read the main conversation, it's searching notes for existing related data, and it's writing out some relevant notes around knowledge, plans, more plans, and lessons learned.

[01:02] So if we check in on some of these, and you'll see a summary of what it did below, which you can read through and validate. But if we check in our lessons learned, you'll see some specific information around releases, and how it's handling JSON files, and our knowledge. You'll see it's discussing some of the errors that were caught. And then in our plans, this is an older plan from this project, so these are all things I've already handled, but these are definitely plans that I would have looked into based on that conversation. And now we can continue to build up our knowledge base.

[01:35] So if we just extract another conversation with select, let's go back in time a little bit. We'll check on this cleanup TypeScript errors and bring this conversation in, drop that in there, then start a new conversation where we reference our extractor. We toss in our conversation, then we'll just toss in our markdown, close this off, let this run, and it will go ahead and pull information out of that conversation as well. So this one added TypeScript errors to our knowledge and lessons learned for TypeScript. So essentially now, based on those two conversations, if we start a new conversation, we can ask questions like, please use basic memory to summarize some of the issues I've had with TypeScript and I think there were some server errors in there or something.

[02:20] Now if you just remember like the general concept of something that went wrong in the past that you want to avoid when you're working with the agent now, you can start by bringing in this as an initial query or initial prompt, so that when you tell your agent to start working on these things, it will avoid them as it's going through these steps.