pii-scrubbing

Installation
SKILL.md

Scrub PII with Braintrust span customizers

Workflow

1. Wire up the plumbing to traverse span fields

Recommend the latest Braintrust SDK for the application's language. Inspect its instrumentation bootstrap and export path, then connect a span customizer to the existing logger or tracer provider; do not create a second telemetry pipeline. See the language references below for concrete customizer and registration examples.

Check for existing scrubbing first, including Python's braintrust.set_masking_function and TypeScript's setMaskingFunction. These native SDK hooks receive individual field values, not complete spans; they cover fields such as input/output and metadata, but not every record field or OTel export path. Reuse an approved existing policy where it covers the request rather than installing a second scrubber. Add a span customizer only for the required coverage, preserving existing masking configuration. Verify the installed SDK's ordering and attachment behavior; a masking hook alone is not proof that attachments or parallel exporters are protected.

Expose the fields needed by the requested policy inside the hook:

  • For whole-field conversation replacement, enumerate the relevant fields/attributes and replace their values. A recursive walk of the messages is unnecessary.
  • For selective key/value matching, traverse the relevant nested objects and arrays and retain field paths. Inventory other locations where that content may be copied; do not assume input/output are the only sensitive fields.
  • For OpenTelemetry, use the public export representation rather than enumerating a live span's own properties. Include event attributes when the policy covers conversation content; resources, scope, links, status, and metadata need explicit coverage only when requested.
  • Treat SDK attachment objects and other non-JSON objects as opaque values unless a supported adapter is available. Do not walk private SDK internals or stringify the whole span.
  • Keep identity, parent relationships, routing, and protocol fields unchanged. Do not mutate application-owned objects or log inspected values; keys and paths can also contain secrets.
  • Keep the hook synchronous and local. Preserve existing customizers and place scrubbing after content-enriching hooks.
Installs
5
GitHub Stars
3
First Seen
14 days ago