Agent skill

Deidentifying Clinical Text

by maziyarpanahi in maziyarpanahi/openmed

Remove, mask, or replace PHI/PII in clinical free text on-device with OpenMed's deidentify().

Apache-2.0Auto-check passedLegal & Compliance

Install Deidentifying Clinical Text

skills CLI
$ npx skills add maziyarpanahi/openmed --skill deidentifying-clinical-text -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install maziyarpanahi/openmed deidentifying-clinical-text --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/maziyarpanahi/openmed.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/deidentifying-clinical-text .claude/skills/deidentifying-clinical-text && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
deidentifying-clinical-text
GitHub stars
5.5k
Token cost
~1.8k tokens
SKILL.md length
602 words
Files
1
Skills in repo
74
Repo updated
First seen
Licence
Apache-2.0

At a glance

Remove, mask, or replace PHI/PII in clinical free text on-device with OpenMed's deidentify().

  • Works in 6 steps: Pick a method and a policy. Start from a… → Set confidence_threshold deliberately.… → Run deidentify. Inspect… → …
  • The user needs to de-identify medical notes
  • SKILL.md covers When to use this skill, Quick start, The five methods and Workflow, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Deidentifying Clinical Text is an agent skill from maziyarpanahi/openmed. Remove, mask, or replace PHI/PII in clinical free text on-device with OpenMed's deidentify(). Use when the user needs to de-identify medical notes, strip patient identifiers, redact PHI before sharing or analysis, anonymize discharge summaries, or pick a de-id method (mask vs remove vs replace vs hash vs shiftdates). Covers confidencethreshold for safety, consistent+seed for stable surrogates, keepmapping for reversible de-id, policy= profiles, and the DeidentificationResult fields. Pairs with OpenMed extractpii…

Its SKILL.md is about 1.8k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Legal & Compliance, covering Privacy and GDPR. The repository describes itself as: Local-first healthcare AI: clinical NER and HIPAA PII de-identification on hardware you control. 2,200+ medical models, 35 model-backed PII languages, and Python, MLX, Android… The licence is Apache-2.0.

When your agent uses it

  • The user needs to de-identify medical notes
  • Strip patient identifiers
  • Redact PHI before sharing
  • Anonymize discharge summaries

Example prompts

  • “/deidentifying-clinical-text”

Requirements

  • Python 3

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Pick a method and a policy. Start from a bundled policy= profile
  2. Set confidence_threshold deliberately. Default is 0.7. For de-id,
  3. Run deidentify. Inspect result.pii_entities by offset and label,
  4. For stable surrogates, pass consistent=True, seed= so the same
  5. For reversibility, pass keep_mapping=True and store result.mapping
  6. Verify, don't assume. Check residual risk with audit=True

What it can do on your machine

Read from SKILL.md and the folder at commit 34d7b8c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • hhs.gov

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Deidentifying Clinical Text loads about 1.8k tokens when it runs. Until then it costs about 163 tokens; SKILL.md has 602 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~163
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from maziyarpanahi/openmed at commit 34d7b8c, republished under its Apache-2.0 licence (© maziyarpanahi). 602 words, ~1,835 tokens.

