CSlawyer1985/legal-skillhub / skills/appeal-docs-generator
appeal-docs-generator
Verified民事二审上诉文本成套生成技能。上传一审判决书后,以民诉法为尺子逐条审查原审判决是否错误(期限/主体程序/诉请判项比对/三段论/说理/新要素六诊),结合元典连接器检索现行有效法条与类案,并做一次「当事人是否已逐条确认事实认定错误、有无新证据」的事实核对互动,最终一次生成民事上诉状、二审证据清单、支持上诉请求的法条与类案检索报告、二审授权委托书、所函、二审接待笔录、待确认事实清单等全套文本。上诉状严格套用德恒格式母版(黑体18pt居中标题/仿宋14pt正文/1.5倍行距),格式100%保留。另提供 scan 轻出口,只做上诉可行性评估与上诉费测算,不出全套文书。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 25.4 KB |
| _meta.json | config | 114 B |
| references/templates-b64.json | config | 148.9 KB |
| references/yuandian_tools_guide.md | markdown | 2.2 KB |
| references/上诉状填充字段表.md | markdown | 4.6 KB |
| references/二审风险告知要点.md | markdown | 2.2 KB |
| references/元典检索姿势.md | markdown | 4.1 KB |
| references/判决书解剖清单.md | markdown | 8.4 KB |
| references/当事人事实核对清单.md | markdown | 4.0 KB |
| references/所函模板.md | markdown | 1.2 KB |
| references/授权委托书模板.md | markdown | 1.7 KB |
| references/接待笔录模板.md | markdown | 4.1 KB |
| references/文件清单及盖章指引模板.md | markdown | 3.3 KB |
| references/检索报告模板.md | markdown | 3.1 KB |
| references/模板与排版规范.md | markdown | 5.5 KB |
| references/民诉法审查尺子表.md | markdown | 9.1 KB |
| scripts/appeal_fee_calc.py | script | 6.3 KB |
| scripts/build_pending_facts_docx.py | script | 6.9 KB |
| scripts/deadline_check.py | script | 5.0 KB |
| scripts/fill_appeal_docx.py | script | 9.8 KB |
| scripts/generate_file_list.py | script | 7.8 KB |
| scripts/render_docx.py | script | 8.6 KB |
| scripts/restore_templates.py | script | 5.7 KB |
scripts/fill_appeal_docx.py
View on GitHub#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Maintained by Lu Lingyan, Deheng (Wuxi) Law Firm.
"""上诉状填充器 —— 以《民事上诉状-脱敏模板.docx》为格式母版,原位填充,格式 100% 保留。
为什么不用通用渲染引擎
----------------------
`render_docx.py` 是从零 `Document()` 建文档再套样式,无法复刻母版中的细节(黑体 18pt
居中标题、仿宋 14pt 正文与加粗规则、"此致"缩进、落款居中、日期右对齐、页脚 PAGE/NUMPAGES
域名)。上诉状必须与母版逐项一致,因此这里采用**克隆母版段落为格式供体**的做法:
- 当事人栏 → 克隆母版"上诉人"段(仿宋 14pt 加粗)
- 上诉请求项 → 克隆母版"1、……"段(仿宋 14pt 不加粗)
- 事实与理由小节标题 → 克隆母版"一、……"段(仿宋 14pt 加粗)
- 事实与理由正文 → 克隆母版"错误之一:……"段(仿宋 14pt 不加粗)
段落数量按实际内容增减,母版中多余的示例段落会被删除。
输入
----
python3 fill_appeal_docx.py <母版.docx> <输出.docx> <payload.json>
payload.json 结构见 references/上诉状填充字段表.md,示例:
{
"上诉人": {"原审地位": "被告", "姓名": "张三", "身份": "张三,男,1980年1月1日出生,汉族,住××市××区××路1号。"},
"被上诉人": [{"原审地位": "原告", "身份": "李四,男,……。"}],
"第三人": [{"身份": "王五,男,……。"}],
"一审法院": "××市××区人民法院",
"一审案号": "(2024)苏××××民初1234号",
"二审法院": "××市中级人民法院",
"上诉请求": ["1、撤销……;或撤销原判决,发回重审;", "2、本案一审、二审诉讼费用均由被上诉人承担。"],
"事实与理由": [
{"kind": "lead", "text": "开篇结论段……"},
{"kind": "head", "text": "一、一审未查明案件基本事实,且事实认定错误。"},
{"kind": "body", "text": "错误之一:……"},
{"kind": "body", "text": "……"}
],
"落款签名": "张三",
"落款日期": "2026年9月16日"
}
说明
----
- `原审地位` 只填「原告/被告/第三人」,输出为「上诉人(一审被告):……」,**不要**自带"一审"二字。
- `一审案号` 自带全角括号时不会被重复加括号。
- `kind` 三选一:`lead`(开篇结论段)/`head`("一、二、"小结标题,加粗)/`body`(正文,不加粗)。
自检
----
落盘前检查:① 正文不得残留 `〔` 占位符;② 上诉请求、事实与理由非空;
③ 当事人栏必备字段齐全。任一不过 → 报错并不落盘。
"""
import copy
import json
import sys
from docx import Document
from docx.oxml.ns import qn
from docx.text.paragraph import Paragraph
# 母版段落索引(0 基)—— 对应《民事上诉状-脱敏模板.docx》34 段的骨架
IDX = {
"title": 0, # 民事上诉状
"appellant": 2, # 上诉人(一审……) ← 当事人栏格式供体
"appellee": 3, # 被上诉人
"third_party_first": 4,
"third_party_last": 7,
"preamble": 9, # 〔上诉人〕因不服……提起上诉。
"req_head": 10, # 上诉请求:
"req_first": 11, # 1、……
"req_second": 12, # 2、……
"claim_head": 14, # 事实和理由:
"lead": 15, # 开篇结论段
"head": 16, # 一、…… ← 小结标题格式供体(加粗)
"body_first": 17, # 错误之一:…… ← 正文格式供体(不加粗)
"body_last": 28, # 综上,……(事实与理由区段末尾)
"court": 30, # 〔二审法院全称〕
"sign": 32, # 上诉人:〔……〕
"date": 33, # 〔 〕年〔 〕月〔 〕日
}
def _strip_runs(par):
"""删除段落内所有 run,保留段落属性(pPr)与书签等非 run 元素。"""
for r in list(par.runs):
r._element.getparent().remove(r._element)
def set_text(par, text, fmt_from=None):
"""写入文本,保留段落属性(pPr)。
格式来源优先级:显式传入的 fmt_from(母版供体段落)> 该段落自身原有的首个 run。
**必须在删除 run 之前先把 rPr 抓下来**,否则新建的 run 会退回 Normal 样式,
造成字体、字号、加粗全部丢失。
"""
src = fmt_from if fmt_from is not None else par._element
rpr = None
src_runs = src.findall(qn("w:r"))
if src_runs:
rpr = src_runs[0].find(qn("w:rPr"))
_strip_runs(par)
run = par.add_run(text)
if rpr is not None:
run._element.insert(0, copy.deepcopy(rpr))
return par
def _case_no(no):
"""案号自带全角/半角括号时不再另加括号,避免出现((2024)……)双括号。"""
no = (no or "").strip()
if not no:
return ""
return no if no[0] in "((" else f"({no})"
def clone_after(anchor_el, donor_el, text, parent):
"""在 anchor_el 之后插入一个 donor_el 的副本并写入 text,返回新段落元素与 Paragraph 对象。"""
new_el = copy.deepcopy(donor_el)
# 去掉副本里原有的 run,仅保留段落属性作为格式骨架
for r in new_el.findall(qn("w:r")):
new_el.remove(r)
anchor_el.addnext(new_el)
par = Paragraph(new_el, parent)
set_text(par, text, fmt_from=donor_el)
return new_el, par
def remove_els(els):
for el in els:
parent = el.getparent()
if parent is not None:
parent.remove(el)
def fill(template_path, output_path, payload):
doc = Document(template_path)
parent = doc.paragraphs[0]._parent
paras = doc.paragraphs
# ---- 先固化格式供体(母版段落元素,必须在删除之前深拷贝)----
d_party = copy.deepcopy(paras[IDX["appellant"]]._element) # 当事人栏:仿宋 14pt 加粗
d_req = copy.deepcopy(paras[IDX["req_first"]]._element) # 请求项:仿宋 14pt 不加粗
d_head = copy.deepcopy(paras[IDX["head"]]._element) # 小结标题:加粗
d_body = copy.deepcopy(paras[IDX["body_first"]]._element) # 正文:不加粗
missing = [k for k in ("上诉人", "被上诉人", "一审法院", "一审案号", "二审法院",
"上诉请求", "事实与理由") if not payload.get(k)]
if missing:
raise SystemExit(f"❌ payload 缺字段:{', '.join(missing)}")
# ---- 一、当事人栏 ----
a = payload["上诉人"]
set_text(paras[IDX["appellant"]],
f"上诉人(一审{a.get('原审地位', '')}):{a['身份']}",
fmt_from=d_party)
# 母版中"被上诉人 + 第三人×2 + 两行提示"整段删掉,再按实际人数重建
remove_els([paras[i]._element
for i in range(IDX["appellee"], IDX["third_party_last"] + 1)])
anchor = paras[IDX["appellant"]]._element
for ap in payload["被上诉人"]:
anchor, _ = clone_after(anchor, d_party,
f"被上诉人(一审{ap.get('原审地位', '')}):{ap['身份']}", parent)
for tp in payload.get("第三人", []):
anchor, _ = clone_after(anchor, d_party, f"第三人:{tp['身份']}", parent)
# ---- 二、不服前提句 ----
who = payload.get("上诉人简称") or a.get("姓名") or "上诉人"
set_text(paras[IDX["preamble"]],
f"{who}因不服{payload['一审法院']}{_case_no(payload['一审案号'])}民事判决,提起上诉。",
fmt_from=d_party)
# ---- 三、上诉请求 ----
remove_els([paras[IDX["req_first"]]._element, paras[IDX["req_second"]]._element])
anchor = paras[IDX["req_head"]]._element
for item in payload["上诉请求"]:
anchor, _ = clone_after(anchor, d_req, item, parent)
# ---- 四、事实与理由(整段重建)----
region = [p._element for p in paras[IDX["lead"]:IDX["body_last"] + 1]]
remove_els(region)
anchor = paras[IDX["claim_head"]]._element
donor_map = {"lead": d_body, "head": d_head, "body": d_body}
for item in payload["事实与理由"]:
kind = item.get("kind", "body")
if kind not in donor_map:
raise SystemExit(f"❌ 事实与理由的 kind 只能是 lead/head/body,收到:{kind}")
anchor, _ = clone_after(anchor, donor_map[kind], item["text"], parent)
# ---- 五、此致 / 落款 ----
set_text(paras[IDX["court"]], payload["二审法院"])
sign = payload.get("落款签名")
set_text(paras[IDX["sign"]], f"上诉人:{sign}" if sign else "上诉人: (签名/盖章)")
set_text(paras[IDX["date"]], payload.get("落款日期") or " 年 月 日")
# ---- 自检 ----
full = "\n".join(p.text for p in doc.paragraphs)
errs = []
if "〔" in full or "〕" in full:
left = [l for l in full.splitlines() if "〔" in l]
errs.append("残留占位符:" + " | ".join(left[:3]))
if not payload["上诉请求"]:
errs.append("上诉请求为空")
if not payload["事实与理由"]:
errs.append("事实与理由为空")
for key in ("一审法院", "一审案号", "二审法院"):
if payload[key] not in full:
errs.append(f"{key} 未写入正文({payload[key]})")
if errs:
raise SystemExit("❌ 自检未通过,未落盘:\n - " + "\n - ".join(errs))
doc.save(output_path)
return output_path
def Paras(el, parent):
return Paragraph(el, parent)
if __name__ == "__main__":
if len(sys.argv) != 4:
raise SystemExit(__doc__)
with open(sys.argv[3], encoding="utf-8") as fh:
data = json.load(fh)
out = fill(sys.argv[1], sys.argv[2], data)
print(f"✅ {out}(自检通过)")
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 198k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |