Package Exports
- claude-code-exporter
- claude-code-exporter/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (claude-code-exporter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Claude Code Exporter
Export your Claude Code session prompts to markdown files for documentation, analysis, and archival purposes.
🚀 Features
- Extract User Prompts: Automatically extracts all user prompts from Claude Code sessions
- Markdown Export: Generates clean, readable markdown files for each session
- Smart Filtering: Excludes system-generated messages and command outputs
- Flexible Path Detection: Automatically finds Claude sessions for your projects
- CLI & API: Use as a command-line tool or integrate into your Node.js applications
- Cross-Platform: Works on macOS, Linux, and Windows
📋 Table of Contents
- Installation
- Quick Start
- Usage
- Output Format
- Examples
- Configuration
- Troubleshooting
- Contributing
- License
🔧 Installation
Global Installation (Recommended)
npm install -g claude-code-exporterLocal Installation
npm install claude-code-exporterUsing npx (No Installation)
npx claude-code-exporter /path/to/project🎯 Quick Start
Export prompts from your current project:
claude-promptsExport prompts from a specific project:
claude-prompts /path/to/your/project📖 Usage
Command Line Interface
claude-prompts [options] [project-path] [output-dir]Arguments
project-path- Path to your project (default: current directory)output-dir- Output directory for markdown files (default:./claude-prompts)
Options
-h, --help- Show help message-v, --version- Show version number-V, --verbose- Enable verbose output for debugging--list- List available sessions without exporting
Examples
# Export from current directory
claude-prompts
# Export from specific project
claude-prompts /Users/username/my-project
# Export to custom directory
claude-prompts /Users/username/my-project ./my-exports
# List sessions without exporting
claude-prompts --list /Users/username/my-project
# Enable verbose mode for debugging
claude-prompts -V /Users/username/my-projectProgrammatic API
const ClaudePromptExporter = require('claude-code-exporter');
// Create exporter instance
const exporter = new ClaudePromptExporter('/path/to/project', {
verbose: true // Optional: enable debug output
});
// Export to markdown files
const result = exporter.exportToMarkdown('./output-directory');
console.log(`Exported ${result.sessionsExported} sessions`);
// Or just extract prompts without exporting
const sessions = exporter.extractPrompts();
sessions.forEach(({ sessionId, prompts }) => {
console.log(`Session ${sessionId}: ${prompts.length} prompts`);
});📄 Output Format
Each exported markdown file follows this structure:
# Claude Code Session Export
## Session Information
- **Session ID**: `2ead3268-3c7c-48ab-b46b-8b7a706d097c`
- **Total Prompts**: 7
- **First Prompt**: 12/25/2024, 10:30:45 AM
- **Last Prompt**: 12/25/2024, 11:45:23 AM
- **Project Path**: `/Users/username/my-project`
---
## Prompt 1
> 12/25/2024, 10:30:45 AM
Create a REST API with Express.js for a todo application
---
## Prompt 2
> 12/25/2024, 10:35:12 AM
Add authentication using JWT tokens
File Naming Convention
Files are named using the pattern: {session-id}-{title}.md
session-id: Unique identifier for the Claude sessiontitle: Generated from the first few words of the initial prompt
Example: 2ead3268-3c7c-48ab-b46b-8b7a706d097c-create-rest-api-with.md
🔍 Examples
Example 1: Documenting Project Development
Export all prompts from your project development:
claude-prompts ~/projects/my-app ./documentation/claude-sessionsExample 2: Creating a Learning Archive
Archive your Claude Code learning sessions:
claude-prompts ~/learning/javascript ./learning-archiveExample 3: Batch Processing Multiple Projects
const ClaudePromptExporter = require('claude-code-exporter');
const projects = [
'/Users/me/project1',
'/Users/me/project2',
'/Users/me/project3'
];
projects.forEach(projectPath => {
try {
const exporter = new ClaudePromptExporter(projectPath);
const outputDir = `./exports/${path.basename(projectPath)}`;
exporter.exportToMarkdown(outputDir);
} catch (error) {
console.error(`Failed to export ${projectPath}: ${error.message}`);
}
});⚙️ Configuration
Requirements
- Node.js: Version 14.0.0 or higher
- Claude Code: Must be installed with sessions stored in
~/.claude/projects/ - Operating System: macOS, Linux, or Windows
Environment Variables
The exporter uses standard environment variables:
HOME(macOS/Linux) orUSERPROFILE(Windows) - Used to locate the Claude home directory
🔧 Troubleshooting
Common Issues
"No Claude sessions found for project"
Cause: The project path doesn't match any Claude Code sessions.
Solution:
- Verify the project path is correct
- Ensure you have Claude Code sessions for this project
- Check that sessions exist in
~/.claude/projects/ - Use
--verboseflag for detailed debugging output
"Claude home directory not found"
Cause: Claude Code is not installed or not in the expected location.
Solution:
- Install Claude Code from claude.ai
- Verify
~/.claude/directory exists - Check environment variables
HOMEorUSERPROFILE
Empty or Missing Prompts
Cause: Sessions may contain only system messages or commands.
Solution:
- The exporter automatically filters system-generated content
- Verify your sessions contain actual user prompts
- Use
--listto preview available sessions
Debug Mode
Enable verbose output for troubleshooting:
claude-prompts --verbose /path/to/projectThis will show:
- Path encoding details
- Session discovery process
- Message filtering information
- Processing statistics
🤝 Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Setup
# Clone the repository
git clone https://github.com/yourusername/claude-code-exporter.git
cd claude-code-exporter
# Install dependencies
npm install
# Run tests
npm test
# Test CLI locally
./bin/claude-prompts /path/to/test/projectCode Style
- Use 2 spaces for indentation
- Follow Node.js best practices
- Add JSDoc comments for public methods
- Ensure all tests pass before submitting PR
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built for the Claude Code community
- Inspired by the need to document AI-assisted development
- Thanks to all contributors and users
📚 Resources
Made with ❤️ for developers