Legal Document Redaction logo

Legal Document Redaction

Community
vivy-yi
legal-document-redaction

法律文件脱敏——按场景白名单与法域规则,对判决书/合同/证据/邮件/聊天记录中的 16 类敏感实体进行识别、替换或遮蔽,输出可外发版本。 适用情形:用户要求脱敏/匿名化/可外发版本/隐去当事人/隐去姓名/隐去账号/隐去身份证号/做案例库分享稿/发律师函时隐去内部编号。 核心:识别 16 类敏感实体→按上下文标注角色→按脱敏规则映射表替换→可逆模式生成比对文件。 与 data-compliance 互补:data-compliance 是 PIPL 合规**审查**,本 skill 是脱敏**执行**。 配套 skill:白/黑名单与优先级见 legal-document-redaction-config;还原脱敏稿见 legal-document-restoration。

Overview

Publishervivy-yi
RepositoryGreater-China-Legal
Skill namelegal-document-redaction
Stars
49
Forks
9
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by vivy-yi on GitHub. Read the source before you install it.

Installation

Install the Legal Document Redaction AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/vivy-yi/Greater-China-Legal/tree/main/plugins/legal-operations/legal-document-redaction
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/vivy-yi/Greater-China-Legal.git /tmp/Greater-China-Legal
mkdir -p .claude/skills
cp -r /tmp/Greater-China-Legal/plugins/legal-operations/legal-document-redaction .claude/skills/legal-document-redaction
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Legal Document Redaction in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Legal Document Redaction on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Legal Document Redaction is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

/legal-document-redaction — 法律文件脱敏

场景通用原子 skill。本 skill 仅负责"识别 + 替换"两件事。 配套机制(白/黑名单、优先级、还原、批次一致性)由相邻 atomic skill 承担,不在本 skill 范围内。

一、加载上下文(必读)

调用本 skill 前必须确认:

1. 输入文件类型(判决书/合同/邮件/聊天记录/内部备忘录……)
2. 目标受众(律师内部/客户/对方/监管/学术/公众)
3. 脱敏粒度(粗/中/细)
4. 可逆性(不可逆 vs 可逆并生成比对文件)
5. 适用法域(cn-mainland 默认 / hk / tw / sg / mo / eu)
6. 上下文角色标注(是否需要识别甲方/乙方/丙方、合同总价/违约金等)

未指定 → 暂停,要求补充(按 GCL 原子 skill 规范)。 禁止对刑事证据、未成年人信息、医疗健康数据默认采用"粗粒度+不可逆"——这三类必须由用户显式确认。


二、16 类敏感实体清单

任何法律文件脱敏的第一步是识别。下列 16 类是高频命中项:

#实体类型中文示例(特征)英文示例(特征)
1自然人姓名2-4 字中文姓名(含常见复姓、姓 + 名/名 + 名结构)English personal name (First Last)
2法人/非法人组织名称中文公司全称(行政区划 + 字号 + 行业 + 组织形式)English company name (Corp/Ltd/Inc)
3公民身份号码18 位数字 + 末位 X 校验—
4联系电话 / 手机11 位手机号 / 座机号E.164 格式 + 区号
5银行账号 / 支付账号16-19 位数字,可分组IBAN / 银行卡号
6地址(门牌号以上)省市区 + 街道 + 门牌Street address with number
7邮箱local@domain 格式local@domain
8车牌 / 不动产证号 / 合同编号字母数字混合Alphanumeric code
9IP / MAC / 设备指纹IPv4/IPv6 / MACUUID hash
10病历 / 健康 / 基因信息病种、检验值、家族病史diagnosis, lab values
11未成年人 / 被害人 / 证人姓名自然人姓名但需特别保护minor's name, witness ID
12内部编号 / 案号 / 卷宗号(YYYY)法院代字+序号+号Case No. format
13日期YYYY 年 M 月 D 日 / YYYY-MM-DDISO 8601 / 自由格式
14价格 / 金额币种 + 数字 + 单位(万/千/元)Currency + amount
15统一社会信用代码18 位字母数字—
16项目名称中文项目全称(名 + 项目/工程/系统)Project codename

