Loading...
Loading...
Legal document drafting -- contracts, memos, briefs, complaints, demand letters, opinions, discovery, settlements, ToS, privacy policies. Full pipeline: document structure, per-section writing, Bluebook citation, case law lookup (CourtListener API), regulation lookup (eCFR API), DOCX output, and TDD-style verification (defined terms, cross-references, placeholders, boilerplate, citation format). Triggers on: 'draft a contract', 'write a legal memo', 'create an NDA', 'write a brief', 'legal document about', 'draft a complaint', 'terms of service', 'privacy policy', 'demand letter', 'settlement agreement', 'legal opinion', 'discovery requests', any request to produce a legal or law-related document.
npx skill4agent add kortix-ai/kortix-registry legal-writerglob("**/KORTIX-legal-writer/")| Resource | Path | Purpose |
|---|---|---|
| Verifier | | TDD verification suite (10 checks) |
| Case law API | | CourtListener search/lookup for case citations |
| Regulation API | | eCFR + Federal Register lookup for statutes/regs |
| Bluebook ref | | Bluebook citation format quick reference |
| Doc type ref | | Section templates for every document type |
1. WRITE section content
2. GENERATE: build/update the DOCX via the docx skill
3. VERIFY: python3 verify-legal.py legal/{slug}/
4. If FAIL → FIX → go to 2
5. If PASS → move to next sectionPhase 1: SCAFFOLD → Create project, metadata.json, empty DOCX with structure
Verify: document exists and has correct sections ✓
Phase 2: RESEARCH → Case law, statutes, regulations (if litigation/regulatory doc)
Verify: citations are formatted correctly ✓
Phase 3: WRITE → Per-section drafting in logical order
Verify: verify-legal.py after EACH section ✓
Phase 4: POLISH → Self-reflection pass, strict verification, final DOCX
Verify: verify-legal.py --strict with zero warnings ✓legal/{document-slug}/
├── metadata.json # Document type, parties, jurisdiction, etc.
├── document.docx # The main document (generated via docx)
├── research/ # Case law, statutes, notes (optional)
│ ├── cases.json # CourtListener search results
│ ├── regulations.json # eCFR lookup results
│ └── notes.md # Research notes
└── versions/ # Prior versions (optional){
"type": "contract",
"title": "Services Agreement",
"jurisdiction": "State of Delaware",
"governing_law": "Delaware",
"date": "2025-01-15",
"parties": [
{"name": "Acme Corporation", "short_name": "Company", "role": "client"},
{"name": "Jane Smith Consulting LLC", "short_name": "Contractor", "role": "contractor"}
],
"word_limit": null,
"page_limit": null
}word_limitpage_limitreferences/document-types.md| Type | Key | Use Case |
|---|---|---|
| Legal memorandum | | Internal analysis, predictive |
| Motion brief | | Persuasive, court filing |
| Contract/Agreement | | Transactional, bilateral obligations |
| Complaint/Petition | | Initiating litigation |
| Demand letter | | Pre-litigation claim |
| Legal opinion | | Formal legal opinion for transaction |
| Discovery requests | | Interrogatories, doc requests |
| Settlement agreement | | Resolving dispute |
| Terms of Service | | User-facing terms |
| Privacy Policy | | Data privacy compliance |
SLUG="document-slug-here"
mkdir -p "legal/$SLUG"/{research,versions}docxpython-docxreferences/document-types.md[TO BE DRAFTED]python3 verify-legal.py legal/$SLUG/--strictSKILL_DIR="..." # from glob
# Search for relevant cases
python3 "$SKILL_DIR/scripts/courtlistener.py" search "search terms" --after 2015 --limit 10
# Get specific opinion details
python3 "$SKILL_DIR/scripts/courtlistener.py" opinion 12345
# Format as Bluebook citation
python3 "$SKILL_DIR/scripts/courtlistener.py" bluebook 12345research/cases.jsonCOURTLISTENER_API_TOKEN# Search regulations
python3 "$SKILL_DIR/scripts/ecfr_lookup.py" search "employment discrimination" --title 29
# Get specific CFR section
python3 "$SKILL_DIR/scripts/ecfr_lookup.py" section 16 444.1
# Search Federal Register for recent rules
python3 "$SKILL_DIR/scripts/ecfr_lookup.py" fedreg "data privacy"references/bluebook.md1. READ all previously written sections for context
2. WRITE the section following document-type conventions
3. REGENERATE the DOCX (update via python-docx)
4. VERIFY: python3 verify-legal.py legal/{slug}/
5. If errors → FIX → go to 3
6. SELF-REFLECT:
- Is every legal assertion supported by authority? (litigation docs)
- Are defined terms used consistently?
- Any ambiguous language? ("reasonable" without standard, "timely" without deadline)
- Cross-references point to correct sections?
- No placeholder text remaining in this section?
7. REVISE if needed → regenerate → verify
8. Section DONE → next"Effective Date" means [definition]."Agreement" means this Services Agreement, including all exhibits and schedules.
"Confidential Information" means any information disclosed by one party to the
other that is designated as confidential or that reasonably should be understood
to be confidential given the nature of the information and the circumstances of
disclosure.
"Deliverables" means the work product to be delivered by Contractor as described
in Exhibit A.IN NO EVENT SHALL EITHER PARTY BE LIABLE TO THE OTHER PARTY FOR ANY
INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES,
REGARDLESS OF THE CAUSE OF ACTION OR THE THEORY OF LIABILITY, EVEN IF
SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
THE TOTAL AGGREGATE LIABILITY OF [PARTY] UNDER THIS AGREEMENT SHALL NOT
EXCEED THE TOTAL FEES PAID BY [OTHER PARTY] DURING THE TWELVE (12) MONTH
PERIOD PRECEDING THE CLAIM.[ISSUE] The issue is whether [legal question under specific law/standard].
[RULE] Under [jurisdiction] law, [state the rule]. See [Authority]. The [court]
has held that [rule elaboration]. [Authority]. Courts consider [factors/elements]:
(1) [factor]; (2) [factor]; and (3) [factor]. [Authority].
[APPLICATION] Here, [apply each factor to the client's facts]. First, [fact]
satisfies [factor] because [reasoning]. See [analogous case]. Unlike in
[distinguishable case], where [different facts led to different outcome], here
[explain why our facts are more like the favorable case].
[CONCLUSION] Therefore, [conclusion on this issue]. A court would likely
[prediction].Good: "I. THE TRIAL COURT ERRED BY GRANTING SUMMARY JUDGMENT BECAUSE
GENUINE DISPUTES OF MATERIAL FACT EXIST."
Bad: "I. SUMMARY JUDGMENT"
Good: "A. Plaintiff's Deposition Testimony Creates a Triable Issue of Fact
Regarding Defendant's Knowledge of the Defect."
Bad: "A. Deposition Testimony"12. On or about March 15, 2024, Plaintiff entered into a written agreement
with Defendant for the purchase of the Property (the "Purchase Agreement").
A true and correct copy of the Purchase Agreement is attached hereto as
Exhibit A and incorporated by reference.
13. Pursuant to Section 4.1 of the Purchase Agreement, Defendant represented
and warranted that the Property was free of all environmental contamination.
14. On or about June 1, 2024, Plaintiff discovered that the Property contained
significant levels of lead contamination in the soil.[INSERT][TBD][TODO]python3 "$SKILL_DIR/scripts/verify-legal.py" "legal/$SLUG/" --strictlegal/{slug}/document.docx# If libreoffice is available:
libreoffice --headless --convert-to pdf "legal/$SLUG/document.docx" --outdir "legal/$SLUG/"
# Or use python-docx2pdf:
pip install docx2pdf && python3 -c "from docx2pdf import convert; convert('legal/$SLUG/document.docx')"docxpython-docx| Jurisdiction | Font | Spacing | Margins | Special |
|---|---|---|---|---|
| Federal appellate | 14pt proportional serif | Double | 1" all | Word limit varies by circuit |
| U.S. Supreme Court | 12pt Century | 2pt leading | Special text field | Booklet format |
| California state | 13pt+ proportional serif | Double | 1.5" left/right | Line numbers required |
| New York state | 12pt+ proportional | Double | 1" all | Varies by court |
| Most federal district | 12pt TNR or similar | Double | 1" all | Check local rules |