## Scope: formatting only
This skill places text the user has already written into a blank California pleading paper template.
- Do not write, draft, complete, rewrite, summarize, or suggest any legal content. That includes captions,
  parties, claims, causes of action, defenses, facts, prayers, citations, and signatures.
- Use the user's words exactly as given. Do not correct, reword, or add to them. If a required caption field is
  missing, ask the user to supply it, or leave it blank. Never invent it.
- If the user asks for legal advice, drafting, a review of their document, deadlines, or which form or court to
  use, say that this skill only formats documents and that they should talk with a lawyer licensed in California.
  Then stop using this skill for that request.
- This skill covers paper format only. It does not check content, deadlines, service, filing fees, Judicial
  Council form requirements, or e-filing requirements (see rule 2.256(b)). It does not cover appellate briefs.
  The user should check the filing court's instructions before filing.
- This skill is general information and a formatting aid. It is not legal advice, and using it does not create an
  attorney-client relationship. It was published by SentryHall, a legal-information site run by a law student who
  is not a lawyer.

Copy the code below exactly, with no changes, into a file named chat_pleading.py, and run it with Python 3. Check its sha256 against the value listed under the code. For a blank template, run python3 chat_pleading.py blank.docx and check that file's sha256 too. If a value does not match, tell the user the file may differ, and copy the code again. If it still does not match, stop.

