← Catalog

phi-router

HIPAA-aligned router for Claude Code, Codex and pi. Your coding agent runs on your flat-rate subscription, and each message that holds PHI reaches only your BAA account.

Package

Install

Install with PiG

pig install npm:phi-router

Install with Pi

pi install npm:phi-router
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./plugins/pi/extension.mjs"
  ]
}

README

Written by the package's publisher, shown as published in version 0.6.2 (README.md). PiG does not review it.

phi-router

Run Claude Code, Codex or pi on your flat-rate subscription when your work touches patient data. Only your BAA account reads PHI. HIPAA-aligned.

npm check license: MIT

Claude Code reads a synthetic patients.csv. The open account gets [sealed h1], the phi-sealed subagent does the work on the BAA account, and Claude Code answers that 2 of 4 patients are overdue.

The real Claude Code and router against mock accounts. Model replies are scripted, and the patients are synthetic. The bottom pane shows what each account received.

How it works

A message goes through phi-router's rules and judge. Sealed parts stay in the sealed store, and cleared parts reach the root agent. When the task needs PHI, the root agent hands a scoped task to the phi/sealed subagent, and phi-router checks its answer before the root agent reads it.

  • Your agent runs on your subscription. phi-router reads each new message before it goes out.
  • Rules catch identifiers such as SSNs. A judge on your BAA account decides the rest.
  • A message with PHI reaches your subscription as a handle, such as [sealed h3].
  • When the task needs that PHI, your agent hands a scoped task to the phi-sealed subagent on your BAA account. phi-router checks the subagent's answer and sends it back to rewrite, up to five times, until it holds no PHI. Identifiers you need go to a private file on your machine.
  • If the router is down, requests fail.

Get started

You need:

  • Claude Code, Codex or pi, logged in to your subscription.
  • An OpenAI API key under your BAA, for the judge.
  • For Claude Code or pi, an Anthropic API key or a Claude Enterprise login under your BAA.

Paste this into your coding agent:

Install phi-router for your harness by following its SETUP.md in https://github.com/drsh4dow/phi-router/blob/main/SETUP.md

Or run it yourself, with codex or pi in place of claude:

npx phi-router setup claude

Setup finds the keys you already have and asks only for the rest. Claude Code and Codex take updates by themselves, and pi tells you when one is out. More in SETUP.md and Accounts.

Proof

bun run eval:recorded replays a synthetic corpus through the router with the judge's recorded answers. It calls no API.

CheckResult
PHI cases leaked to an open account0 of 282
Clean cases sealed anyway41 of 352
Judge cost for 3,031 calls$0.6132

The corpus covers 12 identifier kinds, such as names, SSNs and MRNs, in 12 formats, such as FHIR, HL7v2, SQL dumps and screenshots. Zero leaks in a sample is not a zero leak rate. For the 74 plain-text cases, the 95% upper bound is 0.0397. bun run check replays it on every pull request and fails on any leak.

What it saves

bun run cost . drives the real Claude Code through a scripted claims session against mock accounts. Your subscription took 8 of 9 requests. The BAA account took 1.

Estimate, input tokens at list priceEverything on the BAA accountWith phi-router
Per session$0.44$0.04
Per 1,000 sessions$444$41

Prices were read on 2026-11-26: Claude Opus 5.5 at $4 and the Decisions judge at $0.10 per million input tokens. The estimate leaves out output tokens, caching and your subscription fee.

Compared to the alternatives

(blank)Everything on a BAA API keyClaude Enterprise with HIPAAA redaction tool such as Presidiophi-router
Everyday requests run onThe BAA account, per tokenThe Enterprise accountYour current accountYour subscription
The agent can work with PHIYesYesNo, only redacted textYes, through the subagent
When the check can't runNo checkNo checkUp to your codeThe part stays sealed

What HIPAA-aligned means

phi-router keeps PHI on the accounts your BAA covers. It is not a certification.

phi-router does this:

  • PHI that the rules or the judge find reaches only your BAA accounts.
  • A part it cannot check stays sealed.
  • Sealed content stays in a 0600 file on your machine.

You keep this:

  • The BAA with each vendor whose account reads PHI.
  • The policy. phi-router's definition of PHI is a routing rule, so check it against yours.
  • Your compliance program and the machine phi-router runs on.

FAQ

What counts as PHI? A complete direct identifier of a real patient or member, of 12 kinds: name, SSN, full date of birth, home address, personal phone, personal email, member number, Medicare or Medicaid number, MRN, driver license, passport, and face photo. Internal ids, staff contacts, fragments and counts are not.

What does the judge see? Each new part no rule sealed, alone, without the conversation (ADR 0013). It runs on OpenAI's Decisions API under your BAA. If it fails to answer, the part stays sealed.

What does the router not cover? Before each prompt, your harness checks that the router on its port is yours. A request sent before the first prompt, or after a crash in the middle of a turn, skips that check, so another user on the same machine could read it (ADR 0002).

Does it work with Codex and pi? Claude Code and pi-harness run the whole flow. Codex runs the subagent without the answer check. Stock pi has no subagents, so use phi/sealed for PHI work. See SETUP.md.

What if my subscription hits a rate limit? List several subscriptions and phi-router moves to the next one. When all are limited, the request runs on the BAA account, with handles still in place of PHI. In Claude Code and pi, the status line under the prompt marks the overflow, with the time the router tries your subscription again when it has one, and /phi shows the session's accounts and counts. phi-router adds no notice to their conversation. Codex has no status line, so it says so once at the end of the turn.

Security

Report a vulnerability or a suspected leak privately, as SECURITY.md says. Never put real PHI in an issue. To contribute, see CONTRIBUTING.md.

This software comes with no warranty. The author takes no responsibility for how you use it, including with policies other than the one it ships.