法律文书模板与导出

From pa1nrui1/legal-skills · View interactive version

法律文书模板与导出 is an AI agent skill from the GitHub repository pa1nrui1/legal-skills. 统一处理法律工作中最终需要输出本地 Word(.docx)的文书、报告、清单、笔录、意见书、函件、合同和正式交付文件。由法律工作总控强制路由调用;业务 Skill 负责正文和法律判断,本 Skill 负责选择格式 profile、接收语义 HTML 或要素式填充数据、导出 DOCX、结构体检和兜底模板。

How to use this skill

Skill file

法律文书模板与导出

本 Skill 只处理最终 Word 的格式与导出,不替代业务 Skill 的事实梳理、法律分析、文书正文生成、材料读取复查、法规核验和出稿前审查。

法律工作总控规则(强制)

执行本 Skill 前,必须先遵循:

本 Skill 继承 practice-profile.md 的子 Skill 执行质量门;审查报告、来源边界或验证结果缺失时,不得标记为正式交付。

强制路由

输入约定

普通线性文书:业务 Skill 应先生成语义 HTML,并经 法律文书出稿前审查 生成 draft_checked.html。使用 XHTML 兼容写法:

要素式表单文书:业务 Skill 应生成结构化字段和填充计划:

Profile

内置 profile 位于 assets/profiles/:

模板匹配与版本门禁

全局模板登记表位于 assets/legal-template-registry.json,只做索引和门禁,不迁移各业务 Skill 的正文模板或外部模板文件。正式合同类 Word 如存在内容模板来源,应先生成 template-selection.json:

python scripts/select_legal_template.py \
  --source-skill 合同起草 \
  --doc-type 解除委托协议 \
  --business-scene 撤诉解除委托 \
  --user-request "客户撤诉,费用不退,留存抵扣后续法律服务" \
  --source-template-path "模板源文件.docx" \
  --output template-selection.json

选择结果必须写入 preflight-meta.json,至少包括 template_selection_path、content_template_id、content_template_version、content_template_sha256、profile_id、profile_version 和 format_standard。未命中登记表、模板 sha256 不一致、多候选冲突或 profile 不兼容时,不得进入正式导出。

导出命令

python scripts/html_to_docx.py \
  --input draft_checked.html \
  --output output.docx \
  --profile litigation_standard \
  --preflight-report 出稿前审查报告.md

如未指定或未找到 profile,脚本使用 fallback_desktop_word。

要素式表单文书导出:

python scripts/fill_docx_template.py \
  --template 母版.docx \
  --plan fill-plan.json \
  --output output.docx \
  --log fill-execution-log.json

一键质控验证:

python scripts/run_template_clone_qc.py \
  --template-id civil_complaint_private_lending_v1 \
  --fixture private_lending_basic \
  --out /tmp/legal_template_clone_qc

全部登记起诉状母版结构/渲染回归:

python scripts/run_template_clone_qc.py \
  --all \
  --fixture structure_only \
  --out /tmp/legal_template_clone_all_qc

双通道回归验证(同时验证旧 HTML 链路和新模板克隆链路):

python scripts/run_dual_docx_qc.py --out /tmp/legal_dual_docx_qc

失败与兜底

验证命令

python scripts/health_check.py
python scripts/health_check.py --docx output.docx --expect-title "文书标题"
python scripts/health_check.py --docx output.docx --expect-title "解除委托协议" --format-standard contract_standard
python scripts/health_check.py --docx output.docx --expect-clean-clone --template-clone-report qc-report.json

验证至少检查:

正式交付包审计:

python scripts/audit_formal_delivery.py \
  --bundle-dir 正式交付目录 \
  --docx 正式交付文件.docx

正式 .docx 不得仅凭“文件已生成”标记完成。普通 HTML 交付包必须具备 draft.html、preflight-meta.json、draft_checked.html、出稿前审查报告.md、最终 .docx 和 health-check-report.txt;要素式模板克隆交付包必须具备 complaint-data.json、fill-plan.json、qc-meta.json、要素式出稿前审查报告.md 或 出稿前审查报告.md、qc-report.json、最终 .docx 和 health-check-report.txt。审查报告状态必须为 PASS 或 FIXED_PASS,健康检查记录必须包含 health_check_ok: True 并指向最终 .docx;要素式模板克隆包还必须指向 qc-report.json 且该报告状态为 PASS。

迁移边界

禁止事项

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.