Lesson

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

Learn a powerful workflow to automatically extract and structure information from AI chat logs into a persistent, queryable knowledge base using an "extractor"

Access
Included
Transcript
Needs source

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>