redline-generator
Skill1 starsChanged 7 months agoApache-2.0View on GitHub
Apply margin comments and tracked changes to DOCX for review output generation using scripts/add-docx-comments.py. Reference patterns from contract-review-agent/.claude/skills/docx-redliner/scripts/:
In this repository15 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- citation-auditorSkill
- citation-checkerSkill
- cover-memo-writerSkill
- cross-document-checkerSkill
- document-parserSkill
- formatting-reviewerSkill
- ingestSkill
- known-issues-managerSkill
- library-managerSkill
- quality-gateSkill
- scoring-engineSkill
- structure-checkerSkill
- substance-reviewerSkill
- writing-quality-reviewerSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
Start from a copy of the original DOCX
- Very specific: line 26
All comments follow the format guide in references/comment-format-guide.md
- Distinctive: line 103
If DOCX XML manipulation fails → attempt XML sanitization + retry
- Distinctive: line 104
If repair fails → produce Markdown fallback + error report
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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
redline-generator Skill
Apply margin comments and tracked changes to DOCX for review output generation using scripts/add-docx-comments.py.
Capabilities
- Redline DOCX Generation (
scripts/add-docx-comments.py)- Copy original DOCX (never modify the original)
- Insert margin comments for ALL findings from
issue-registry.json - Insert tracked changes (
<w:del>+<w:ins>) for Critical/Major findings when the recommendation exposes an explicit textual correction (arrow replacement or typo list) - Comment prefixes are citation-aware when
verification-audit.jsonis provided - Paragraph mapping: paragraph_index → regex parse → keyword search → correction-text search → unmapped collection
- Usage:
python3 add-docx-comments.py <input_docx> <issue_registry_json> <output_redline_docx> [--clean-output <output_clean_docx>] [--verification-audit <verification_audit_json>] [--fallback-markdown <fallback_md_path>] [--mapping-report <redline_mapping_report_json>] - Output: annotated DOCX with comments attached to relevant paragraphs
- Unmapped issues collected in a final comment at document end
- Writes
redline-mapping-report.jsonnext toissue-registry.jsonby default, unless--mapping-reportis provided - Stdlib only (zipfile + xml.etree.ElementTree) — no python-docx dependency
- Clean DOCX Generation
- Start from a copy of the original DOCX
- Accept only Critical/Major textual corrections (Suggestions remain comment-only)
- Apply textual replacements directly so the clean version contains no tracked change or comment markup
- Result: clean document with only substantive fixes applied
- Comment Formatting
- All comments follow the format guide in
references/comment-format-guide.md - Severity prefix:
[CRITICAL],[MAJOR],[MINOR],[SUGGESTION] - Citation comments: use Verification Status prefix (e.g.,
[CRITICAL — NONEXISTENT]) - Author: "시니어 리뷰 스페셜리스트" (Korean docs) / "Senior Review Specialist" (English docs)
- All comments follow the format guide in
DOCX Processing Workflow
Original DOCX (in `$SECOND_REVIEW_PRIVATE_DIR/input/`)
│
├── Copy to working/ (PRESERVE ORIGINAL)
│
├── Redline Generation (CURRENT)
│ ├── Run add-docx-comments.py <input> <issue-registry> <redline> --clean-output <clean> --mapping-report <report>
│ ├── Maps issues to paragraphs (index → regex → keyword search)
│ ├── Inserts <w:comment> + range markers for each issue
│ ├── Inserts tracked changes for explicit textual corrections
│ ├── Creates/updates comments.xml, rels, content types
│ ├── Writes working/redline-mapping-report.json
│ └── Output: {doc}_redline_v{N}.docx (with margin comments)
│
└── Clean DOCX: accept Critical/Major corrections → {doc}_clean_v{N}.docxOOXML Tracked Changes Format
Reference patterns from contract-review-agent/.claude/skills/docx-redliner/scripts/:
Deletion (<w:del>)
<w:del w:id="1" w:author="시니어 리뷰 스페셜리스트" w:date="2026-03-13T00:00:00Z">
<w:r w:rsidDel="00000001">
<w:rPr><!-- preserve original formatting --></w:rPr>
<w:delText>deleted text</w:delText>
</w:r>
</w:del>Insertion (<w:ins>)
<w:ins w:id="2" w:author="시니어 리뷰 스페셜리스트" w:date="2026-03-13T00:00:00Z">
<w:r>
<w:rPr><!-- match surrounding formatting --></w:rPr>
<w:t>inserted text</w:t>
</w:r>
</w:ins>Comment
<!-- In document.xml: -->
<w:commentRangeStart w:id="3"/>
<w:r><w:t>commented text</w:t></w:r>
<w:commentRangeEnd w:id="3"/>
<w:r>
<w:rPr><w:rStyle w:val="CommentReference"/></w:rPr>
<w:commentReference w:id="3"/>
</w:r>
<!-- In comments.xml: -->
<w:comment w:id="3" w:author="시니어 리뷰 스페셜리스트" w:date="2026-03-13T00:00:00Z">
<w:p>
<w:r><w:t>[CRITICAL] Description. Recommendation.</w:t></w:r>
</w:p>
</w:comment>When to Use
- WF1 Step 7: Redline & Output Generation
- Input: issue-registry.json, original DOCX, verification-audit.json
- Output: redline DOCX, clean DOCX (saved to
$SECOND_REVIEW_PRIVATE_DIR/output/{matter_id}/round_{N}/deliverables/)
Safety Rules
- NEVER modify the original DOCX — always work on a copy
- Preserve original formatting — copy
<w:rPr>from existing runs - If DOCX XML manipulation fails → attempt XML sanitization + retry
- If repair fails → produce Markdown fallback + error report
- Clean DOCX must have no remaining tracked changes or comments
Paragraph Mapping Strategy
For each issue in issue-registry.json, apply these strategies in order:
- Primary:
location.paragraph_indexas integer → count<w:p>elements in<w:body> - Fallback 1: Parse paragraph number from location string fields (regex:
para(?:graph)?\s*(\d+)) - Fallback 2: Keyword search — extract keywords from issue description, find paragraph with highest keyword overlap in
<w:t>text content - Fallback 3: Unmapped — collect all unmapped issues in a single comment attached to the last paragraph
The script writes redline-mapping-report.json with per-issue mapping status:
exact: paragraph plus character span, anchor text, or text correction matchparagraph: paragraph index/reference match, but no exact anchor textfallback: keyword search matchunmapped: no usable location found
Target: ≥90% Critical/Major exact mapping rate for Deep Review. Any unmapped Critical/Major issue should fail the Step 8 quality gate unless the user explicitly approves degraded delivery.
Checkpoint
This skill runs as part of Step 7 alongside cover-memo-writer. The main agent updates checkpoint.json after ALL Step 7 outputs are generated:
step_7.status→"completed"step_7.output→ comma-separated paths of redline DOCX, clean DOCX, cover memo, andworking/redline-mapping-report.jsonlast_completed_step→7
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.