Download SKILL.mdSave it as .claude/skills/deidentifying-clinical-text/SKILL.md (or your agent's skills folder).
name
deidentifying-clinical-text
description
Remove, mask, or replace PHI/PII in clinical free text on-device with OpenMed's deidentify(). Use when the user needs to de-identify medical notes, strip patient identifiers, redact PHI before sharing or analysis, anonymize discharge summaries, or pick a de-id method (mask vs remove vs replace vs hash vs shift_dates). Covers confidence_threshold for safety, consistent+seed for stable surrogates, keep_mapping for reversible de-id, policy= profiles, and the DeidentificationResult fields. Pairs with OpenMed extract_pii (detect spans), reidentify (restore), configuring-privacy-policies, and auditing-deidentification-runs.
license
Apache-2.0
metadata.project
OpenMed
metadata.category
openmed-core
metadata.pairs
adjacent
metadata.version
1.0

De-identifying clinical text

openmed.deidentify detects PHI/PII and rewrites the text so it can be shared, stored, or analyzed without exposing patients. It runs fully on-device after a one-time model download — no network calls, no telemetry, no raw PHI leaving the process. This is the single most important OpenMed entry point for privacy work; everything else (policies, audit, multilingual, date-shifting) layers on top of it.

When to use this skill

Reach for deidentify when you need to transform text — replace, mask, remove, hash, or date-shift the identifiers. If you only need to locate PHI spans without changing the text, use extract_pii (see extracting-pii-entities). To restore masked text later, use reidentify (see reidentifying-text).

Quick start

python
import openmed

note = (
    "Patient John Doe (MRN 1234567) was seen on 2024-03-02 by Dr. Alice Reed. "
    "Contact: john.doe@example.com, 617-555-0142."
)

result = openmed.deidentify(
    note,
    method="mask",                 # mask | remove | replace | hash | shift_dates
    confidence_threshold=0.7,      # safety default; raise to reduce false negatives' impact
    policy="hipaa_safe_harbor",    # optional bundled profile (see below)
)

print(result.deidentified_text)
# Patient [NAME] (MRN [ID_NUM]) was seen on [DATE] by Dr. [NAME]. ...

for e in result.pii_entities:
    # NEVER log e.text / e.original_text — those are raw PHI. Use offsets + label.
    print(e.canonical_label, e.start, e.end, round(e.confidence, 3))

deidentify returns a DeidentificationResult with these fields (note the exact names):

FieldWhat it holds
.deidentified_textthe rewritten, PHI-safe string (your output)
.pii_entitieslist[PIIEntity] — each has start, end, canonical_label, confidence, action, surrogate; original_text/text hold raw PHI
.mappingredacted→original dict, only when keep_mapping=True (secret)
.methodthe method actually applied
.metadatarun metadata (model, policy, counts)

The five methods

method=EffectReversible?Use when
"mask"John Doe → [NAME]with keep_mapping=Truedefault; clear that redaction happened
"remove"deletes the span entirelynominimal-footprint output
"replace"type-matched fake value (John Doe→Mark Lee)with keep_mapping=Truekeep notes readable/parseable (see generating-synthetic-surrogates)
"hash"stable hash per value, links repeatsno (one-way)cohort linkage without revealing identity
"shift_dates"moves dates, preserves intervalsn/aresearch needing temporal structure (see shifting-clinical-dates)

Workflow

  1. Pick a method and a policy. Start from a bundled policy= profile (hipaa_safe_harbor, gdpr_pseudonymization, research_limited_dataset, …) so per-label actions are set for you. See configuring-privacy-policies.
  2. Set confidence_threshold deliberately. Default is 0.7. For de-id, prefer over-redaction: a missed identifier is a breach, an over-redacted token is just noise. The bundled safety sweep catches structured IDs (SSN, MRN-like, emails) even below threshold.
  3. Run deidentify. Inspect result.pii_entities by offset and label, not raw text, to confirm coverage.
  4. For stable surrogates, pass consistent=True, seed=<int> so the same input maps to the same fake value every run (reproducible pipelines).
  5. For reversibility, pass keep_mapping=True and store result.mapping in a secured vault — never alongside the de-identified output.
  6. Verify, don't assume. Check residual risk with audit=True (auditing-deidentification-runs) and the 18-identifier checklist (auditing-safe-harbor-checklist).
Show full SKILL.md (238 more words)Show less

Consistent surrogates and reversibility

python
# Same fake identity for every mention of the same person, reproducibly:
r = openmed.deidentify(note, method="replace", consistent=True, seed=42)

# Reversible de-id (keep the mapping secret and separate from output):
r = openmed.deidentify(note, method="mask", keep_mapping=True)
restored = openmed.reidentify(r.deidentified_text, r.mapping)
assert restored == note

Hand-off to / from OpenMed

  • Detect only: openmed.extract_pii(text) → PredictionResult with .entities (spans, no rewrite). Use it to preview coverage first.
  • Restore: openmed.reidentify(deidentified_text, mapping) — requires keep_mapping=True at de-id time and proper authorization.
  • Policies: configuring-privacy-policies to choose/customize a policy=.
  • Audit: deidentify(..., audit=True) → AuditReport with offsets, hashes, detector provenance, and residual-risk — never plaintext.
  • Other surfaces (same engine): MCP tool openmed_deidentify; REST POST /pii/deidentify. There is no CLI de-id command.

Edge cases & gotchas

  • Attribute names. It is result.deidentified_text and result.pii_entities — not .text/.entities. (extract_pii returns a PredictionResult whose spans are at .entities.)
  • Raw PHI never leaves the span objects. PIIEntity.text and .original_text contain real identifiers. Do not print, log, or cache them. Audit and logs use offsets, canonical_label, and hashes only.
  • Threshold is a safety dial, not an accuracy dial. Lowering it redacts more; in de-id, false positives are cheap and false negatives are breaches.
  • shift_dates is for dates only; combine with keep_year/date_shift_days (see shifting-clinical-dates). It does not touch names or IDs.
  • keep_mapping output is sensitive as PHI. The mapping re-identifies everyone — store it encrypted, access-controlled, and apart from the output.
  • Multilingual: pass lang= (and locale= for surrogates) for non-English notes; see deidentifying-multilingual-text. Do not run English models on other languages.
  • De-id is verified, not assumed. Gate releases on leakage/residual-risk, not F1 alone.

Standards & references

© maziyarpanahi, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/deidentifying-clinical-text of maziyarpanahi/openmed.

Open the folder on GitHubat commit 34d7b8c

Compare with similar skills

Deidentifying Clinical Text next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Deidentifying Clinical Text compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Deidentifying Clinical Text this skillmaziyarpanahi/openmed5.5k—~1.8kAutomated safety check: PassApache-2.0
C15tc15t/c15t1.9k1 repos~1.6kAutomated safety check: PassApache-2.0
Korean Privacy Termskimlawtech/korean-privacy-terms587—~2.9kAutomated safety check: PassApache-2.0
Gdpr ComplianceSushegaad/Claude-Skills-Governance-Risk-and-Compliance9461 repos~3.9kAutomated safety check: PassMIT
Hipaa ComplianceSushegaad/Claude-Skills-Governance-Risk-and-Compliance9461 repos~2.3kAutomated safety check: PassMIT
Pii Contract Analyzegregmos/PII-Shield150—~8.9kAutomated safety check: NotesMIT

Similar skills

  • C15t

    c15t/c15t

    Work with c15t consent management docs, APIs, and integrations for Next.js, React, and JavaScript.

    1.9k GitHub starsUsed in 1 repo~1.6k tokens
    Legal & ComplianceAuto-check passed
  • Korean Privacy Terms

    kimlawtech/korean-privacy-terms

    처리방침·이용약관 자동 생성 스킬 패키지 (v4.0). An agent skill from kimlawtech/korean-privacy-terms.

    587 GitHub stars~2.9k tokensUpdated 1 mo ago
    Legal & ComplianceAuto-check passed
  • Gdpr Compliance

    Sushegaad/Claude-Skills-Governance-Risk-and-Compliance

    Expert GDPR compliance assistant covering all four core workflows: (1) auditing code and systems for GDPR violations, (2) drafting GDPR-compliant documents such as privacy policies, Data Processing…

    946 GitHub starsUsed in 1 repo~3.9k tokens
    Legal & ComplianceAuto-check passed
  • Hipaa Compliance

    Sushegaad/Claude-Skills-Governance-Risk-and-Compliance

    Expert HIPAA compliance assistant for healthcare and software contexts.

    946 GitHub starsUsed in 1 repo~2.3k tokens
    Legal & ComplianceAuto-check passed
  • Pii Contract Analyze

    gregmos/PII-Shield

    Universal legal document processor with PII anonymization. An agent skill from gregmos/PII-Shield.

    150 GitHub stars~8.9k tokensUpdated 3 mo ago
    Legal & ComplianceAuto-check: notes
  • Gdpr Compliance Checker

    goSprinto/compliance-skills

    Autonomous GDPR compliance auditor that scans a codebase to identify PII collection, storage, and sharing, then produces an article-by-article gap analysis, a pre-filled Data Processing Agreement…

    133 GitHub stars~8.6k tokensUpdated 4 mo ago
    Legal & ComplianceAuto-check: notes

More from maziyarpanahi/openmed

All 74 skills in this repo
  • Checks OpenMed de-identified clinical text against the 18 HIPAA Safe Harbor identifier categories and reports gaps and residual re-identification risk.

    5.5k GitHub stars~1.7k tokensUpdated today
    Auto-check passed
  • OpenMed Model Card Writer

    maziyarpanahi/openmed

    Fills in a model card for an OpenMed clinical NER or de-identification model from its evaluation reports: intended use, metrics, subgroups and limitations.

    5.5k GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Walks a data pipeline against the HIPAA Privacy and Security Rule checklist and produces a gap report before it processes patient data.

    5.5k GitHub stars~2k tokensUpdated today
    Auto-check passed
  • ICD-10 Coding Assistant

    maziyarpanahi/openmed

    Suggests candidate ICD-10-CM diagnosis and ICD-10-PCS procedure codes for clinical text extracted by OpenMed, with rationale for a certified coder to review.

    5.5k GitHub stars~2k tokensUpdated today
    Auto-check passed
  • OpenMed ETL to OMOP CDM

    maziyarpanahi/openmed

    Maps OpenMed-extracted, terminology-coded conditions, drugs and measurements into OMOP CDM v5.4 tables for OHDSI and ATLAS analytics.

    5.5k GitHub stars~1.9k tokensUpdated today
    Auto-check passed
  • Extracting SDOH and Z-Codes

    maziyarpanahi/openmed

    Finds social risks such as housing instability or food insecurity in clinical notes and proposes matching ICD-10-CM Z-codes for a coder to confirm.

    5.5k GitHub stars~1.9k tokensUpdated today
    Auto-check passed

Questions about Deidentifying Clinical Text

What does Deidentifying Clinical Text do?

Remove, mask, or replace PHI/PII in clinical free text on-device with OpenMed's deidentify(). Deidentifying Clinical Text is an agent skill from maziyarpanahi/openmed. Remove, mask, or replace PHI/PII in clinical free text on-device with OpenMed's deidentify().

When should I use Deidentifying Clinical Text?

Deidentifying Clinical Text fits situations like: the user needs to de-identify medical notes; strip patient identifiers; redact PHI before sharing; anonymize discharge summaries.

How do I install Deidentifying Clinical Text in Claude Code?

Run `npx skills add maziyarpanahi/openmed --skill deidentifying-clinical-text -a claude-code`. Or copy the skill folder (skills/deidentifying-clinical-text in maziyarpanahi/openmed) into .claude/skills/deidentifying-clinical-text in your project. Claude Code loads it when a task matches its description.

How do I install Deidentifying Clinical Text in Codex?

Run `npx skills add maziyarpanahi/openmed --skill deidentifying-clinical-text -a codex`. Or copy the skill folder (skills/deidentifying-clinical-text in maziyarpanahi/openmed) into .agents/skills/deidentifying-clinical-text in your project. Codex loads it when a task matches its description.

Can I use Deidentifying Clinical Text in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add maziyarpanahi/openmed --skill deidentifying-clinical-text -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/deidentifying-clinical-text, .gemini/skills/deidentifying-clinical-text, .github/skills/deidentifying-clinical-text and .opencode/skills/deidentifying-clinical-text in your project.

What does Deidentifying Clinical Text need to run?

SKILL.md names no scripts, command-line tools or credentials: Deidentifying Clinical Text is instructions for the agent only. Our summary lists: Python 3.

Does Deidentifying Clinical Text access the network?

SKILL.md names 1 domain. As links in the text: hhs.gov. This is read from the text; nothing was executed.

Is Deidentifying Clinical Text safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Deidentifying Clinical Text use?

Deidentifying Clinical Text is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Deidentifying Clinical Text use?

About 1.8k tokens (SKILL.md is roughly 7.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Deidentifying Clinical Text?

Skills that share tags, products or a category with Deidentifying Clinical Text: C15t (c15t/c15t, 1.9k stars), Korean Privacy Terms (kimlawtech/korean-privacy-terms, 587 stars), Gdpr Compliance (Sushegaad/Claude-Skills-Governance-Risk-and-Compliance, 946 stars) and Hipaa Compliance (Sushegaad/Claude-Skills-Governance-Risk-and-Compliance, 946 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Deidentifying Clinical Text?

maziyarpanahi (a GitHub user) maintains it in maziyarpanahi/openmed, which has 5,506 GitHub stars. The repository holds 74 skills in this directory. The repository was last updated on October 11, 2026.

Source: maziyarpanahi/openmed on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.