★ 识别原则 ─────────────────────────────────

  • 宁多勿漏:法律文件脱敏"漏一个就可能构成执业风险"。识别阶段允许低置信度命中,由用户后续筛选。
  • 上下文敏感:"张某"在判决书中必脱敏;在客户内部 KOL 名单中可保留——调用方必须告知文件类型。
  • 派生信息也算:单条脱敏后组合仍可识别个人(出生年月+籍贯+职业)的,按"动机-机会"标准仍需脱敏。
  • 前缀剥离:若规则以"联系电话:"等前缀开头,只识别前缀后的号码,避免前缀被一起替换。 ─────────────────────────────────────────────────

三、上下文角色标注

调用方要求标注上下文角色时(§ 一-6 = 是),按以下规则给实体贴角色标签:

3.1 合同方角色

触发词角色替换前缀
甲方 | 买方 | 委托方 | 发包方 | 采购方 | 出租方 | 投资方买方买方
乙方 | 卖方 | 受托方 | 承包方 | 供应商 | 承租方 | 受让方卖方卖方
丙方 | 第三方 | 担保方第三方第三方

示例(由 AI 根据原文动态生成):甲方:[法人原文] → 【买方公司1】(而非无差别 【公司1】)

3.2 金额类型

触发词金额类型
合同总价 | 总金额 | 交易价格合同总价
单价 | 单位价格单价
预付款 | 首付款 | 定金预付款
尾款 | 余款尾款
违约金 | 赔偿金 | 补偿金违约金

示例(由 AI 根据原文动态生成):合同总价:[金额原文] → 【合同总价1】

上下文标注是脱敏的增强层,非必需。调用方没要求时跳过本节,直接按 § 二实体类型生成标签。


四、脱敏规则映射表 ← TODO(用户编写)

业务核心,按 Learning mode 原则,决策权交回用户。 调用方给出"粗/中/细 × 可逆/不可逆"组合后,下表决定每个实体如何被替换。规则本身不是技术问题,是法律执业习惯 + 客户偏好问题。

4.1 三档粒度定义

粗粒度:保留实体类型提示,便于阅读,但具体值不可识别。
        例:[自然人原文] → [当事人A]、[法人原文] → [甲方公司]
中粒度:保留部分特征(如姓、行业),便于人工对应。
        例:[自然人原文] → 张某某、[法人原文] → [公司]
细粒度:仅保留结构(如长度、类型),最接近匿名。
        例:[自然人原文] → 长度 N 的姓名占位、[法人原文] → 长度 N 的法人占位

4.2 替换策略矩阵(通用默认)

基于司法实务 + PIPL + 最高院共识。律所采用时可 fork 修改本表。

实体类型粗粒度中粒度细粒度映射键命名
自然人姓名[当事人 N]张某某***PERSON_001
法人名称[公司 N]XX 有限公司***ORG_001
身份证号前 6 位****后 4 位前 6 位****后 4 位***ID_CARD_001
联系电话[电话 N]138****1234***PHONE_001
银行账号[账号 N]************1234***ACCOUNT_001
地址[地址 N]XX 市 XX 区*******ADDRESS_001
邮箱[邮箱 N]@.com***EMAIL_001
车牌 / 证号 / 合同编号[文件编号 N][文件编号]***FILE_CODE_001
IP / MAC[IP N]...***IP_001
健康信息[健康信息 N]******HEALTH_001
未成年人 / 证人[证人 N]******WITNESS_001
内部编号 / 案号[案号 N]*******CASE_001
日期[日期 N]2024 年 X 月 X 日2024 年DATE_001
价格 / 金额[金额类型 N]¹人民币 *** 万元***PRICE_001
统一社会信用代码[代码-统一社会信用代码 N]******CREDIT_CODE_001
项目名称[项目 N][项目]***PROJECT_001

¹ 金额标签按 § 三 3.2 上下文类型自动选用:[合同总价 N] [单价 N] [预付款 N] [尾款 N] [违约金 N]

