# Conversation Export Guide

Export your Claude.ai conversations with full crash recovery and date filtering.

## Prerequisites

### 1. Install Playwright Browsers (one-time)
```powershell
cd "D:/Project Mind/project-mind-mcp"
npx playwright install chromium
```

### 2. Export Session Cookies from Browser

**Chrome:**
1. Go to `claude.ai` and log in
2. Open DevTools (F12) → Application → Cookies
3. Install "EditThisCookie" extension or use this console command:
```javascript
// In DevTools Console on claude.ai
JSON.stringify(
  document.cookie.split(';').map(c => {
    const [name, value] = c.trim().split('=');
    return { name, value, domain: '.claude.ai', path: '/' };
  })
);
```
4. Copy the output and save to `D:/claude-cookies.json`

**Alternative: Use a cookie export extension:**
- "Cookie Editor" (Chrome/Firefox)
- Export as JSON format
- Save to `D:/claude-cookies.json`

## Usage

### Preview Conversations (Recommended First Step)
```
Tool: preview_conversations
Input: {
  "cookiesFile": "D:/claude-cookies.json",
  "dateFilter": {
    "after": "2024-01-01"  // Only show chats after this date
  },
  "limit": 50
}
```

Returns: Total count, project breakdown, date range.

### Export All Conversations
```
Tool: export_conversations
Input: {
  "cookiesFile": "D:/claude-cookies.json",
  "outputPath": "D:/claude-archive/conversations",
  "dateFilter": {
    "after": "2024-01-01",    // Optional: Only after this date
    "before": "2025-01-01"    // Optional: Only before this date
  },
  "format": "json-compressed"  // Options: json, json-compressed, split-by-project
}
```

### Monitor Progress
```
Tool: get_export_progress
Input: {
  "jobId": 1  // From export_conversations response
}
```

### Resume After Crash
If the export is interrupted:
```
Tool: resume_export
Input: {
  "checkpointFile": "D:/claude-archive/checkpoint.json"
}
```

## Date Filtering

| Filter | Effect |
|--------|--------|
| `after: "2024-06-01"` | Only conversations updated/created after June 1, 2024 |
| `before: "2024-12-31"` | Only conversations updated/created before Dec 31, 2024 |
| Both | Conversations within the date range |
| Neither | All conversations |

## Output Formats

### `json` - Single JSON file
```
D:/claude-archive/
└── conversations.json     # ~5MB per 100 conversations
```

### `json-compressed` (Recommended)
```
D:/claude-archive/
└── conversations.json.gz  # 80-90% smaller than raw JSON
```

### `split-by-project`
```
D:/claude-archive/
├── manifest.json
├── project-mind.json.gz
├── gregore.json.gz
└── __general__.json.gz    # Non-project conversations
```

## Output Schema

```typescript
interface ConversationArchive {
  exportedAt: string;
  source: "claude";
  stats: {
    totalConversations: number;
    totalMessages: number;
    dateRange: { earliest: string; latest: string };
    byProject: Record<string, number>;
  };
  conversations: Conversation[];
}

interface Conversation {
  id: string;
  title: string;
  createdAt: string;
  updatedAt: string;
  project?: { id: string; name: string };
  messageCount: number;
  messages: Message[];
}

interface Message {
  id: string;
  role: "user" | "assistant";
  content: string;  // Full text, unchanged
  timestamp?: string;
  artifacts?: Artifact[];
}
```

## Troubleshooting

### "Authentication failed"
- Cookies may have expired. Export fresh cookies from browser.
- Make sure you're logged into claude.ai in the browser.

### Export is slow
- Normal! We're being respectful to servers with 1.5s delay between requests.
- ~2000 conversations ≈ 1 hour

### Browser opens but nothing happens
- Check if chromium was installed: `npx playwright install chromium`
- Try `"headless": false` to watch what's happening

## Future: GPT Export

The architecture supports adding GPT export. Stay tuned for:
```
Tool: export_conversations
Input: {
  "source": "chatgpt",  // Coming soon
  ...
}
```
