๐Ÿ” Claude Sanitizer

AI-powered intelligent data sanitization - Uses Claude to detect and redact sensitive information while preserving training value.

๐ŸŒŸ Why Claude Sanitizer?

The Problem: Regex patterns can miss context-dependent sensitive data and might over-redact, removing valuable training information.

The Solution: Use Claude's AI to intelligently understand what's truly sensitive vs. what's important training context.

โœจ Features

๐Ÿง  Intelligent Detection:

  • Uses Claude (Haiku or Sonnet) to analyze conversations
  • Understands context (e.g., "password" in code vs. actual password)
  • Detects hidden patterns that regex might miss
  • Preserves training value while removing risks

๐ŸŽฏ Smart Pre-Screening:

  • Only checks entries with sensitive keywords
  • Optional aggressive mode checks everything
  • Cost-effective with Haiku model
  • Detailed reporting of all redactions

๐Ÿ”’ Comprehensive Protection:

  • API keys and tokens (all major platforms)
  • Crypto assets (seed phrases, keys, addresses)
  • Financial data (credit cards, SSN)
  • Personal information (emails, phones)
  • Authentication credentials (passwords, keys)

๐Ÿ’Ž Preserves Training Value:

  • Keeps file paths (structure important for context)
  • Keeps function/class names (code patterns)
  • Keeps error messages (debugging patterns)
  • Keeps tool names and commands
  • Only redacts truly sensitive data

๐Ÿš€ Quick Start

Installation

# Using uvx (no install)
uvx claude-sanitizer my-data.jsonl

# Or install globally
uv tool install claude-sanitizer
claude-sanitizer my-data.jsonl

# Or with pip
pip install claude-sanitizer
claude-sanitizer my-data.jsonl

Set API Key

export ANTHROPIC_API_KEY=sk-ant-...

Basic Usage

# Smart mode (pre-screened, cost-effective)
claude-sanitizer my-data.jsonl

# Aggressive mode (check everything, more thorough)
claude-sanitizer my-data.jsonl --aggressive

# Use Sonnet for better accuracy (more expensive)
claude-sanitizer my-data.jsonl --model sonnet

# Dry run (see what would be redacted)
claude-sanitizer my-data.jsonl --dry-run --report report.json

# Custom output
claude-sanitizer my-data.jsonl --output clean-data.jsonl

๐Ÿ’ก How It Works

1. Pre-Screening (Smart Mode)

Scan for keywords:
โ”œโ”€ password, secret, api_key, token
โ”œโ”€ wallet, seed, mnemonic, private_key
โ”œโ”€ credit_card, ssn, bitcoin, ethereum
โ””โ”€ Only check entries with these keywords

2. AI Analysis

Claude analyzes each flagged entry:
โ”œโ”€ Detects: API keys, passwords, crypto data, PII
โ”œโ”€ Preserves: File paths, function names, errors
โ”œโ”€ Returns: Specific redactions with reasons
โ””โ”€ Severity: High/Medium/Low

3. Intelligent Redaction

Apply specific placeholders:
โ”œโ”€ API keys โ†’ [API_KEY]
โ”œโ”€ Seed phrases โ†’ [SEED_PHRASE]
โ”œโ”€ Credit cards โ†’ [CREDIT_CARD]
โ”œโ”€ Emails โ†’ [EMAIL]
โ””โ”€ Preserve everything else

๐Ÿ“Š Example Output

๐Ÿ” Claude Sanitizer v0.1.0
AI-powered intelligent data sanitization

Model: claude-3-5-haiku-20241022
Mode: Smart (pre-screened)

โœ“ Loaded 10,000 entries

Sanitizing... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 100%

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Sanitization Results                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Total entries       โ”‚ 10,000            โ”‚
โ”‚ Entries checked     โ”‚ 342               โ”‚
โ”‚ With sensitive data โ”‚ 47                โ”‚
โ”‚ Total redactions    โ”‚ 89                โ”‚
โ”‚ Estimated cost      โ”‚ $0.0043           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Sample Redactions:

  โ— [API_KEY]: GitHub personal access token detected
  โ— [SEED_PHRASE]: BIP39 mnemonic seed phrase (12 words)
  โ— [AWS_SECRET]: AWS secret access key

โœ… Sanitized data saved: my-data_sanitized.jsonl
โœ… Report saved: my-data_report.json

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚            โœจ Sanitization complete!           โ”‚
โ”‚                                                โ”‚
โ”‚ Your data is now safe for contribution while  โ”‚
โ”‚ preserving maximum training value for agentic โ”‚
โ”‚ AI development.                                โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

๐Ÿ’ฐ Cost Estimates

Haiku (Default) - Fast & Affordable:

  • $0.25 per 1M input tokens
  • ~$0.0043 per 10K entries (342 checked)
  • Recommended for most use cases

