Datafog Python banner
DataFog DataFog

Datafog Python

AI community

Description

Offline PII firewall for AI agents and LLM apps: fast local detection and redaction, Claude Code hook, LiteLLM guardrail. Zero network calls, one dependency.

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

# DataFog Python

DataFog is a Python library for detecting and redacting personally identifiable information (PII).

It provides:

  • Fast structured PII detection via regex
  • An offline PII firewall for AI agents: a Claude Code hook and a LiteLLM gateway guardrail (introduced in 4.6)
  • Optional NER support via spaCy and GLiNER
  • A simple agent-oriented API for LLM applications
  • Backward-compatible DataFog and TextService classes

Agent & Gateway Firewall

DataFog includes two ready-made enforcement points that catch PII at the moment it would leave your machine — offline, in microseconds, with matched values never echoed into logs or transcripts:

  • **Claude Code hook** (`datafog-hook`): gates agent tool calls (shell commands, web requests, file writes, MCP tools) and warns the model when prompts or tool results carry PII. ~70–90ms per invocation including process startup. Easiest install is the [Claude Code plugin](https://github.com/DataFog/datafog-claude-plugin):

    /plugin marketplace add DataFog/datafog-claude-plugin
    /plugin install datafog@datafog

    Manual hook setup and limitations: [examples/claude_code_hook/](examples/claude_code_hook/).

  • **LiteLLM guardrail** (`DataFogGuardrail`): redacts or blocks PII in requests and responses at the gateway, for any LiteLLM-proxied provider. In-process (~40µs per message scanned; a request clears the guardrail in well under a millisecond), no sidecar service. Setup: [examples/litellm_guardrail/](examples/litellm_guardrail/).

Both default to the high-precision entity set (`EMAIL`, `PHONE`, `CREDIT_CARD`, `SSN`); noisier types are opt-in. Known-safe values can be exempted with an allowlist: `scan(text, allowlist=[...])` for exact values, `allowlist_patterns=[...]` for full-match regexes (e.g. `^\d{10}$` to stop unix timestamps matching as phone numbers) — available in both adapters and the API. Presidio-style entity names (`EMAIL_ADDRESS`, `PHONE_NUMBER`, `US_SSN`) are accepted