[FEATURE] User-Defined Input Preprocessing Hook

Resolved 💬 4 comments Opened Nov 13, 2025 by PeterHeick Closed Jan 13, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Users may need to transform, filter, or sanitize their input before it's sent to Claude Code. Common scenarios include:
Privacy: Anonymizing sensitive data (emails, hostnames, tokens)
Compliance: Redacting PII to meet GDPR/privacy requirements
Formatting: Standardizing input format (e.g., converting logs to structured data)
Custom workflows: Company-specific preprocessing needs
Currently, there's no mechanism to intercept and process user input client-side before transmission.

Workflow
User submits prompt
Client-side: Claude Code executes user's preprocessing script locally
Script processes input (filter, transform, etc.) and outputs modified version
Preview shown to user: "Input was modified - continue?"
User confirms → Processed input sent to Claude
Key Requirements
✅ Runs client-side only (before network transmission)
✅ User provides their own script/program
✅ Standard input/output interface (stdin → script → stdout)
✅ Optional preview of changes before sending
✅ Opt-in (disabled by default)

Proposed Solution

A client-side preprocessing hook that allows users to run their own script/program on input before it's sent to Claude. Example configuration in .claude/settings.json:
{
"hooks": {
"preProcess": {
"enabled": true,
"command": "/path/to/my-filter-script.sh",
"showPreview": true
}
}
}

Alternative Solutions

_No response_

Priority

Low - Nice to have

Feature Category

Developer tools/SDK

Use Case Example

Use Case 1: Privacy Filter
#!/bin/bash

User's custom script: anonymize.sh

sed -E 's/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/EMAIL/g' | \
sed -E 's/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/IP/g'

Use Case 2: Log Formatter
#!/usr/bin/env python3

User's custom script: format-logs.py

import sys, json
logs = sys.stdin.read()
structured = {"logs": logs.split('\n'), "timestamp": "2024-11-13"}
print(json.dumps(structured))

Use Case 3: Company-Specific Sanitizer
#!/usr/bin/env node
// User's custom script: sanitize.js
const input = require('fs').readFileSync(0, 'utf-8');
const sanitized = input
.replace(/Project-\d+/g, 'PROJECT')
.replace(/internal\.company\.com/g, 'HOST');
console.log(sanitized);

Additional Context

Benefits
Flexibility: Users control what and how to preprocess
Privacy: Sensitive data never leaves the client
Extensibility: Supports any transformation use case
Simplicity: Standard Unix pipe interface (stdin/stdout)

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