```python
# California pleading paper (.docx) for chat AI assistants. Python 3, standard library only, no network.
# Blank template: python3 chat_pleading.py out.docx   Filled: python3 chat_pleading.py out.docx caption.json body.txt
# It puts the user's caption fields (JSON) and body text (paragraphs split by blank lines) where the labels are.
import sys,json,zipfile
from xml.sax.saxutils import escape
a=sys.argv;C=a[2:]!=[];D=json.load(open(a[2]))if C else{}
W='http://schemas.openxmlformats.org/';N=f'xmlns:w="{W}wordprocessingml/2006/main" xmlns:r="{W}officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"'
def s(l,r='auto',b=''):return f'<w:spacing{b} w:line="{l}" w:lineRule="{r}"/>'
A,X=s(240),s(480,'exact')
def p(q='',x='',f=''):return f'<w:p><w:pPr>{q}</w:pPr><w:r><w:rPr>{f}</w:rPr><w:t xml:space="preserve">{x}</w:t></w:r></w:p>'
def m(q,k,l,f=''):return''.join(p(q,escape(x),f)for x in D.get(k,'').split('\n'))if C else p(q,f'[{l}]',f)
def c(w,b,x):return f'<w:tc><w:tcPr><w:tcW w:w="{w}"/><w:tcBorders>{b}</w:tcBorders></w:tcPr>{x}</w:tc>'
def g(*e):return''.join(f'<w:{k} w:val="single" w:sz="4"/>'for k in e)
F,K,J='<w:pStyle w:val="FirmInformation"/>','<w:pStyle w:val="Court"/>','<w:jc w:val="both"/>'
L=D.get('attorney_block','').split('\n')if C else['[Attorney or party name, address, phone, fax, email,','State Bar number if any]']
L=[escape(x)for x in L]
if len(L)>12:sys.exit('attorney_block: 12 lines at most')
L+=['']*12
o=''.join(p(F+A*(i!=9),L[i])for i in range(12))+p(K+'<w:jc w:val="left"/>')+m(K,'court_title','Name of court','<w:b/>')+p(K)*2
q=m(A+J,'case_title','Case title')+p(A+J)*2+p('<w:spacing w:before="240"/><w:ind w:left="720"/>'+J)*2+p(A+J)*3+p(K)
R=[('case_number','Case number'),('document_title','Nature of the paper; on a complaint or petition, character of the action'),('judge_dept','Judge and department, if assigned'),('referee','Referee, if one was appointed'),('amount_demanded','Amount demanded statement, if rule 2.111(9) applies'),('limited_civil','Limited Civil Case statement, if rule 2.111(10) applies'),('reclassification','Reclassification statement, if rule 2.111(11) applies'),('hearing','Hearing date, time, and department, if any'),('trial_date','Trial date, if set'),('date_filed','Date action filed, if needed')]
r=''.join(m(A+'<w:ind w:left="256"/>',*R[i],'<w:b/>'*(i==1))for i in range(10))+p(K+'<w:spacing w:after="0"/>')
o+=f'<w:tbl><w:tblPr><w:tblW w:w="10075"/></w:tblPr><w:tblGrid><w:gridCol w:w="5037"/><w:gridCol w:w="5038"/></w:tblGrid><w:tr>{c(5037,g("bottom","right"),q)}{c(5038,g("left"),r)}</w:tr></w:tbl>'
B=[x.strip().replace('\n',' ')for x in(open(a[3]).read()if a[3:]else'').split('\n\n')if x.strip()]or['']
o+=p(s(480,'exact',' w:before="0"'))+''.join(p(X+'<w:ind w:firstLine="720"/>',escape(x))for x in B)+p(A)
o+=f'<w:tbl><w:tblPr/><w:tblGrid><w:gridCol w:w="4990"/><w:gridCol w:w="4990"/></w:tblGrid><w:tr>{c(4990,"",m(X,"signature_date","Date"))}{c(4990,"",p(A)*3+p(A,"_"*39,"<w:b/>")+m(A,"signer_name","Signer name")+p(A)+m(A,"signer_role","Signer&apos;s role","<w:i/>"))}</w:tr></w:tbl>'
o+=p(A)+p('<w:tabs><w:tab w:val="left" w:pos="5040"/></w:tabs>'+A)
o=f'<w:document {N}><w:body>{o}<w:sectPr><w:headerReference w:type="default" r:id="h"/><w:footerReference w:type="default" r:id="f"/><w:pgSz w:w="12240" w:h="15840"/><w:pgMar w:top="1080" w:right="720" w:bottom="1080" w:left="1440" w:header="720" w:footer="360" w:gutter="0"/></w:sectPr></w:body></w:document>'
P='position:absolute;mso-position-horizontal-relative:margin;mso-position-vertical-relative:'
def v(x,y):return f'<w:r><w:pict><v:line style="{P}{y}" from="{x},0" to="{x},11in" strokeweight=".75pt"/></w:pict></w:r>'
G=X+'<w:jc w:val="right"/>';n=''.join(p(G,str(i))for i in range(1,29))+p(G)
h=f'<w:hdr {N}><w:p><w:pPr><w:tabs><w:tab w:val="center" w:pos="4800"/><w:tab w:val="right" w:pos="9600"/></w:tabs>{X}</w:pPr>{v("505.7pt","margin;mso-position-vertical:center")}<w:r><w:pict><v:shapetype id="t" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"/><v:shape type="#t" stroked="f" style="{P}margin;margin-left:-47.15pt;width:36pt;height:669.6pt"><v:textbox inset="0,0,0,0"><w:txbxContent>{n}</w:txbxContent></v:textbox></v:shape></w:pict></w:r>{v("-5.9pt","page")}{v("-3.6pt","page")}</w:p></w:hdr>'
Z='<w:sz w:val="20"/>';Q=A+'<w:ind w:right="90"/><w:jc w:val="center"/><w:rPr>'+Z+'</w:rPr>';E='<w:pBdr><w:top w:val="single" w:sz="4" w:space="1"/></w:pBdr>'
u=''.join(f'<w:r><w:rPr>{Z}</w:rPr>{x}</w:r>'for x in('<w:fldChar w:fldCharType="begin"/>','<w:instrText xml:space="preserve"> PAGE </w:instrText>','<w:fldChar w:fldCharType="separate"/>','<w:t>1</w:t>','<w:fldChar w:fldCharType="end"/>'))
f=f'<w:ftr {N}><w:p><w:pPr>{Q}</w:pPr>{u}</w:p>{m(E+Q,"document_title","Title of the paper",Z)}</w:ftr>'
y=f'<w:styles {N}><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/><w:lang w:val="en-US"/></w:rPr></w:rPrDefault><w:pPrDefault/></w:docDefaults><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:pPr>{s(240,"exact")}</w:pPr><w:rPr><w:sz w:val="24"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="FirmInformation"><w:name w:val="Firm"/><w:basedOn w:val="Normal"/><w:pPr><w:tabs><w:tab w:val="left" w:pos="187"/></w:tabs></w:pPr></w:style><w:style w:type="paragraph" w:styleId="Court"><w:name w:val="Court"/><w:basedOn w:val="Normal"/><w:pPr><w:keepNext/><w:spacing w:after="240"/><w:jc w:val="center"/></w:pPr><w:rPr><w:caps/></w:rPr></w:style></w:styles>'
T='application/vnd.openxmlformats-officedocument.wordprocessingml.';O=W+'officeDocument/2006/relationships/'
z={'[Content_Types].xml':f'<Types xmlns="{W}package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/>'+''.join(f'<Override PartName="/word/{k}.xml" ContentType="{T}{m}+xml"/>'for k,m in(('document','document.main'),('styles','styles'),('settings','settings'),('h','header'),('f','footer')))+'</Types>','_rels/.rels':f'<Relationships xmlns="{W}package/2006/relationships"><Relationship Id="d" Type="{O}officeDocument" Target="word/document.xml"/></Relationships>','word/_rels/document.xml.rels':f'<Relationships xmlns="{W}package/2006/relationships">'+''.join(f'<Relationship Id="{m}" Type="{O}{k}" Target="{m}.xml"/>'for k,m in(('header','h'),('footer','f'),('styles','styles'),('settings','settings')))+'</Relationships>','word/document.xml':o,'word/h.xml':h,'word/f.xml':f,'word/styles.xml':y,'word/settings.xml':f'<w:settings {N}><w:compat><w:compatSetting w:name="compatibilityMode" w:uri="http://schemas.microsoft.com/office/word" w:val="15"/></w:compat></w:settings>'}
with zipfile.ZipFile(a[1],'w')as Y:
 for k in z:
  i=zipfile.ZipInfo(k,(2026,1,1,0,0,0));i.create_system=3;Y.writestr(i,'<?xml version="1.0" encoding="UTF-8"?>'+z[k])
```

