Skip to content

πŸ” Extract and analyze your Claude Code conversation history to discover usage patterns, generate insights, and create custom slash commands from your prompting style.

License

Notifications You must be signed in to change notification settings

levindixon/claude-code-prompt-plunderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Claude Code Prompt Plunderer

A Python utility that extracts and analyzes user prompts from Claude Code conversation history. This tool helps you understand your Claude Code usage patterns by collecting prompts from the locally stored conversation logs and presenting them in both JSON and Markdown formats.

Features

  • πŸ” Prompt Extraction: Automatically discovers and extracts user prompts from Claude Code JSONL conversation files
  • πŸ“Š Smart Filtering: Filter prompts by character length to focus on meaningful interactions
  • πŸ”„ Deduplication: Identifies repeated prompts and tracks usage frequency
  • πŸ“ˆ Statistical Analysis: Provides insights into prompt length distribution and usage patterns
  • πŸ“ Multiple Output Formats: Generates both JSON (for programmatic use) and Markdown (for human reading)
  • 🏷️ Rich Metadata: Preserves timestamps, working directories, and session information

Use Cases

  • Command Automation: Analyze your most frequent prompts to create custom Claude Code commands
  • Usage Analysis: Understand your interaction patterns with Claude Code
  • Prompt Library: Build a personal library of effective prompts
  • Workflow Optimization: Identify repetitive tasks that could be automated
  • Learning Tool: Review past interactions to improve prompt engineering skills

Installation

No installation required! This is a standalone Python script that uses only Python standard library modules.

Requirements

  • Python 3.6 or higher
  • Access to Claude Code conversation files (typically in ~/.claude/projects)

Usage

Basic Usage

python3 plunder_prompts.py

This will:

  • Look for conversation files in the default location (~/.claude/projects)
  • Extract prompts between 140-280 characters (optimal for identifying meaningful commands)
  • Save results to extracted_prompts.json and extracted_prompts.md

Advanced Options

# Specify a custom conversation directory
python3 plunder_prompts.py --base-dir /path/to/claude/projects

# Adjust length filters for different use cases
python3 plunder_prompts.py --min-length 50 --max-length 500

# Save output to a specific location
python3 plunder_prompts.py --output ./analysis/my_prompts.json

# Combine options
python3 plunder_prompts.py --base-dir ~/backups/claude --min-length 100 --max-length 1000 --output ./prompts_analysis.json

Command Line Arguments

Argument Default Description
--base-dir ~/.claude/projects Directory containing Claude Code conversation folders
--min-length 140 Minimum character length for prompts to include
--max-length 280 Maximum character length for prompts to include
--output ./extracted_prompts.json Output file path (Markdown file will use same name with .md extension)

Output Format

JSON Output

The JSON file contains structured data perfect for programmatic analysis:

{
  "metadata": {
    "total_prompts": 150,
    "unique_prompts": 87,
    "extraction_date": "2024-01-15T10:30:00",
    "min_length_filter": 140,
    "max_length_filter": 280
  },
  "prompts": [
    {
      "id": 1,
      "text": "Create a Python function that validates email addresses",
      "count": 3,
      "length": 52,
      "first_timestamp": "2024-01-10T09:15:00",
      "last_timestamp": "2024-01-14T16:22:00",
      "working_directories": ["/home/user/project1", "/home/user/project2"]
    }
  ]
}

Markdown Output

The Markdown file provides a human-readable analysis including:

  • Summary statistics
  • Length distribution analysis
  • Top 10 most frequent prompts
  • Complete list of all unique prompts with metadata

Example Workflow

  1. Extract your prompts:

    python3 plunder_prompts.py --min-length 50 --max-length 300
  2. Review the Markdown output to understand your usage patterns:

    open extracted_prompts.md  # macOS
    # or
    xdg-open extracted_prompts.md  # Linux
  3. Use the JSON output for further analysis:

    import json
    
    with open('extracted_prompts.json', 'r') as f:
        data = json.load(f)
    
    # Find your most complex prompts
    complex_prompts = [p for p in data['prompts'] if p['length'] > 200]
    
    # Find prompts used in specific projects
    project_prompts = [p for p in data['prompts']
                       if '/myproject' in str(p['working_directories'])]

Privacy and Security

  • This tool only reads files from your local machine
  • No data is sent to external services
  • All processing happens locally on your computer
  • The tool respects file permissions and will skip files it cannot read

Example Prompts & Analysis Tools

The prompts/ directory contains ready-to-use prompt templates that analyze your extracted data in creative and insightful ways. Use them with Claude Code like this:

# First extract your prompts
python3 plunder_prompts.py

# Then use any analysis prompt
claude "$(cat ./prompts/style_tengu.md)"

Available Analysis Prompts

Analyzes your prompts to suggest custom Claude Code slash commands tailored to your workflow. Identifies repetitive patterns and generates ready-to-use command templates.

Creates a unique ASCII Tengu character representing your prompting personality. Includes stats, special moves, and evolution paths. Perfect for sharing in Slack!

Generates ASCII visualizations of your prompt patterns including category breakdowns, length distributions, and keyword clouds. Great for understanding your Claude Code usage at a glance.

Shows how your prompting style has evolved over time with an ASCII timeline. Tracks skill progression, project transitions, and identifies key growth moments.

Produces a comprehensive personality analysis based on your prompting patterns. Reveals hidden traits, communication style, and predicts your future evolution as a prompt engineer.

Future Ideas

While not implemented yet, here are some interesting extensions you could build:

  • Prompt Categorization: Use LLMs to categorize prompts by intent (debugging, refactoring, documentation, etc.)
  • Command Generation: Automatically generate Claude Code custom commands for frequent tasks
  • Time Analysis: Analyze prompt patterns over time to understand productivity trends
  • Project-specific Analysis: Group prompts by project to understand different coding contexts
  • Prompt Templates: Extract and generalize prompts into reusable templates

Contributing

Feel free to fork this repository and adapt the tool to your needs! Some ideas for contributions:

  • Add support for additional filtering options
  • Implement prompt categorization
  • Create visualization tools for the extracted data
  • Add export formats (CSV, SQLite, etc.)

License

MIT License - See LICENSE file for details

Acknowledgments

Created for the Claude Code community to help users better understand and optimize their AI-assisted coding workflows.

About

πŸ” Extract and analyze your Claude Code conversation history to discover usage patterns, generate insights, and create custom slash commands from your prompting style.

Topics

Resources

License

Stars

Watchers

Forks

Languages