设计依据:

  1. 身份证号 6+4:司法惯例(参见《人民法院在线诉讼规则》等),既能脱敏又保留地域信息(便于当事人识别)。
  2. 金额保留币种+单位:人民币 *** 万元 比 *** 更可读,便于人工复核。
  3. 日期粗/中/细差异:分别保留"结构 / 月份 / 年份"——按需细粒度,避免无意义的具体日期暴露。
  4. 健康/未成年人/证人三类强制细粒度 + 不可逆——PIPL 第 73 条与最高院司法解释共识。
  5. 自然人姓名:中粒度 张某某 保留姓氏便于实务对应(中国法律文书传统)。
  6. 统一社会信用代码:细粒度 ***——18 位代码本身就是敏感标识,无中间粒度意义。
  7. 采用本 skill 的律所可 fork 修改:表格是 skill 作者视角的默认设置,律所上线时可按本所 SOP 覆盖。

4.3 可逆性开关

可逆模式:生成 sidecar(内部) + 比对文件 .md(可外发给审核人)
不可逆模式:映射表不持久化,执行后无法还原
刑事证据 / 未成年人 / 医疗数据 → 默认不可逆(即使选了可逆,强制覆盖)

五、跨法域法律依据

调用方标注法域后,本节决定脱敏标准;未标注默认 cn-mainland。

5.1 cn-mainland — 中华人民共和国

规范关键条款脱敏关联
《个人信息保护法》第 73 条第 3 项定义"去标识化"
《个人信息保护法》第 73 条第 4 项定义"匿名化"——不可复原
《个人信息保护法》第 51 条处理者义务:加密、去标识化等安全措施
《数据安全法》第 21 条数据分类分级 + 脱敏作为技术措施
《最高法关于人民法院在线诉讼规则》第 16 条经当事人同意可匿名化处理

5.2 hk — 香港

规范关键条款脱敏关联
《个人资料(私隐)条例》Cap. 486DPAO 1 第 1.1 节定义"anonymised data"
《个人资料(私隐)条例》Cap. 486DPP 3使用限制(外发需同意)
香港个人资料私隐专员公署《匿名化指引》全文匿名化 ≠ 假名化;必须不可识别

5.3 tw — 台湾

规范关键条款脱敏关联
《个人资料保护法》第 2 条第 1 款第 4 目定义"去识别化"
《个人资料保护法》第 2 条第 1 款第 5 目定义"匿名化"——完全不可复原
《个人资料保护法施行细则》第 3 条去识别化具体方法(编码、遮蔽、隐码)

5.4 sg — 新加坡

规范关键条款脱敏关联
《PDPA 2012》第 2(1) 条定义"anonymised data"
《PDPA 2012》第 4 部分通知与同意义务
PDPC《Guide to Basic Anonymisation》全文匿名化技术指南

5.5 mo — 澳门

规范关键条款脱敏关联
《个人资料保护法》(第 8/2005 号)第 4 条第 4 款定义"匿名化"
《个人资料保护法》(第 8/2005 号)第 7 条数据处理安全措施义务

5.6 eu — 欧盟(跨境参考)

规范关键条款脱敏关联
《GDPR》Recital 26区分 anonymisation(脱 GDPR)vs pseudonymisation(仍在 GDPR)
《GDPR》第 4 条第 5 项定义 pseudonymisation

六、工作流(4 步)

步骤 1 解析:读取文件 → 切分段落 → 识别文件类型 → 未指定参数则暂停
步骤 2 识别:按 § 二 16 类清单 + § 三 上下文角色做正则匹配
步骤 3 替换:按 § 四 4.2 映射表取得替换模板 → 分配映射键 → 生成脱敏稿
步骤 4 校验:覆盖率 ≥ 95% + 派生信息风险扫描 + 可读性自检 + 不可逆文件销毁映射

七、输出格式

7.1 脱敏输出(3 段式)

markdown
## [A] 脱敏元数据
- 文件:<原文件名> | 法域:<cn-mainland/hk/tw/sg/mo/eu>
- 粒度:<粗/中/细> | 可逆:<是/否>
- 上下文标注:<是/否> | 替换计数:N 处

## [B] 脱敏后文本
[完整文本,每处替换以 [ENTITY_TYPE_N] 占位]

## [C] 风险标注
- [WARN] 派生信息残留 / 低置信度未处理

7.2 可逆模式附加

sidecar(内部,不外发):`plugins/legal-scenes/<本场景>/matters/<slug>/redaction-map.json`
  permissions: 0600