chat_pleading.py sha256: a938960835a1db5179832443b30abc028432d4b2262a295f6bef6515a319ca99

blank.docx (python3 chat_pleading.py blank.docx) sha256: 04da8c872d5aacbf83a1e04a54fb0ab64ea133e597debd94f9d42d9d5420509d

To fill the template, write the user's first-page details to caption.json and the user's text to body.txt, exactly as the user gave them. Then run python3 chat_pleading.py out.docx caption.json body.txt and give the user out.docx.
caption.json keys: attorney_block (up to 12 lines), court_title, case_title, case_number, document_title, judge_dept, referee, amount_demanded, limited_civil, reclassification, hearing, trial_date, date_filed, signature_date, signer_name, signer_role. Use only these keys; any other key is ignored. In a value, \n starts a new line.
In body.txt, put a blank line between paragraphs. Single line breaks are joined with a space. The body comes out as plain paragraphs, with no bold, italics, or headings; marks such as ** and # print as typed. A key left out shows as a blank line. If a detail is missing, ask the user for it or leave the key out. Never invent it.

> SentryHall publishes general legal information for educational purposes. It is not legal advice,
> and reading it does not create an attorney-client relationship. The author is a law student, not
> a lawyer. Laws change and apply differently to different facts. For advice about your situation,
> talk with a lawyer licensed in California. You can look up a lawyer's license status at
> [calbar.ca.gov](https://www.calbar.ca.gov).

[Full disclaimer](/disclaimer)
