legal-citation-automator
Skill65 starsChanged 4 months agoMITView on GitHub
法学脚注 DOCX 执行器。用于把已经由 legal-citation-comprehensive 诊断、补全或确认过的法学引注插入 Word 文档,并进行 Word/WPS 脚注结构兼容性检查。适用于自动添加脚注、批量脚注修复、DOCX footnotes.xml 处理、脚注编号检查、脚注引用标记插入。不要把它当作引注规则大脑;复杂引注规则必须先交给 legal-citation-comprehensive。
In this repository28 other files it gives its agents.
- case-retrieval-display-tableSkill
- docx-cnSkill
- docx-editingSkill
- docx-toolkitSkill
- evidence-catalog-generatorSkill
- legal-citation-comprehensiveSkill
- legal-fact-checkerSkill
- legal-homework-formatterSkill
- legal-toa-formatterSkill
- pkulaw-legal-searchSkill
- pkulaw-mcp-batch-contract-screeningSkill
- pkulaw-mcp-case-memoSkill
- pkulaw-mcp-case-numberSkill
- pkulaw-mcp-case-retrievalSkill
- pkulaw-mcp-citation-validatorSkill
- pkulaw-mcp-contract-review-liteSkill
- pkulaw-mcp-doc-linkSkill
- pkulaw-mcp-fatiao-preciseSkill
- pkulaw-mcp-governance-research-memoSkill
- pkulaw-mcp-grounded-answerSkill
- pkulaw-mcp-installerSkill
- pkulaw-mcp-labor-employment-answerSkill
- pkulaw-mcp-law-recognitionSkill
- pkulaw-mcp-law-retrievalSkill
- pkulaw-mcp-legal-researchSkill
- pkulaw-mcp-opinion-citation-checkSkill
- pkulaw-mcp-regulatory-reply-checkSkill
- pkulaw-mcp-semantic-nlsqlSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 7 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Do not invent citation content here.
- Distinctive: line 20
Search the full handbook index for non-trivial or unusual sources.
- Very specific: line 25
If multiple sources support the same anchor, combine them into one footnote_text separated by semicolons.
- Distinctive: line 26
If source facts are missing, stop and return a report instead of editing the DOCX.
- Very specific: line 29
every w:footnoteReference has a matching w:footnote.
- Distinctive: line 59
Do not modify the DOCX when:
- Distinctive: line 69
Instead, produce a citation repair report using the comprehensive skill output.
- Very specific: line 83
Never create a body footnoteReference without a matching footnote definition.
- Distinctive: line 84
Never add footnote definitions without confirming the body reference was actually inserted.
- Distinctive: line 85
If multiple anchors match, pause and ask for clarification.
- Very specific: line 87
Do not emit adjacent footnote references after the same punctuation.
- Very specific: line 92
Use legal-citation-comprehensive as the authoritative source for:
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Legal Citation Automator
Role
This skill is the DOCX execution layer. It inserts or repairs footnotes only after citation text has been diagnosed and approved by legal-citation-comprehensive.
Do not invent citation content here. Do not rely on this skill to decide legal citation format. Use the comprehensive skill first for source type, missing elements, and final footnote wording.
Weak-agent guardrail: if any required fact is uncertain, stop. Output a repair checklist. Do not edit the DOCX just because the user asked for automation.
Safe Workflow
- Run
legal-citation-comprehensive.- Diagnose each messy footnote or citation candidate.
- Search the full handbook index for non-trivial or unusual sources.
- Produce either final citation text or a
[待补]checklist.
- Prepare a citation insertion plan.
- Each item must include the exact body text anchor or paragraph/run location.
- Each item must include final footnote text.
- If multiple sources support the same anchor, combine them into one
footnote_textseparated by semicolons. Do not create two insertion items for the same sentence-final anchor. - If source facts are missing, stop and return a report instead of editing the DOCX.
- Insert footnotes using OOXML, preserving the existing document structure.
- Verify:
- every
w:footnoteReferencehas a matchingw:footnote; - separator IDs remain
-1and0; - generated replacement notes may start at
4+as a conservative repair convention; - footnote text style matches the target document/template;
- DOCX zip, content types, and relationships are valid.
- every
Input Contract
The safe input to an insertion script is a JSON array:
[
{
"anchor_text": "依《民法典》第153条第1款",
"placement": "after_anchor",
"footnote_text": "《中华人民共和国民法典》第153条:“……”",
"source_status": "verified"
}
]Required fields:
anchor_text: exact text in the body, or an equivalent precise location object.placement:after_anchor,after_sentence, or a precise custom instruction.footnote_text: final text fromlegal-citation-comprehensive.source_status: must beverified; ifneeds_user_input, do not edit.
When to Refuse Editing
Do not modify the DOCX when:
- the footnote text contains
[待补: ...]; - the comprehensive skill has not supplied handbook rule numbers;
- the citation source has not been verified;
- the anchor appears multiple times and the user has not clarified which instance;
- two or more insertion items target the same anchor/placement and would create adjacent footnote references; merge them first unless the body text has distinct citation anchors;
- the source is a PDF/book/article but required bibliographic facts are absent;
- the requested citation format conflicts with the handbook and no user override is explicit.
Instead, produce a citation repair report using the comprehensive skill output.
Scripts
scripts/diagnose_with_comprehensive.py: wrapper that calls the comprehensive skill diagnostic script when available.scripts/add_footnotes.py: legacy OOXML insertion utility. Use only after reviewing its target-location behavior for the current task.scripts/docx_compat_check.py: final DOCX compatibility gate.scripts/fix_footnote_conflict.py: repair mismatched or unsafe footnote IDs.scripts/identify_citations.py: first-pass candidate detector; always review candidates manually.
Important DOCX Rules
- The clean template pattern is separator footnotes
-1and0; a regular note ID1is valid. - Starting generated replacement notes at
4+is a conservative repair convention, not a universal rule. - Never create a body
footnoteReferencewithout a matchingfootnotedefinition. - Never add footnote definitions without confirming the body reference was actually inserted.
- If multiple anchors match, pause and ask for clarification.
- Strip leading/trailing whitespace from every
footnote_textbefore writing it tofootnotes.xml. Keep at most the normal single delimiter space after the footnote number; do not let the citation text itself start with a blank. - Do not emit adjacent footnote references after the same punctuation. If a sentence needs two supporting sources, put them in the same footnote separated by
;. - For Civil Law homework, combine with
legal-homework-formatterso footnote style remains 小五、左对齐、单倍行距、段前后 0、首行不缩进.
Relationship to Comprehensive Skill
Use legal-citation-comprehensive as the authoritative source for:
- source classification;
- missing element diagnosis;
- full handbook rule lookup;
- standard footnote wording;
- direct/indirect quotation analysis;
- repeat citation forms.
This skill is successful only when the final DOCX structure is valid and the citation content has already been validated.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