比对文件(可外发给审核人):{原文件名}_比对.md
  # 脱敏比对表
  ## 批次元数据(批次 UUID / 法域 / 生成时间)
  ## 映射表(占位符 | 原文 | 实体类型 | 上下文角色)

八、与场景的协作

本 skill 是只读改写器,不修改调用方的业务逻辑:

上游场景触发时机输出用途
contract-review合同审查完成后生成可对外分享版本
litigation-support案件结案归档入案例库前脱敏
data-compliancePIPL 合规审查 → 需要外发样本提供脱敏样本
cocounsel-legal外部律师协办隐去当事人真实身份
employment-legal离职 / 解雇文书外发隐去员工身份给监管
government-investigation调查取证材料外发隐去证人 / 举报人
law-student / legal-clinic教学案例改编公开案例库前脱敏

配套 references / 相邻 skill(不在本 SKILL.md 范围):

  • references/config.md — 白/黑名单 + 优先级 + 自定义类型(脱敏时按需 Read)
  • legal-document-restoration/ — 脱敏稿 runs 级还原 + 比对文件回填(另一操作)
  • shared/matter-workspace/ — 案件工作区管理(plugins/legal-scenes/<本场景>/matters/<slug>/ 为实际存储路径)

九、禁用与边界

  • ❌ 禁止对刑事证据原始件脱敏(仅副本可脱敏)
  • ❌ 禁止对未成年人信息默认采用粗粒度(必须细粒度+不可逆)
  • ❌ 禁止映射表入版本控制(加入 .gitignore,强制本地存储)
  • ❌ 禁止在不知道调用方角色时执行(按 GCL 规范,律师/客户/公众的脱敏要求不同)
  • ❌ 禁止脱敏稿与原文混存同一目录

十、版本与变更

版本日期变更
1.2.02026-06-24瘦身:移除优先级机制详细 / 白黑名单详细 / 还原流程详细 / 批次一致性 / useCaptureGroup 技术说明——拆为相邻 atomic skill。12→16 类实体扩展保留。
1.1.02026-06-24升级:12 类→16 类;新增优先级机制、上下文识别、还原流程、批次一致性(已被 v1.2.0 撤销)
1.0.02026-06-24初版:12 类实体 × 3 档粒度 × 5 大法域

★ Insight ─────────────────────────────────────

  • skill 原子化原则:一个 skill 只做一件事。脱敏 = 识别 + 替换。配置(白黑名单)、还原(反向)、批次(工作流)都是别的原子操作,应单独建 skill 或由调用方组织。
  • 借鉴 ≠ 复制:吸收参考项目的 16 类分类与上下文角色标注的业务洞察,不复制其工具架构与数据结构。洞察可跨实现,架构应适配载体。
  • 行数即约束:< 350 行是可持续维护的边界。超 500 行的 skill 必然塞了无关内容,且单 session 写不完。瘦身就是原子化体检。 ─────────────────────────────────────────────────

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Legal Document Redaction AI skill do?

法律文件脱敏——按场景白名单与法域规则,对判决书/合同/证据/邮件/聊天记录中的 16 类敏感实体进行识别、替换或遮蔽,输出可外发版本。 适用情形:用户要求脱敏/匿名化/可外发版本/隐去当事人/隐去姓名/隐去账号/隐去身份证号/做案例库分享稿/发律师函时隐去内部编号。 核心:识别 16 类敏感实体→按上下文标注角色→按脱敏规则映射表替换→可逆模式生成比对文件。 与 data-compliance 互补:data-compliance 是 PIPL 合规**审查**,本 skill 是脱敏**执行**。 配套 skill:白/黑名单与优先级见 legal-document-redaction-config;还原脱敏稿见 legal-document-restoration。

Why use Legal Document Redaction on TypingMind?

Because you install it once and use it with any model. Legal Document Redaction is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Legal Document Redaction in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/vivy-yi/Greater-China-Legal/tree/main/plugins/legal-operations/legal-document-redaction. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Legal Document Redaction?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Legal Document Redaction?

As many as you like. As long as a model supports skills, you can use Legal Document Redaction with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Legal Document Redaction AI skill free?

It is published on GitHub by vivy-yi. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