
Legal Qa Extractor
- 99 installs
- 543 repo stars
- Updated August 5, 2026
- cat-xierluo/legal-skills
Extract valuable legal Q&A pairs from lawyer-client conversation records into a structured knowledge base, with strict client de-identification.
About
Extracts valuable legal question-answer pairs (client question plus lawyer answer) from lawyer-client communication records into structured knowledge-base content with strict client de-identification. A developer or lawyer uses it to turn consultation records into reusable articles, cases, or learning material.
- Extracts reusable client-question and lawyer-answer pairs
- Strict client information de-identification
Legal Qa Extractor by the numbers
- 99 all-time installs (skills.sh)
- Ranked #649 of 1,879 Documentation skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/cat-xierluo/legal-skills --skill legal-qa-extractorAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 99 |
|---|---|
| repo stars | ★ 543 |
| Last updated | August 5, 2026 |
| Repository | cat-xierluo/legal-skills ↗ |
What it does
Extract valuable legal Q&A pairs from lawyer-client conversation records into a structured knowledge base, with strict client de-identification.
Files
法律问答提取技能
概述
从律师与客户的沟通记录中提取有价值的法律问答对(客户问题 + 律师解答),生成结构化知识库内容。适用于将客户咨询转化为可复用的法律知识,供后续整理成文章、案例或学习材料。
核心价值:提取那些可以被其他客户复用的问答内容,而不是单一客户的具体案情。
核心原则
客户信息保护
绝对禁止在问答内容中包含:
- ❌ 客户真实姓名
- ❌ 企业/机构名称
- ❌ 具体地址、联系方式
- ❌ 任何可识别个人或企业的信息
脱敏处理标准:
- ✅ 客户姓名 → 使用"当事人"、"客户"、"甲/乙"等代称
- ✅ 企业名称 → 使用"某公司"、"某企业"、"该企业"等代称
- ✅ 具体信息 → 模糊化为"某地"、"某时间"、"相关人员"等
- ✅ 客户原话 → 脱敏后引用:"客户询问..."而非"张总说..."
问答对的价值判断
提取的问答应该满足以下条件之一:
- 普遍性:其他客户也可能遇到同类问题
- 典型性:代表了某类法律场景的常见关切
- 教育性:律师的解答有普法价值或指导意义
- 复用性:可以独立成文或作为知识库条目
工作流程
步骤 1:分析输入内容
获取沟通记录文档和用户的具体要求,理解:
- 文档中的沟通内容和情境
- 用户希望重点关注哪些方面
- 哪些问答具有复用价值
步骤 2:识别有价值的问答对
完整梳理文档中的问答内容,按以下维度识别价值:
问答识别维度
1. 直接问答 - 客户明确提出问题,律师给出解答 2. 追问回应 - 客户追问,律师进一步解释 3. 风险提醒 - 律师主动提醒的风险点及应对建议 4. 操作指引 - 涉及流程、步骤、注意事项的问答 5. 普遍关切 - 其他客户也可能遇到的同类问题
问答提取方法
- 语义分析:理解客户真实问题和律师核心观点
- 逻辑归纳:将分散的对话整理为独立问答对
- 价值评估:判断问答是否具有普遍适用性
- 标准化表述:将口语化表达转化为规范的问答格式
步骤 3:生成结构化报告
输出文件保存至原文档的同一目录,文件命名:{原文档名}_法律问答提取_{YYYYMMDD}.md
输出格式详见 output-template.md。
每个问答对包含以下部分:
- 问题:客户提出的问题(标准化表述)
- 律师解答:律师的核心观点和建议(300-500字)
- 问题背景(可选):该问题出现的情境(200-300字)
- 价值标签:普遍性/典型性/教育性/复用性
- 适用场景:什么情况下读者会关心这个问答
步骤 4:问答分类与关联
提供以下分析维度:
- 问答特征分析:重点问答数量、常规问答数量、价值分布
- 领域分类:按法律领域或业务场景分类
- 关联分析:哪些问答之间存在关联、可组合成文章
质量标准
- 独立性:每个问答对可以独立理解,不依赖完整对话背景
- 普遍性:问答内容对其他客户也有参考价值
- 完整性:问题和解答都清晰完整,没有断章取义
- 脱敏严格:严格遵循客户信息保护规则
- 可复用:提取的问答可以直接用于文章、知识库或学习材料
输入要求
本技能接受以下类型的输入:
1. 文档路径:用户提供的沟通记录文档路径 2. 粘贴内容:用户直接粘贴的沟通记录内容 3. 用户要求:用户希望重点关注哪些类型的问答
配置与归档
用户配置
本技能支持通过 config/.env 文件自定义扫描行为:
# 复制模板
cp config/.env.example config/.env
# 编辑配置
QA_EXTRACTOR_SCAN_PATHS=~/Desktop/Clawd/10 - ⚖️ 法律工作/工作文档/011 - 潜在项目
QA_EXTRACTOR_SCAN_DEPTH=3
QA_EXTRACTOR_FILE_TYPES=md,txt扫描记录
技能会维护 archive/scan-log.json 记录扫描状态:
{
"version": "1.1.0",
"last_full_scan": "2026-05-10T23:00:00+08:00",
"watch_paths": [
{
"path": "~/Desktop/Clawd/10 - ⚖️ 法律工作/工作文档/011 - 潜在项目",
"last_scanned": "2026-05-10T23:00:00+08:00",
"status": "active"
}
],
"projects": {
"潜在项目_A": {
"source_files": ["path/to/file1.md", "path/to/file2.md"],
"last_extracted": "2026-05-10",
"qa_count": 8,
"output_file": "archive/extractions/2026-05-10_潜在项目_A_qa.md",
"status": "active"
}
},
"files": {
"path/to/file.md": {
"content_hash": "sha256:abc123...",
"last_modified": "2026-05-09",
"last_extracted": "2026-05-10",
"qa_count": 5,
"status": "active"
}
},
"archived": {
"path/to/old_project": {
"archived_at": "2026-05-01",
"reason": "moved_by_user"
}
}
}字段说明:
| 字段 | 用途 |
|---|---|
files.*.content_hash | 文件内容指纹,变化时触发重新提取 |
files.*.status | active / archived,归档后跳过扫描 |
projects.*.source_files | 同一项目的多份沟通记录,合并输出 |
projects.*.status | active / archived,项目归档后锁定 |
archived.* | 记录已移走的路径,防止重复扫描 |
增量扫描逻辑:
文件夹类型判断(用于识别归档与活动项目):
| 命名模式 | 类型 | 处理方式 |
|---|---|---|
纯数字 / 日期区间(如 24、25 01-06、26 01-06) | 归档容器 | 深度扫描内部子文件夹 |
日期+姓名(如 260323 张美金...、260404 顾忆芬...) | 直接项目 | 直接扫描该文件夹 |
| 其他 | 项目 | 直接扫描该文件夹 |
1. 遍历 watch_paths 下所有直接子文件夹 2. 判断每个文件夹类型(归档容器 / 直接项目) 3. 对归档容器递归扫描;对直接项目扫描内容文件 4. 对每个文件计算 content_hash 5. 若文件不在 scan-log,或 hash 与记录不一致 → 触发提取 6. 若项目内所有文件均变化才触发提取 7. 提取完成后,按项目合并多份记录,输出单份 QA 文件
抽取结果归档
抽取的问答对保存在 archive/extractions/ 目录,按项目聚合:
archive/
├── scan-log.json # 扫描状态记录
└── extractions/
├── 2026-05-10_潜在项目_A_qa.md # 项目A的多轮咨询合并
├── 2026-05-10_潜在项目_B_qa.md # 项目B的单次记录
└── 2026-05-11_潜在项目_C_qa.md # 项目C(后续增量新增)多轮咨询合并逻辑:
- 同一项目文件夹内的所有
.md/.txt文件视为同一项目的多轮沟通 - 提取时按文件顺序(文件名或修改时间)整合所有问答对
- 去重:相同问题的多次出现保留最新解答
- 输出文件名:
{日期}_{项目名}_qa.md
注意:archive/ 目录不纳入 Git 版本控制。
适用场景
- 整理客户咨询记录为可复用知识
- 从对话中提取内容营销素材
- 建立法律问答知识库
- 准备普法文章的素材
- 制作客户常见问题清单
- 定时扫描项目文件夹,增量提取新内容
01 单问题咨询
- 场景:整段咨询围绕一个核心法律问题展开,中间只有少量事实补充。
- 关注点:是否只生成 1 张主卡;长摘要是否覆盖完整回答。
- 通过标准:不重复建卡,不遗漏关键结论。
02 多问题跳转
- 场景:客户在同一通话中从实体判断跳到证据、时效、程序,再回到原问题。
- 关注点:是否能拆出多个具体问题,而不是混成一张大卡。
- 通过标准:不同求解目标分别成卡,排序仍保持清晰。
03 同题多次重提
- 场景:同一问题在通话前中后被反复提起,客户每次表述略有变化。
- 关注点:是否合并为一张主卡,并通过“过程痕迹”体现多次提起。
- 通过标准:同题不重复建卡,过程痕迹完整。
04 多轮追问
- 场景:客户围绕同一问题连续追问例外情形、计算方式或应对路径。
- 关注点:哪些追问应归并,哪些应拆卡。
- 通过标准:归并边界稳定,必要时标
待确认。
05 律师主动风险提醒
- 场景:客户主要叙述事实,律师主动指出潜在法律风险、证据问题或程序风险。
- 关注点:是否能识别为有效主卡,而不是忽略。
- 通过标准:能以“风险提醒”或相关类型形成主卡。
06 行政沟通占比高
- 场景:大量内容是排期、报价、付款、发材料,真正法律问题很少。
- 关注点:是否会过度抽取无效卡片。
- 通过标准:只保留真正的法律问题,其余内容不单独成卡。
07 回答不完整
- 场景:客户问题明确,但律师回答被打断、尚未展开完毕,或明显依赖未补充事实。
- 关注点:是否把结果保守标为
待补充或待确认。 - 通过标准:不把残缺回答伪装成完整结论。
08 目录批处理混合场景
- 场景:目录里同时包含咨询文本、行政沟通文本、历史抽取结果、隐藏文件和非文本文件。
- 关注点:扫描范围、排除逻辑、跳过原因是否稳定。
- 通过标准:只处理有效文本,跳过项说明清楚,不生成总索引文件。
Benchmark 样本说明
本目录不存放真实客户材料,只存放脱敏样本设计说明,用于回归测试 legal-qa-extractor 的输出稳定性。
样本列表
01-single-issue.md:单问题咨询02-multi-issue-switching.md:多问题跳转03-same-issue-repeated.md:同题多次重提04-follow-up-questions.md:多轮追问05-proactive-risk-reminder.md:律师主动风险提醒06-admin-heavy.md:行政沟通占比高07-incomplete-answer.md:回答不完整08-batch-mixed-directory.md:目录批处理混合场景
使用方式
- 每次调整
SKILL.md、输出模板或规则文档后,至少按上述 8 类场景做一次纸面回归。 - 若有真实脱敏咨询记录,可将其映射到最接近的样本类型,复核输出是否满足
references/benchmark-rubric.md。
变更日志
[1.1.0] - 2026-05-10
新增
config/.env.example:用户自定义配置模板,支持扫描路径、深度、文件类型配置archive/目录:扫描记录与抽取结果本地归档,与 git 完全隔离- 增量扫描:基于 content_hash 判断文件是否变化,变化才触发提取
- 项目级聚合:同一子文件夹内的多份沟通记录合并为单份 QA 输出
- 归档识别:
archived机制追踪已移走的路径,跳过归档后的项目
改进
- scan-log 格式升级:从文件列表升级为含 hash、status、projects 的结构化格式
- 抽取结果按项目/日期组织到
archive/extractions/
正式版发布
- 从
test/目录迁移至skills/正式目录 - 功能完整,经过验证,正式发布使用
---
[0.1.0] - 2026-02-07
新增
- 从 extract-law command 转换为 skill 格式
- 从律师与客户沟通记录中提取有价值的法律问答对
- 支持 5 个问答识别维度(直接问答、追问回应、风险提醒、操作指引、普遍关切)
- 严格的客户信息脱敏处理机制
- 结构化输出格式(Q&A 形式)
- 问答分类与关联分析功能
改进
- 适配 skill 触发机制,使用自然对话替代命令调用
- 将输出模板移至 references/output-template.md,保持 SKILL.md 简洁
- 简化工作流程描述,聚焦问答对提取
优化
- 定位调整:从"法律问题提炼"调整为"法律问答提取",更准确反映技能核心价值
- 输出格式:从"问题-分析-背景-解决方案"改为"Q&A"格式,更适合知识复用
- 价值判断:新增价值标签(普遍性、典型性、教育性、复用性)
文档完善
- 创建 SKILL.md 核心文档
- 创建 references/output-template.md 输出模板参考
- 添加 MIT 许可证
---
原始版本记录(Command 时期)
v2.7 (2025-10-30)
- 添加严格的客户信息保护机制:所有问题分析报告必须脱敏处理,绝不包含客户姓名、企业名称等敏感信息
v2.6 (2025-10-29)
- 统一输出目录:输出文件保存至原文档所在目录
v2.5 (2025-10-28)
- 增强分析深度:明确各部分字数要求(详细分析300-500字、问题背景200-300字、解决方案300-400字)
v2.4 (2025-10-28)
- 简化输出格式:将详细的无序列表改为段落文字总结
v2.3 (2025-10-28)
- 专注提炼:删除营销建议,增强问题分析的细致性
v2.2 (2025-10-28)
- 全面优化:增强问题分析维度、详细营销建议、平台适配方案
v2.1 (2025-10-28)
- 修复:全面分析文档中的所有法律问题,不仅限于用户关注的重点
v2.0 (2025-10-28)
- 大幅简化流程,专注于从文档中提炼法律问题
v1.0 (2025-10-28)
- 初始版本
# 法律问答提取技能 - 用户配置
# 复制此文件为 .env 并填入你的实际路径
# === 扫描配置 ===
# 要扫描的根目录(支持多个目录,用逗号分隔)
# 示例:~/Desktop/Clawd/10 - ⚖️ 法律工作/工作文档/011 - 潜在项目
QA_EXTRACTOR_SCAN_PATHS=~/Desktop/Clawd/10 - ⚖️ 法律工作/工作文档/011 - 潜在项目
# 扫描深度(默认:3)
# 0 = 仅扫描根目录,1 = 扫描到二级文件夹,2 = 扫描到三级文件夹,以此类推
QA_EXTRACTOR_SCAN_DEPTH=3
# 扫描文件类型(用逗号分隔)
QA_EXTRACTOR_FILE_TYPES=md,txt
# === 输出配置 ===
# 抽取结果保存目录(默认:archive/extractions)
QA_EXTRACTOR_OUTPUT_DIR=archive/extractions
# === 脱敏配置 ===
# 是否自动脱敏(默认:true)
QA_EXTRACTOR_AUTO_ANONYMIZE=true
Creative Commons Attribution-NonCommercial 4.0 International
Copyright (c) 2025 杨卫薪律师(微信ywxlaw)
=======================================================================
This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
You are free to:
- Share — copy and redistribute the material in any medium or format
- Adapt — remix, transform, and build upon the material
Under the following terms:
- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made.
- NonCommercial — You may not use the material for commercial purposes.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
To view a copy of this license, visit:
https://creativecommons.org/licenses/by-nc/4.0/
=======================================================================
Commercial License
For commercial use licenses, please contact:
Email: secretxierluo@gmail.com
WeChat: ywxlaw (微信)
=======================================================================
The full text of the CC BY-NC 4.0 license is reproduced below:
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING
FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Section 1 – Definitions.
Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
Copyright and Similar Rights means copyright and/or similar rights closely related to copyright, including without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
Licensor means the individual(s) or entity(ies) granting rights under this Public License.
NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
Section 2 – Scope.
Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
a) reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
b) produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
Term. The term of this Public License is specified in Section 6(a).
Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
Downstream recipients. Each recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by the Licensor or others designated as receiving attribution as provided in Section 3(a)(1)(A)(i).
Other rights. Moral rights, rights against unfair competition, rights to protect publicity, privacy, or personality rights, and any other rights other than Copyright and Similar Rights are not subject to this Public License. Additional rights may apply to the Licensed Material, such as patent, trademark, or other intellectual property rights.
Section 3 – License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
Attribution.
If You Share the Licensed Material (including in modified form), You must:
a) retain the following if it is supplied by the Licensor with the Licensed Material:
i) identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
ii) a copyright notice;
iii) a notice that refers to this Public License;
iv) a notice that refers to the disclaimer of warranties;
v) a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
b) indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
c) indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
If requested by the Licensor, You must remove any of the information required by Section 3(a)(1) to the extent reasonably practicable.
NonCommercial. You may not exercise the Licensed Rights for commercial purposes.
Section 4 – Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
a) for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only; and
b) if You include all or a substantial portion of the contents of the database in a database to which You have Adapted Material, then You must comply with Section 3(a) if You Share the Adapted Material.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
Section 5 – Disclaimer of Warranties and Limitation of Liability.
Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or out of the use or inability to use the Licensed Material, even if the Licensor has been advised of the possibility of any such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
Section 6 – Term and Termination.
a) This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically and are reverted.
b) Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation.
c) For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
d) Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
Section 7 – Other Terms and Conditions.
a) The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
b) Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
Section 8 – Interpretation.
a) For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
b) If any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable.
c) If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
d) No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
e) Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
=======================================================================
Creative Commons may be contacted at creativecommons.org.
目录批处理规则
本规则定义 legal-qa-extractor 在接收目录路径时的稳定行为。
一、适用范围
目录模式第一版只处理已经转换为文本的咨询记录:
.md.txt
不直接处理:
- DOCX
- 音频、视频
- 图片
二、扫描规则
1. 默认递归
输入一个目录路径后,默认递归扫描全部子目录。
2. 候选文件类型
只将以下文件纳入候选:
*.md*.txt
3. 默认排除项
以下文件或目录默认不进入候选集:
- 隐藏文件(以
.开头) - 隐藏目录中的文件
- 非文本文件
- 已生成结果文件:
*_法律问答提取_*.md
4. 稳定排序
候选文件应按相对路径字典序排序后再处理,确保同一目录多次运行时处理顺序一致。
三、逐文件处理规则
对每个候选文件,按单文件模式执行: 1. 读取文本 2. 根据 intake-checklist.md 判断是否适合抽取 3. 适合则生成单文件输出 4. 不适合则跳过,并记录原因
单文件结果仍保存到源文件同目录,命名规则保持: {原文档名}_法律问答提取_{YYYYMMDD}.md
四、跳过规则
当出现以下情形时,应跳过该文件:
- 文件虽为文本,但主体并非咨询记录
- 基本没有可识别的法律问题
- 几乎全是行政沟通、报价、排期、材料流转
- 文本严重残缺,无法形成稳定问题主卡
- 文件本身就是已生成的历史抽取结果
跳过时:
- 不生成结果文件
- 在本次批处理返回中写出“相对路径 + 简短原因”
五、目录模式返回摘要
批处理完成后,AI 在对话中应返回简短摘要,包括:
- 已处理文件数
- 已跳过文件数
- 跳过原因分类
- 是否存在高比例
待确认文件
示例:
批量处理完成:
- 已处理:12 份
- 已跳过:4 份
- 跳过原因:行政沟通为主 2 份,已生成结果文件 1 份,文本残缺 1 份
- 需人工重点复核:3 份(待确认主卡占比较高)六、明确不做的事情
目录模式第一版不做:
- 生成目录级总索引文件
- 统一汇总全部主卡到单一大文件
- 自动调用其他技能处理 PDF、DOCX、音频
- 对目录中每个无效文件都生成“空结果文件”
回归测试与验收标准
本 Rubric 用于评估 legal-qa-extractor 在不同咨询场景中的稳定性。
一、Hard Fail 条件
出现以下任一情况,直接判定为不通过:
1. 泄露客户身份信息或企业可识别信息 2. 重复扫描或处理已生成的 *_法律问答提取_*.md 3. 将原文不存在的法律结论写入主卡摘要 4. 将两个明显不同的问题错误合并成一张主卡 5. 将明显不完整的回答写成确定结论,且未标 待补充 或 待确认
二、评分维度
每个维度按 0 / 1 / 2 评分:
2= 稳定符合预期1= 基本可用,但存在可见瑕疵0= 明显失真或无法使用
1. 问题识别
- 2:主要法律问题全部识别,边界清晰
- 1:识别出主要问题,但漏掉次要问题或个别边界含糊
- 0:漏掉主要问题,或大量把非问题内容误判为问题
2. 同题归并
- 2:同一问题稳定合并,不重复建卡
- 1:大体合并正确,但个别追问处理不稳
- 0:频繁重复建卡或错误合并不同问题
3. 摘要忠实性
- 2:长摘要与要点都忠实、完整、不越权扩写
- 1:基本忠实,但有轻微压缩失衡或表达漂移
- 0:摘要明显加入原文没有的判断,或遗漏核心结论
4. 完整度与置信度标记
- 2:
完整 / 基本完整 / 待补充与正常 / 待确认使用稳定 - 1:偶有过严或过松,但整体可接受
- 0:边界模糊内容未被标记,或滥用标记导致结果失真
5. 双层标签稳定性
- 2:知识库标签与内容标签口径稳定、可解释
- 1:个别标签存在主观漂移,但不影响整体使用
- 0:标签混乱或与主卡内容明显不符
6. 批处理行为
- 2:扫描范围、排除逻辑、跳过策略均稳定
- 1:偶有误扫或跳过说明不充分
- 0:重复处理结果文件、误处理非文本或批处理行为不稳定
三、通过标准
- 无 Hard Fail
- 六项评分总分至少
10 / 12 - 其中“问题识别”“同题归并”“摘要忠实性”三项不能为 0
四、建议样本集
建议使用 assets/benchmarks/ 下的 8 类场景做回归:
1. 01-single-issue.md 2. 02-multi-issue-switching.md 3. 03-same-issue-repeated.md 4. 04-follow-up-questions.md 5. 05-proactive-risk-reminder.md 6. 06-admin-heavy.md 7. 07-incomplete-answer.md 8. 08-batch-mixed-directory.md
五、记录模板
## 回归记录
- **样本**:
- **日期**:
- **问题识别**:0 / 1 / 2
- **同题归并**:0 / 1 / 2
- **摘要忠实性**:0 / 1 / 2
- **完整度与置信度**:0 / 1 / 2
- **双层标签稳定性**:0 / 1 / 2
- **批处理行为**:0 / 1 / 2
- **是否触发 Hard Fail**:否 / 是
- **结论**:通过 / 需调整
- **备注**:问题识别与归并规则
本规则用于稳定生成“问题主卡”,避免在不同咨询文本中发生卡片边界漂移。
一、主卡单元定义
主卡的最小单元是“具体法律问题”,而不是:
- 单次发言
- 一轮问答
- 一个自然段
- 一个法律领域大类
示例:
- “公司单方调岗是否合法?” -> 一个主卡
- “如果我不同意调岗,后面被解除怎么办?” -> 与前一问题有关,但属于不同的后续法律问题,应视内容决定是否拆卡
- “补偿怎么算?” -> 如独立构成新的求解目标,应单独成卡
二、允许进入主卡的问题类型
1. 直接提问
客户明确提出问题,律师给出回应。
2. 追问补充
客户围绕同一问题继续追问、补充情境或缩小范围。
3. 律师主动风险提醒
客户未明确提问,但律师主动提示风险、后果、底线或常见误区。
4. 律师主动操作指引
律师主动给出流程、准备材料、沟通策略、证据保留等操作建议。
5. 隐含问题
客户虽然主要在叙述事实,但其真实意图明显是在寻求法律判断或路径建议。
三、同题归并规则
以下情形原则上合并为一张主卡:
- 同一法律问题在前后多次出现
- 后续只是补充事实、追加细节、追问例外情形
- 律师在前面回答核心结论,后面补充风险或操作建议
- 客户换了口语表达方式,但实质问的仍是同一问题
归并后必须在“过程痕迹”中体现:
- 首次提出
- 补充事实
- 追问 / 再次提起
- 补充回答
四、拆卡规则
以下情形必须拆成不同主卡:
- 虽然发生在同一通话里,但求解目标不同
- 对应不同法律判断路径或不同操作决策
- 前一个问题讨论是否合法,后一个问题讨论如何举证、如何补偿、如何起诉
- 前一个问题围绕实体权利,后一个问题围绕程序、时效、证据或执行
判断标准不是“话题相近”,而是“能否用一套回答稳定覆盖”。如果不能,就应拆卡。
五、默认排除项
以下内容默认不形成主卡:
- 寒暄和过渡性表达
- 预约时间、付款、报价、沟通渠道
- 发材料、补资料、加联系方式
- 单纯情绪表达,且没有形成法律求解问题
- 纯背景铺垫,但后续没有承接法律判断
必要时,可将这些内容只作为已有主卡的“适用事实边界”或“过程痕迹”辅助信息,而不是单独建卡。
六、忠实总结规则
1. 长摘要
- 建议长度:200-400 字
- 目标是完整总结律师的核心解答
- 允许压缩口语、归并前后段落
- 不得引入原文没有的法条、判例或策略
2. 关键要点 bullet
- 建议 3-6 条
- 覆盖结论、风险、操作建议、限制条件
- 不能只写空泛标题,如“注意风险”“保存证据”
3. 适用事实边界
- 简洁写出该主卡成立所依赖的事实前提
- 不复述全部案情
- 不写可识别个人或企业信息
七、完整度与置信度规则
完整度
完整:问题和核心回答都比较完整基本完整:主要结论清楚,但仍有少量缺口待补充:问题已可识别,但回答明显残缺或事实前提不足
置信度
正常:问题边界、归并关系和回答方向都较明确待确认:存在以下任一情形- 同题归并边界存疑
- 客户/律师发言归属偶有混淆
- 追问是否应拆卡不完全确定
- 回答只覆盖部分情形,且文本噪声较大
对不确定内容,应优先使用 待确认,而不是强行给出确定表达。
八、双层标签判断规则
知识库标签
先判断其是否适合作为长期知识单元沉淀:
- 是否高频常见
- 是否具有可复用标准解释
- 是否适合作为风险提醒或操作流程
- 是否主要是时效、证据、程序性问题
- 是否过于依赖个案事实,导致不宜泛化
内容输出标签
在知识库标签之后,再做粗筛:
- 是否适合写成长文解释
- 是否适合做短内容提醒
- 是否适合做 FAQ
- 是否带有反常识或传播点
- 是否暂不建议内容化
如果问题明显个案化、争议点过窄、事实缺口太大,应优先标为 暂不建议内容化。
九、排序规则
主卡默认按“话题归并后排序”,而不是按对话原顺序排序。
建议排序逻辑: 1. 先按主要法律主题分组 2. 再按问题的重要程度或复用价值排序 3. 同一主题内,先放基础判断,再放操作路径、风险提醒、证据/程序问题
这样更利于后续知识库沉淀和内容池筛选。
输入检查清单
本清单用于判断一份输入是否适合交给 legal-qa-extractor 处理,以及在何种情况下应标记 待确认 或直接跳过。
一、可直接处理的输入
满足以下条件时,可直接进入问答抽取:
- 文件或粘贴文本主体为咨询记录、电话转录、沟通纪要
- 能大致判断客户和律师的发言边界
- 文本中存在明确或隐含的法律求解问题
- 记录主体为中文,且整体可读
- 单文件为
.md或.txt;目录模式下候选文件同样只限.md、.txt
二、可处理但需谨慎标注的输入
满足以下情况时仍可抽取,但应对相关主卡标记 待确认 或 待补充:
- 客户与律师发言偶有混杂,但大部分段落仍可判断
- 口语化明显,存在少量转录错误,但不影响总体理解
- 同一问题前后多次出现,边界需要依靠归并判断
- 律师回答明显不完整,或只回答了问题的一部分
- 对事实前提把握不足,导致部分结论只能保守表达
三、应直接跳过的输入
出现以下情况时,不应输出正式问答结果:
- 纯音频、视频、PDF、DOCX 或截图,尚未转换为文本
- 全文几乎无法区分客户与律师发言
- 全文主要是行政沟通、排期、报价、付款、材料流转,没有形成法律问题
- 文本严重残缺、乱码或只有零散句子,无法形成稳定问题单元
- 目录模式下扫描到已生成的
*_法律问答提取_*.md
目录模式遇到跳过文件时:
- 不生成结果文件
- 在批处理摘要中说明相对路径和跳过原因
四、单文件模式最少判断项
在开始提取前,至少回答以下四个问题:
1. 这是不是咨询文本,而不是一般聊天或行政沟通? 2. 能不能识别出至少一个具体法律问题? 3. 能不能大致判断律师对该问题做了什么解答? 4. 是否存在需要保守标记 待确认 的边界模糊内容?
如果前 3 个问题中有任一答案是否定的,则不应勉强出卡。
五、目录模式最少判断项
对目录中每个候选文件执行以下判断:
1. 文件是否为 .md 或 .txt 2. 文件名是否不是隐藏文件,路径中是否不存在隐藏目录 3. 文件名是否不是 *_法律问答提取_*.md 4. 文件主体是否存在咨询性质内容 5. 文件是否至少能形成一个稳定问题单元
仅在 1-5 全部成立时,才进入正式抽取。
法律问答提取输出模板
输出文件命名规则
- 文件位置:原文档的同一目录
- 文件命名:
{原文档名}_法律问答提取_{YYYYMMDD}.md
输出内容模板
# {主题}法律问答提取
## 📋 基本信息
**提取时间**:{时间}
**原始文档**:{文档名称}
**用户要求**:{用户的具体要求}
---
## 💬 重点问答对
*这些是您重点关注或有高复用价值的问答*
### 问答 1:{问题标题}
**Q:{客户提出的问题}**
**A:**
{律师的解答,用300-500字的段落文字,清晰表达律师的核心观点、法律依据、操作建议和注意事项。确保解答完整、准确,读者可以独立理解并应用。}
**问题背景**(可选):
{该问题出现的情境,用200-300字说明。包括:客户在什么情况下提出这个问题、涉及什么样的法律关系、为什么这个问题值得被记录。如果问题本身很清晰,可以省略此部分。}
**价值标签**:普遍性 / 典型性 / 教育性 / 复用性
**适用场景**:{什么情况下读者会关心这个问答}
---
### 问答 2:{问题标题}
**Q:{客户提出的问题}**
**A:**
{律师解答}
**问题背景**(可选):
{问题情境}
**价值标签**:普遍性 / 典型性 / 教育性 / 复用性
**适用场景**:{适用场景}
---
## 📌 常规问答对
*文档中发现的其他有价值的问答*
### 问答 3:{问题标题}
**Q:{客户提出的问题}**
**A:**
{律师解答}
**价值标签**:普遍性 / 典型性 / 教育性 / 复用性
**适用场景**:{适用场景}
---
## 💡 提取总结
### 问答特征分析
从该文档中共提取出{X}个问答对:
- **重点问答**:{X}个(您关注的高价值内容)
- **常规问答**:{X}个(其他有价值的问答)
**价值分布**:
- 普遍性:{X}个(其他客户也可能遇到)
- 典型性:{X}个(代表某类法律场景)
- 教育性:{X}个(有普法或指导价值)
- 复用性:{X}个(可直接用于文章或知识库)
### 领域分类
按法律领域或业务场景分类:
| 领域/场景 | 问答数量 | 问答编号 |
|----------|----------|----------|
| {领域1} | {X}个 | 1, 3, 5 |
| {领域2} | {X}个 | 2, 4 |
| {领域3} | {X}个 | 6 |
### 关联分析
**可组合的问答组**:
- **{主题1}**:问答 {1, 3, 5} 可以组合成一篇关于{主题1}的文章
- **{主题2}**:问答 {2, 4} 可以组合成一篇关于{主题2}的文章
**文章建议**:
- {建议1}:可以写一篇"{文章标题}",整合问答 {1, 2, 3}
- {建议2}:可以写一篇"{文章标题}",整合问答 {4, 5, 6}
**复用价值**:
- 高价值问答(适合做头条内容):{问答编号}
- 中价值问答(适合做补充内容):{问答编号}
- 基础问答(适合做FAQ):{问答编号}字数要求说明
| 部分 | 字数要求 | 说明 |
|---|---|---|
| 律师解答 | 300-500字 | 核心观点、法律依据、操作建议、注意事项 |
| 问题背景 | 0-300字 | 可选,仅在问题需要情境说明时填写 |
价值标签说明
| 标签 | 含义 |
|---|---|
| 普遍性 | 其他客户也可能遇到的同类问题 |
| 典型性 | 代表了某类法律场景的常见关切 |
| 教育性 | 律师解答有普法价值或指导意义 |
| 复用性 | 可以独立成文或作为知识库条目 |
脱敏处理规范
在撰写问答内容时,必须严格遵循以下脱敏规则:
| 原始信息 | 脱敏后 |
|---|---|
| 客户真实姓名 | "当事人"、"客户"、"甲/乙" |
| 企业/机构名称 | "某公司"、"某企业"、"该企业" |
| 具体地址 | "某地"、"某城市" |
| 具体时间 | "某时间"、"相关时间" |
| 具体联系方式 | 完全省略或用"联系方式"代替 |
| 客户原话 | 脱敏后引用:"客户询问..."而非"张总说..." |
问答独立性原则
提取的每个问答对必须满足:
- 可独立理解:读者不需要看完整对话就能理解问答
- 完整信息:问题和解答都清晰完整,没有断章取义
- 脱敏严格:不包含任何可识别特定客户的信息
- 普遍价值:对其他客户也有参考意义
人工复核清单
本清单用于人工检查 legal-qa-extractor 的单文件结果和批处理行为是否符合预期。
一、隐私与合规
- [ ] 未出现客户真实姓名
- [ ] 未出现企业全称、统一社会信用代码、具体联系方式
- [ ] 未保留足以识别个体的精确身份信息
- [ ] 时间、地点等事实信息只保留到法律判断必要程度
二、问题主卡边界
- [ ] 每张主卡都对应一个具体法律问题
- [ ] 没有把两个不同问题错误合并
- [ ] 没有把同一问题拆成多张重复主卡
- [ ] 同一问题的追问和补充,已体现在“过程痕迹”中
三、摘要忠实性
- [ ] 律师回答长摘要没有引入原文没有的结论
- [ ] 关键要点 bullet 覆盖了主要结论、风险或操作建议
- [ ] 对明显不完整的回答,已标注
待补充 - [ ] 对边界模糊的内容,已标注
待确认
四、标签判断
- [ ] 知识库标签与主卡内容匹配
- [ ] 内容输出标签只做粗筛,没有越权展开为策划结论
- [ ] 个案性过强的问题已使用“个案性较强”或“不宜沉淀”
- [ ] 暂不适合内容化的问题已使用“暂不建议内容化”
五、输出结构稳定性
- [ ] 包含“基本信息”“问题总览”“Q&A 主卡”“简短结尾说明”四个固定部分
- [ ] 每张主卡字段完整,无缺漏
- [ ] 未展示时间戳或原句证据
- [ ] 未输出文章大纲、传播建议、组合选题等内容
六、目录批处理行为
- [ ] 默认递归扫描子目录
- [ ] 只处理
.md、.txt - [ ] 已排除隐藏文件和隐藏目录
- [ ] 已排除
*_法律问答提取_*.md - [ ] 不适合抽取的文件被跳过并给出简短原因
- [ ] 未生成目录级总索引文件
七、复核结论建议
人工复核结束后,建议按以下格式记录:
## 复核结论
- **样本名称**:
- **是否通过**:通过 / 需调整
- **主要问题**:
-
- **建议修正**:
-扫描与归档规格说明
本文档定义 archive/scan-log.json 的结构规范和扫描行为,供定时任务和未来 Agent 理解。
---
一、watch_paths 配置
"watch_paths": [
{
"path": "~/Desktop/Clawd/10 - ⚖️ 法律工作/工作文档/011 - 潜在项目",
"last_scanned": "2026-05-10T23:00:00+08:00",
"status": "active"
}
]- 每次全量扫描后更新
last_scanned status:active|archived
---
二、文件夹类型判断
| 命名模式 | 示例 | 类型 | 扫描方式 |
|---|---|---|---|
| 纯数字 | 24 | 归档容器 | 深度扫描内部每个子文件夹 |
| 日期区间 | 25 01-06、26 01-06 | 归档容器 | 深度扫描内部每个子文件夹 |
| 日期+姓名/公司 | 260323 张美金 浙江腾宇包装公司 咨询 | 直接项目 | 直接扫描内容文件 |
| 其他 | 240428 薛心澄房屋买卖转移登记 | 直接项目 | 直接扫描内容文件 |
关键原则:归档容器本身不输出 QA,其内部的每个子文件夹才是独立项目。
---
三、files 记录
"files": {
"path/to/file.md": {
"content_hash": "sha256:abc123...",
"last_modified": "2026-05-09",
"last_extracted": "2026-05-10",
"qa_count": 5,
"status": "active"
}
}content_hash:文件内容 SHA-256,仅计算文件内容,不含路径/mtime- 增量判断:hash 一致 → 跳过;hash 变化或文件新增 → 触发提取
status:active|archived(文件被移走后从files移到archived)
---
四、projects 聚合
"projects": {
"240428 薛心澄房屋买卖转移登记": {
"source_files": ["240428 薛心澄.../沟通记录1.md", "240428 薛心澄.../沟通记录2.md"],
"last_extracted": "2026-05-10",
"qa_count": 8,
"output_file": "archive/extractions/2026-05-10_240428 薛心澄..._qa.md",
"status": "active"
}
}- 一个项目 = 一个直接子文件夹(不含归档容器内的子项目)
- 多轮咨询合并:同一项目下所有
.md/.txt文件合并为单份 QA 输出 - 去重:相同问题保留最新解答
- 输出文件命名:
{日期}_{项目名}_qa.md
---
五、archived 记录
"archived": {
"011 - 潜在项目/24/240428 薛心澄": {
"archived_at": "2026-05-01",
"reason": "moved_to_archived_folder",
"last_known_qa_count": 3
}
}- 用户归档操作后,将对应路径及其下文件标记为
archived - 扫描时跳过所有
status: archived的路径 - 定期清理
archived记录(超过 6 个月的可删除)
---
六、扫描流程摘要
1. 加载 scan-log.json
2. 遍历 watch_paths 下的直接子文件夹
3. 判断每个文件夹类型(归档容器 / 直接项目)
4. 归档容器 → 递归获取所有子文件夹 → 每个子文件夹视为一个项目
5. 直接项目 → 直接作为项目处理
6. 对每个项目的文件计算 content_hash
7. 对比 scan-log:hash 变化或文件新增 → 触发提取
8. 提取完成 → 更新 files 和 projects 记录
9. 保存 scan-log.json