Co-authored-by: Hanzo Dev <[email protected]>
๐ 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:
- Regex patterns (claude-collector) - Fast, catches obvious patterns
- AI analysis (claude-sanitizer) - Context-aware, catches hidden patterns
- 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:
- Dataset: https://github.com/zenlm/zen-agentic-dataset
- Collector: https://github.com/hanzoai/claude-collector
- Sanitizer: https://github.com/hanzoai/claude-sanitizer
๐ License
MIT License - Free for any purpose
๐ Credits
Built by Hanzo AI for the AI development community.
Safe contribution starts with intelligent sanitization ๐โจ