Legal automation
Initial Petition Agent
An AI agent that drafts disability-benefit petitions from scratch: downloads the client's documents, diagnoses the case, picks the template, calculates arrears and delivers the Word document in the firm's standard — validated by seven gates.
- automated tests
- 105
- official DOCX templates
- 29

Architecture
- Python
- python-docx
- PowerShell
Features
- Downloads only the needed documents for each client from the firm's system, one client at a time, and saves them to Drive in a folder per client named by a fixed legal sequence of 14 types — power of attorney, work card, PPP, proof of address, accident report, medical report, CNIS, award letter and the rest.
- Reads the award letter, INSS medical exams, accident report, CNIS and work card, builds a pre-filled sheet and classifies the case into one of four templates (benefit ceased with or without a new claim, accident with no prior sick pay, non-work accident in federal court), with variants for accident reports pulled from INSS open data.
- Only uses the benefit's cessation date with documentary proof that it concerns the same condition; without proof and without a claim, the case comes back as "consult" instead of becoming a wrong petition.
- Calculates arrears and the claim value: benefit amount carried forward by RGPS adjustments since 2006, monetary correction by monthly SELIC under the EC 113 regime and INPC + legal rate from Sep/2025, five-year limitation, pro-rata 13th and twelve future installments — with a PDF and an audit JSON.
- Seven gates before finishing: real documents, accident-report sheet line by line, legal and structural rules, re-rendering in Word, page check, persistence in Drive with hash, and report. A failed client stays pending and the batch goes on.
- Also normalizes old petitions to the official visual standard without changing the text, analyzes ongoing cases and drafts responses to expert reports with 20 templates by hypothesis and body segment.
Infrastructure
- A Claude skill: Claude in Chrome with the user's session for downloads, injected JavaScript with pdf.js to classify documents by content, and a local Python receiver that accepts the manifest only on 127.0.0.1.
- Python engine — 43 scripts, 105 tests — with python-docx and lxml for the document, PyMuPDF to read the files and reportlab for the calculation PDF; PowerShell renders in Word and saves the client to Drive.
- SELIC series versioned from the Central Bank API: an index outside the official series blocks the calculation, and updates are only written if the tests pass.
- Firm rules in a configuration file that evolves: every new instruction becomes a rule and a new version of the skill.
What it solves
- A document that took hours of reading and typing comes out of one command, in the firm's visual standard and with the calculation attached.
- The right template is picked by fixed criteria, and a real legal doubt becomes a flagged pending item, not an improvised petition.
- Auditable claim value: every installment with the official index and a JSON showing where it came from.
- The team reviews and files; drafting, page checks and archiving come ready.
Want something similar?
Tell me how your process works today. In a quick call I get to know the problem and send a proposal with scope, timeline and price.