Skip to content

richizo/claude-memory-importer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

claude-memory-importer

Reads your AI conversation exports from other platforms, classifies each conversation into the most relevant Project you have on claude.ai, and generates an organized folder of Markdown files ready for manual upload.

Works with exports produced by ai-chat-exporter — a browser automation tool that exports your full chat history from Perplexity, Grok, ChatGPT, and Qwen into structured JSON files.

How it works

  1. Reads one or more JSON files from ai-chat-exporter.
  2. You provide the names of your existing claude.ai Projects (via flag, file, or interactive prompt).
  3. All conversations are sent in batches to an LLM, which assigns each one to the best matching project — or to General if none fits.
  4. Conversations are formatted as Markdown files and written to an output folder, one subfolder per project, one file per platform.
  5. You upload each subfolder's contents to the corresponding Project's knowledge base on claude.ai.

Requirements

  • Python ≥ 3.11
  • uv
  • An API key for the LLM provider you want to use for classification

Installation

git clone https://github.com/richizo/claude-memory-importer
cd claude-memory-importer
uv sync

Usage

# Pass your project names directly
uv run memory-import export/ --projects "Work,Dev,Personal,Research"

# Load project names from a file (one per line)
uv run memory-import export/ --projects-file my-projects.txt

# Interactive prompt if no projects are given
uv run memory-import export/

# Custom output directory
uv run memory-import export/ --projects "Work,Dev" --output-dir ~/Desktop/claude-upload

# Custom general project name
uv run memory-import export/ --projects "Work,Dev" --general-project "Geral"

# Use a different LLM provider
uv run memory-import export/ --projects "Work,Dev" --model gpt-4o-mini

# Preview classification without writing any files
uv run memory-import export/ --projects "Work,Dev" --dry-run

Options

Option Default Description
--projects, -p Project names, comma-separated. Prompted interactively if omitted.
--projects-file Text file with one project name per line.
--output-dir, -o ./claude-import Output directory for the generated Markdown files.
--general-project General Project name for conversations that don't fit anywhere.
--model, -m claude-haiku-4-5-20251001 LLM model for classification. Supports any litellm-compatible provider.
--skip-short 2 Skip conversations with fewer than N turns.
--dry-run off Classify and show assignments without writing any files.
--verbose, -v off Enable DEBUG logging.

LLM providers for classification

Classification uses litellm, which supports any major provider. Set the corresponding environment variable.

Provider --model example Environment variable
Anthropic claude-haiku-4-5-20251001 ANTHROPIC_API_KEY
OpenAI gpt-4o-mini OPENAI_API_KEY
AWS Bedrock bedrock/anthropic.claude-3-haiku-20240307-v1:0 AWS credentials
Google Gemini gemini/gemini-1.5-flash GEMINI_API_KEY
Azure OpenAI azure/gpt-4o AZURE_API_KEY + AZURE_API_BASE

Output structure

One subfolder per project, one Markdown file per platform inside each subfolder:

claude-import/
├── Work/
│   ├── perplexity.md    ← all Perplexity conversations assigned to Work
│   └── chatgpt.md
├── Dev/
│   ├── grok.md
│   └── perplexity.md
└── General/
    ├── chatgpt.md
    └── qwen.md

Each file contains all assigned conversations formatted as readable Markdown:

# Perplexity — Conversations imported to Dev

Total: 8 conversation(s)

## How to use uv with pyproject.toml

- **Date:** 2024-12-01T10:00:00Z
- **URL:** https://perplexity.ai/...

---

**User**

How do I add a dependency with uv?

**Assistant**

Use `uv add <package>` ...

Uploading to claude.ai

After running the tool, open each project on claude.ai and add the files from the corresponding subfolder to the Project knowledge base:

  1. Open the project on claude.ai.
  2. Click Add content in the Project knowledge section.
  3. Upload the .md file(s) from the matching subfolder.

Repeat for each project. The General folder goes to your catch-all project.

Export format compatibility

This tool reads the ExportOutput schema produced by ai-chat-exporter:

{
  "exported_at": "2025-01-01T00:00:00Z",
  "platform": "perplexity",
  "total_exported": 42,
  "conversations": [
    {
      "id": "abc123",
      "title": "How to configure uv",
      "url": "https://perplexity.ai/...",
      "created_at": "2024-12-01T10:00:00Z",
      "turns": [
        { "role": "user",      "content": "..." },
        { "role": "assistant", "content": "..." }
      ],
      "sources": [
        { "url": "https://docs.astral.sh/uv/", "title": "uv Documentation" }
      ]
    }
  ]
}

Project structure

claude-memory-importer/
├── pyproject.toml
├── src/claude_memory_importer/
│   ├── models.py      — TypedDict schemas and ImportConfig dataclass
│   ├── reader.py      — JSON loading, validation, conversation serialization
│   ├── formatter.py   — Conversation → Markdown (one file per platform per project)
│   ├── classifier.py  — LLM-based project classification via litellm
│   ├── display.py     — Terminal UI (Rich)
│   └── cli.py         — CLI entry point (Typer)
└── tests/
    ├── test_reader.py
    ├── test_formatter.py
    └── test_classifier.py

Development

uv sync

# Lint
uv run ruff check src/ tests/

# Format
uv run ruff format src/ tests/

# Tests (no network calls — LLM is mocked)
uv run pytest -v

Test coverage

Module Tests
reader.py JSON loading, field validation, file collection, text serialization, truncation
formatter.py Filename sanitization, platform grouping, Markdown content, multi-project, file size limits
classifier.py JSON parsing (raw + fenced), user message content, project assignment, unknown project fallback, API errors, missing IDs, custom general name, model passthrough

Related

  • ai-chat-exporter — exports your full chat history from Perplexity, Grok, ChatGPT, and Qwen to the JSON format this tool reads.

License

MIT

About

Reads your AI conversation exports from other platforms, classifies each conversation into the most relevant Project you have on claude.ai, and generates an organized folder of Markdown files ready for manual upload.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages