Legal Work Master Control Rules (Mandatory)
Before executing this Skill, you must first follow:
- skills/legal/法律工作总控/references/practice-profile.md
- skills/legal/法律工作总控/references/matter-workspace-protocol.md
- skills/legal/法律工作总控/references/document-reading-protocol.md
- skills/legal/法律工作总控/references/source-boundary-protocol.md
- skills/legal/法律工作总控/references/ocr-correction-protocol.md
- skills/legal/法律工作总控/references/pkulaw-mcp-legal-verification-protocol.md
This Skill only handles tasks within this specialty; case isolation, source disclosure, material gaps, statute/Wiki verification, OCR correction, and reading review are executed according to the master control rules.
Repeal of Old Rules (Mandatory)
- Client directories, stage directories, old-style ledger writes, and old local reading protocols hard-coded directly in old texts are not to be used as execution rules.
- Matter paths, current matters, system records, business file areas, and review ledgers are uniformly based on the Legal Work Master Control
matter-workspace-protocol.md. - Do not silently write to the review ledger; when an update is truly needed, first confirm that it belongs to a review ledger update and explain it to the user.
Law To Markdown
Processing Rules
- Input is
.txt: directly save as.md。 - Input is
.pdf/.docx:- First check whether
mineru-ocrskill。 - is installed. Not installed: prompt to install
mineru-ocrfirst, installation address:https://github.com/cat-xierluo/legal-skills/tree/main/skills/mineru-ocr - Installed: prioritize calling
mineru-ocrfor processing. - Call failed: first prompt to check
mineru-ocrconfiguration/Token. - Only when the user explicitly agrees, use the local fallback (
python-docx/pdfplumber)。
- First check whether
- After the first stage is completed, by default execute the second stage format adjustment (format only, do not change the original text characters):
- The large model calling this skill first determines "legal/non-legal" and passes the result to the script.
- If the caller does not pass a result, the script uses hard rules for automatic recognition (
--law-decision auto)。 - Law name
# - Part/Sub-part
## - Chapter
### - Section
#### - Article
#####(only "Article X" is a heading;第X条【条标】a whole line as a heading is not split) - Paragraph/Item/Sub-item have no headings
- Items and sub-items are line-broken by marker
- Clean up excess spaces: remove trailing spaces, remove leading ASCII spaces, remove full-width indentation at the start of body lines, normalize spaces after headings
- If recognized as clearly non-legal text (such as GB/standard-type documents), the second stage explicitly refuses:
Stage2: rejected (non-law-document)。 - If the second stage does not recognize legal structure or the fidelity check fails, automatically no-op, without changing the text.
- By default execute the third stage check (two sub-stages, hard threshold):
- Stage3-A: verify
stage2relative tostage1textual content accuracy (the character stream must be identical after removing heading symbols and whitespace) - Stage3-B: verify structural effect (structural hierarchy, article heading rules, non-legal strategy, space conventions, item/sub-item line breaks)
- Any failure triggers an automatic retry, up to 2 times; if it still fails, it exits with an error by default
- Stage3-A: verify
Stage 2 recognition parameters
--law-decision law: The caller has determined it is legal text, so optimize directly according to the legal structure.--law-decision non-law: The caller has determined it is non-legal text, so Stage 2 rejects it directly.--law-decision auto: The default mode when no determination is passed, using hardcoded rules in the script.
Stage 3 parameters
--skip-stage3-check: Skip the Stage 3 check (not skipped by default).--stage3-max-retries: Number of automatic retries after failure, default2。--stage3-strict/--no-stage3-strict:- Default strict mode (exit with an error on failure)
- Non-strict mode only outputs a report and does not block the process
--artifact-level minimal|standard|debug:minimal(default): Delivery-oriented, minimal outputstandard: Keep process files (stage1/stage2/stage3-check) for troubleshootingdebug: Keep all process artifacts (including debug information)
Output rules
- By default, output to the
markdown/subdirectory in the same directory as the input file, and create a separate directory based on the input file name:markdown/<文件名>/
- Default (
--artifact-level minimal) output:<原文件名>+审核报告.md(detailed process and conclusion)<原文件名>+最终成果.md(generated only for legal text that passes review)
- Non-legal documents (such as GB/standards):
- The conclusion is "reject processing"
- Only output
<原文件名>+审核报告.md - Do not output
<原文件名>+最终成果.md
- When review fails, process files are automatically retained for troubleshooting:
<文件名>.stage1.md<文件名>.stage2.md<文件名>.stage3-check.md
- If more artifacts are needed, you can switch:
--artifact-level standard: Keepstage1/stage2/stage3-check--artifact-level debug: Keep all debug artifacts
- You can specify via command parameters
--outor--out-dir。
Common commands
python3 law-to-markdown/scripts/law_to_markdown.py "input.txt"
python3 law-to-markdown/scripts/law_to_markdown.py "input.docx"
python3 law-to-markdown/scripts/law_to_markdown.py "input.pdf"
When the user explicitly agrees to fallback:
python3 law-to-markdown/scripts/law_to_markdown.py "input.docx" --allow-fallback
python3 law-to-markdown/scripts/law_to_markdown.py "input.pdf" --allow-fallback
License
SPDX-License-Identifier: Apache-2.0
Copyright (c) 2026 JiCheng
Licensed under the Apache License 2.0; the original license text is in the repository root directory LICENSE。