legal-document

Generate Chinese legal documents from Word templates with placeholder filling and compliance checks.

1|Updated Mar 25, 2026
One-click install
npx skills add https://github.com/qfwc258/trae-skills --skill legal-document-qfwc258
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: legal-document
Source: https://github.com/qfwc258/trae-skills/tree/main/legal-document
Command: npx skills add https://github.com/qfwc258/trae-skills --skill legal-document-qfwc258

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires python-docx, reportlab, jieba, fuzzywuzzy, python-Levenshtein, openpyxl, and includes scripts (resource) and references (resource) components.

What problem does it solve? Drafting legally compliant Chinese documents such as civil complaints, contracts, and legal aid forms requires precise formatting and correct legal terminology, which is slow and error-prone when done manually. ## Core Features & Use Cases - Dual-Driven Template Matching: Locate templates via keyword matching or AI case analysis, searching a user template folder first and a built-in library of 200+ official templates second. - Word Template Processing: Parse .docx templates, extract {{placeholder}} fields, fill them with case data, and export Word or PDF output via python-docx and reportlab. - Compliance & Statute Linking: Validate documents against compliance checklists and retrieve relevant legal articles from a local law database. - Use Case: A legal aid worker needs 10 criminal case meeting forms; they run the batch generator with a JSON data file to produce all filled .docx documents at once. ## Quick Start Ask the assistant to generate a civil complaint for a loan dispute using the legal document templates, providing the plaintiff, defendant, and claim details.

Frequently Asked Questions about legal-document

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate a Chinese legal document from a Word template?

Place your .docx template with {{placeholder}} markers in the legal_templates folder, build the index with template_finder.py, then fill it using word_template_processor.py with a JSON data object. The script outputs a completed Word document.

How to batch generate legal documents from JSON or Excel data?

Use batch_generator.py with a template key and a JSON or Excel data file containing one record per document. It iterates over the records, fills the template placeholders for each, and writes one .docx per record to the output directory.

Can I export generated legal documents to PDF?

Yes, doc_generator.py supports PDF output through the reportlab library. It attempts to register a Chinese font from common system paths; if none is found, Chinese characters may not render correctly in the PDF.

What happens if my Word template has no placeholders?

The template_analyzer.py script analyzes the template's structure, formatting, and language style, producing a report. The AI then uses that analysis to draft a new document following the same format while you supply the content.

Why does template matching fail to find my uploaded template?

Matching relies on keywords and file naming conventions, and the user template folder must be indexed first with template_finder.py --action index. Rebuild the index after adding templates and use descriptive filenames like 民事起诉状-借款纠纷.docx.