Your secrets stay local. Your LLM gets the context.
A local-first context sanitizer that sits between your IDE and the cloud LLM. It detects API keys, PII, and internal IPs β replaces them with reversible tags β and restores them in the response. Nothing sensitive ever leaves your machine.
Quick Start Β· How It Works Β· Features Β· Providers Β· Configuration Β· Contributing
Developers paste secrets into LLM prompts every day. AWS keys, database credentials, customer emails, internal IPs β most don't even realize it. Enterprise security teams know, and they block AI tools entirely because of it.
Cloq eliminates this risk without changing your workflow.
- "Fix the bug. DB is at 10.0.1.50:5432 and key is AKIAIOSFODNN7EXAMPLE"
+ "Fix the bug. DB is at [INTERNAL_IP_1] and key is [AWS_ACCESS_KEY_1]"
β
Cloud LLM only sees sanitized tags
Real values restored locally on responseTraditional LLM prompt caches miss as soon as a variable, key, port, IP, or file path changes.
Because Cloq sanitizes these variables into uniform tags first, it acts as a semantic normalization layer. Identical coding templates are matched locally, cutting development LLM costs by up to 80%!
Developer A: "Fix the bug in 10.0.1.50:5432 with key AKIAIOSFODNN7EXAMPLE"
β³ Normalizes to: "Fix the bug in [INTERNAL_IP_1] with key [AWS_ACCESS_KEY_1]"
β³ CACHE MISS: Sent to Upstream Cloud LLM. Response cached locally as a template.
Developer B: "Fix the bug in 192.168.1.12:5432 with key AKIAI7YYYDNN7ANOTHER"
β³ Normalizes to: "Fix the bug in [INTERNAL_IP_1] with key [AWS_ACCESS_KEY_1]"
β³ CACHE HIT! Cloq instantly restores Developer B's variables locally in 4ms at $0 cost.
No cloud upstream call, zero token usage, completely private, and blazing fast.
# 1. Install globally via pip
pip install cloq
# 2. Run the interactive CLI to start the proxy
cloq-cliThis will launch an interactive menu where you can choose to open the Web UI or run directly in the terminal.
To use with your AI tools:
Just point your LLM client's Base URL to http://127.0.0.1:8989/v1
Cloq comes with a gorgeous, live Web UI that monitors your tokens saved, active sessions, and protected entities in real time.
When running cloq-cli, simply select β
Web UI (Open in Browser), or navigate manually to http://127.0.0.1:8989/ui.
Cloq runs as a transparent local proxy on your machine. Every LLM API call passes through it automatically.
sequenceDiagram
participant Client as IDE / CLI / App
participant Cloq as Cloq Proxy (Local)
participant LLM as Cloud LLM (GPT, Claude, Gemini)
Note over Client,Cloq: Local Machine (Private & Secure)
Client->>Cloq: 1. API Request (with secrets)
Note over Cloq: 2. Detect sensitive data<br/>3. Replace with [TAGS]
Cloq->>LLM: 4. Forward sanitized request
LLM-->>Cloq: 5. Response (with tags)
Note over Cloq: 6. Restore real values locally
Cloq-->>Client: 7. Return complete response
Step by step:
- Intercept β Cloq captures the outgoing API request
- Detect β A pipeline of detectors scans all text fields for sensitive data
- Tag β Each detected entity gets a semantic tag:
[AWS_KEY_1],[EMAIL_ADDRESS_1],[INTERNAL_IP_1] - Forward β The sanitized (safe) request goes to the cloud LLM
- Restore β When the LLM responds, tags are replaced back with real values
- Return β Your tool receives the complete, restored response
The same value always maps to the same tag within a session, so the LLM can reason about relationships ("use [DB_HOST_1] with [AWS_KEY_1]") without ever seeing the real data.
Three pluggable detectors that run as a pipeline:
| Detector | What It Finds | Examples |
|---|---|---|
| Secrets | API keys, tokens, credentials | AWS AKIA..., GitHub ghp_..., Stripe sk_live_..., Google AIza..., Slack xox..., JWTs, private keys (RSA/EC/PGP), connection strings (Postgres, MongoDB, Redis, JDBC) |
| PII | Personal data | Emails, phone numbers, credit cards (Visa/MC/Amex), SSNs, IBAN codes. Uses Microsoft Presidio when installed, falls back to regex |
| Network | Infrastructure details | Private IPs (RFC 1918: 10.x, 172.16-31.x, 192.168.x), IPv6 link-local, localhost, internal hostnames via configurable domain patterns |
Plus entropy-based detection for generic high-entropy strings that don't match known patterns.
Not just <REDACTED> β Cloq uses semantic, indexed tags that preserve meaning for the LLM:
[AWS_ACCESS_KEY_1] β The LLM knows this is a credential
[INTERNAL_IP_1] β The LLM knows this is a host address
[EMAIL_ADDRESS_2] β The LLM can distinguish between two emails
Same value always maps to the same tag (idempotent within a session).
Full SSE streaming support with intelligent buffering β handles tags that are split across chunk boundaries. Adds < 50ms latency.
Add your own detectors for organization-specific patterns:
from cloq.detection.base import BaseDetector, DetectionResult
class MyDetector(BaseDetector):
name = "my_detector"
def detect(self, text: str) -> list[DetectionResult]:
# Your custom detection logic
...JSON Lines audit log that records what type of data was sanitized, but never the actual values:
{"action":"sanitized","entity_type":"AWS_ACCESS_KEY","detector":"secrets","tag":"[AWS_ACCESS_KEY_1]","timestamp":"2025-07-15T10:30:00Z"}Works with any LLM provider. Just set the base URL to http://localhost:8989:
| Provider | Format | Status |
|---|---|---|
| OpenAI (GPT-4o, o1, o3) | /v1/chat/completions |
β |
| Anthropic (Claude 3.5/4) | /v1/messages |
β |
| Google Gemini | :generateContent |
β |
| Azure OpenAI | /openai/deployments/*/chat/completions |
β |
| Groq | OpenAI-compatible | β |
| Together AI | OpenAI-compatible | β |
| Ollama | OpenAI-compatible | β |
| Any OpenAI-compatible API | /v1/chat/completions |
β |
Cloq features a rich interactive CLI. Run cloq-cli with no arguments to launch the interactive menu, or use the direct commands below:
# Core
cloq-cli start # Start the proxy server in terminal
cloq-cli status # Check if proxy is running + stats
cloq-cli version # Show current version
# Diagnostics & Monitoring
cloq-cli doctor # Run system health checks and verify config
cloq-cli gain # View live token and cost savings from cache
cloq-cli dashboard # Launch the live terminal HUD
# Utilities
cloq-cli scan path/to/file.py # Scan a file for secrets (standalone)
cloq-cli test # Run a self-test with sample data
cloq-cli config init # Generate a .cloq.yml templateExample scan output:
Scan Results: credentials.env
ββββββ³βββββββββββββββββ³βββββββββββββββββββββββ³ββββββββ³βββββββββββ
β # β Type β Value β Score β Detector β
β‘ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β 1 β INTERNAL_IP β 10.0ββββββ5432 β 95% β network β
β 2 β AWS_ACCESS_KEY β AKIAββββββββββββMPLE β 98% β secrets β
β 3 β EMAIL_ADDRESS β dev@βββββββ.com β 80% β pii β
ββββββ΄βββββββββββββββββ΄βββββββββββββββββββββββ΄ββββββββ΄βββββββββββ
3 sensitive item(s) detected
Scanned in 0.7ms
cloq config init # Creates .cloq.yml in your project root# .cloq.yml
proxy:
host: 127.0.0.1
port: 8989
detection:
secrets:
enabled: true
custom_patterns:
- name: my_internal_token
regex: "INT-[A-Z0-9]{32}"
entity_type: INTERNAL_TOKEN
pii:
enabled: true
confidence_threshold: 0.7
entities: [EMAIL_ADDRESS, PHONE_NUMBER, CREDIT_CARD]
network:
enabled: true
internal_domains:
- "*.internal.mycompany.com"
- "*.corp.mycompany.net"
allowlist:
values: ["api.openai.com", "api.anthropic.com"]
logging:
audit:
enabled: true
path: "~/.cloq/audit.log"Config priority (highest wins): CLI flags β CLOQ_* env vars β .cloq.yml β ~/.config/cloq/config.yml β defaults
Use Cloq as a library without the proxy:
from cloq.detection.pipeline import DetectionPipeline
from cloq.detection.secrets import SecretsDetector
from cloq.detection.pii import PIIDetector
from cloq.detection.network import NetworkDetector
from cloq.sanitizer.engine import SanitizationSession, sanitize, restore
# Build a detection pipeline
pipeline = DetectionPipeline([
SecretsDetector(),
PIIDetector(),
NetworkDetector(internal_domains=["*.internal.company.com"]),
])
# Detect + sanitize
text = "DB at 10.0.1.50:5432, key AKIAIOSFODNN7EXAMPLE, email dev@corp.com"
results, metrics = pipeline.run(text)
session = SanitizationSession(session_id="req-1")
sanitized = sanitize(text, results, session)
# β "DB at [INTERNAL_IP_1], key [AWS_ACCESS_KEY_1], email [EMAIL_ADDRESS_1]"
# After LLM responds, restore the real values
response = "[INTERNAL_IP_1] is healthy. Use [AWS_ACCESS_KEY_1] to connect."
restored = restore(response, session)
# β "10.0.1.50:5432 is healthy. Use AKIAIOSFODNN7EXAMPLE to connect."| Concern | How Cloq Solves It |
|---|---|
| Data leakage | Sensitive data is replaced before it leaves the machine |
| Compliance | Audit log proves what was sanitized without storing secrets |
| Zero trust | Nothing goes to the cloud unredacted β ever |
| No telemetry | Cloq never phones home. Fully offline capable |
| Custom policies | Add organization-specific patterns and domain rules |
| Developer experience | Zero friction β one command, no code changes |
- Local-only processing β The proxy runs entirely on your machine
- In-memory sessions β Tag β original mappings are never written to disk
- Audit without secrets β Logs record entity types and actions, never actual values
- No telemetry β Zero external network calls from Cloq itself
- Minimal dependencies β Small attack surface by design
See SECURITY.md for our vulnerability disclosure policy.
src/cloq/
βββ cli/ # Typer + Rich CLI (start, scan, status, test, config)
βββ config/ # Pydantic v2 config schema + YAML/env loader
βββ detection/ # Pluggable detector pipeline
β βββ secrets.py # 15+ regex patterns + Shannon entropy
β βββ pii.py # Presidio integration + regex fallback
β βββ network.py # RFC 1918 IPs, internal hostnames
βββ proxy/ # FastAPI + httpx async proxy server
β βββ providers.py # OpenAI, Anthropic, Google, Azure adapters
β βββ streaming.py # SSE streaming with cross-boundary restoration
βββ sanitizer/ # Reversible tagβoriginal engine + session store
βββ logging/ # JSON Lines audit logger
We welcome contributions of all kinds!
git clone https://github.com/CodeBase-X1/cloq.git
cd cloq
pip install -e ".[dev]"
make test # Run 55 tests
make lint # Ruff linting
make format # Auto-formatSee CONTRIBUTING.md for full guidelines.
- Core detection engine (secrets, PII, network)
- Reversible sanitization with semantic tags
- Multi-provider proxy (OpenAI, Anthropic, Google, Azure)
- SSE streaming support
- CLI with Rich terminal output
- VS Code extension
- JetBrains plugin
- Local ML model integration (spaCy NER)
- Web dashboard for monitoring
- Docker image for team deployment
- GDPR/HIPAA compliance report generation
Apache 2.0 Β· Built by the CodeBase-X1 community
If Cloq helped you, consider giving it a β