Sonnet - Maximum Accuracy:

  • $3 per 1M input tokens
  • ~$0.0516 per 10K entries (342 checked)
  • Use for high-sensitivity data

๐Ÿ”„ Workflow Integration

Complete Pipeline

# 1. Extract with claude-collector
uvx claude-collector --output raw-data.jsonl

# 2. Basic sanitization (fast, regex-based)
# Already done by claude-collector

# 3. AI sanitization (intelligent, context-aware)
uvx claude-sanitizer raw-data.jsonl

# 4. Result: raw-data_sanitized.jsonl
# Ready for contribution!

With Zen Agentic Dataset

# Extract and sanitize
uvx claude-collector --output my-data.jsonl
uvx claude-sanitizer my-data.jsonl --aggressive

# Add to dataset
cp my-data_sanitized.jsonl ~/zen-agentic-dataset/data/USERNAME/training/

# Commit and PR
cd ~/zen-agentic-dataset
git add data/USERNAME/
git commit -m "Add sanitized agentic data"
git push

๐Ÿ“‹ What Gets Redacted

๐Ÿ” API Keys & Tokens:

  • โœ… All major platforms (30+ formats)
  • โœ… OAuth tokens, JWT
  • โœ… AWS credentials

๐Ÿ’ฐ Financial & Crypto:

  • โœ… Seed phrases (BIP39 detected)
  • โœ… Private keys (hex, PEM)
  • โœ… Crypto addresses (ETH, BTC)
  • โœ… Credit cards, SSN

๐Ÿ”‘ Authentication:

  • โœ… Passwords in any context
  • โœ… Database connection strings
  • โœ… Private keys

๐Ÿ‘ค Personal Data:

  • โœ… Email addresses
  • โœ… Phone numbers
  • โœ… Physical addresses

โœ… What Gets Preserved

Important for Training:

  • โœ… File paths (structure matters)
  • โœ… Function/class names
  • โœ… Error messages
  • โœ… Tool names (Read, Write, Bash)
  • โœ… Programming concepts
  • โœ… Generic emails (support@, info@)
  • โœ… Repository names

๐ŸŽฏ Use Cases

Perfect For:

  • ๐ŸŒ Web3/Crypto project contributors
  • ๐Ÿ’ณ E-commerce/Payment developers
  • ๐Ÿข Enterprise application teams
  • โ˜๏ธ Cloud infrastructure developers
  • ๐Ÿ”’ Security-conscious contributors

Scenarios:

  • Sharing Claude Code sessions from work
  • Contributing from crypto/blockchain projects
  • Datasets with payment integrations
  • Any high-sensitivity development data

๐Ÿ”ฌ Advanced Options

# Check everything (most thorough)
claude-sanitizer data.jsonl --aggressive --model sonnet

# Dry run with detailed report
claude-sanitizer data.jsonl --dry-run --report analysis.json

# Custom output location
claude-sanitizer data.jsonl --output ~/safe/data.jsonl --report ~/safe/report.json

# Different models
claude-sanitizer data.jsonl --model haiku  # Fast, cheap
claude-sanitizer data.jsonl --model sonnet # Thorough, accurate

๐Ÿ›ก๏ธ Security Guarantees

Multi-Layer Protection:

  1. Regex patterns (claude-collector) - Fast, catches obvious patterns
  2. AI analysis (claude-sanitizer) - Context-aware, catches hidden patterns
  3. Human review (optional) - Final check before contribution

Result: Maximum safety with preserved training value

๐Ÿ“Š Report Format

The --report flag generates a detailed JSON report:

{
  "stats": {
    "total": 10000,
    "checked": 342,
    "has_sensitive": 47,
    "redactions": 89,
    "cost_estimate": 0.0043
  },
  "redactions": [
    {
      "entry_index": 42,
      "analysis": {
        "has_sensitive_data": true,
        "redactions": [
          {
            "original": "sk-ant-abc123...",
            "replacement": "[ANTHROPIC_API_KEY]",
            "reason": "Anthropic API key detected in configuration",
            "severity": "high"
          }
        ],
        "summary": "Found 1 high-severity credential"
      }
    }
  ],
  "timestamp": "2025-11-14T01:30:00Z"
}

๐Ÿค Contributing

This tool is part of the Zen Agentic Dataset ecosystem:

๐Ÿ“œ License

MIT License - Free for any purpose

๐Ÿ™ Credits

Built by Hanzo AI for the AI development community.


Safe contribution starts with intelligent sanitization ๐Ÿ”โœจ

S
Description
AI-powered intelligent sanitization tool using Claude for safe dataset contribution
Readme
78 KiB
Languages
Python 100%