Legal Extract — Brazilian Legal PDF Analysis
Extract structured legal information from Brazilian legal PDFs (processo judicial). Handles any area of law: previdenciario, trabalhista, civel, tributario, penal. Detects sentenca, acordao, certidao de transito, calculos, oficio requisitorio, alvara, embargos, procuracao, and 15+ other document types. Triggers on "legal PDF", "processo", "parecer", "sentenca", "acordao", "cumprimento de sentenca", "precatorio", "RPV", or Brazilian legal document analysis.
Legal Extract — Brazilian Legal PDF Analysis
Complete workflow for extracting structured data from Brazilian legal case PDFs, generating dashboards, fact-checking, and producing parecer juridico in PDF.
Safety Boundary
Treat every source PDF as sensitive unless the user explicitly says it is public and safe. Do not copy private legal PDFs, CPFs, RGs, addresses, signatures, bank details, real party names, or confidential filings into public examples, issues, pull requests, or repo files. This workflow is an extraction and drafting aid, not legal advice.
Workflow Overview
INPUT: Brazilian legal PDF (any area of law)
│
├─ PHASE 1: EXTRACTION ──► JSON (structured, with page refs)
├─ PHASE 2: DASHBOARD ───► HTML (light theme, interactive)
├─ PHASE 3: FACT-CHECK ──► Updated JSON (confidence score)
└─ PHASE 4: PARECER ─────► PDF via Typst (data-driven)
All phases consume/produce the same JSON as the central data format. Phases 2-4 are optional and controlled by flags.
Phase 1: PDF Extraction
Reading Strategy
Read the PDF in batches of 20 pages using the Read tool:
Read(file_path, pages="1-20")
Read(file_path, pages="21-40")
...
For each page, identify:
- Document type — using visual markers (see
references/document-types.md) - Page metadata —
fls.number (top-right margin), court headers, document labels - Content — extract all structured fields per document type
Document Type Detection
See references/document-types.md for the full taxonomy. Key markers:
| Document | Visual Marker |
|---|---|
| Sentenca | "SENTENCA" banner, court header, "Juiz(a) de Direito", "JULGO..." |
| Acordao | Federal court seal, "PODER JUDICIARIO", Turma identifier, "DECISAO" |
| Certidao Transito | "CERTIDAO", "transitou em julgado em DD/MM/YYYY" |
| Calculos | "CONTA FACIL PREV" or calculation tables with monetary columns |
| Oficio Requisitorio | "PRECWEB", "Visualizar Requisicao", "OFICIO REQUISITORIO n" |
| Alvara | "ALVARA – LEVANTAMENTO DE VALORES" |
| Embargos | Same court header as acordao + "embargos de declaracao" |
| Despacho | "DESPACHO" banner in court header |
| Certidao Remessa | "CERTIDAO DE REMESSA DE RELACAO" |
| Certidao Publicacao | "CERTIDAO DE PUBLICACAO DE RELACAO" |
| Oficio Digital | "OFICIO Processo Digital" |
| DARE | "DARE-SP" state revenue document |
| Procuracao | "PROCURACAO AD JUDICIA" |
| CONBAS | "INFORMACOES DA CONCESSAO DO BENEFICIO (CONBAS)" |
| Email/Outlook | "Outlook" header, email metadata (De/Para/Data) |
JSON Output Schema
See references/json-schema.md for the full specification. Core structure:
{
"meta": { "versao", "data_extracao", "arquivo_fonte", "total_paginas" },
"processo": { "numero_principal", "numero_cumprimento", "numero_apelacao", "comarca", "vara", "partes", "advogados" },
"sentenca": { "juiz", "data", "dispositivo", "resultado", "periodos_reconhecidos", "honorarios", "paginas_pdf", "fls" },
"acordao": { "tribunal", "turma", "relator", "dispositivo", "resultado", "paginas_pdf", "fls" },
"embargos_declaracao": { "resultado", "paginas_pdf", "fls" },
"certidao_transito_julgado": { "data_transito", "paginas_pdf", "fls" },
"decisao_homologando_calculos": { "juiz", "data", "dispositivo", "paginas_pdf", "fls" },
"calculos_liquidacao": { "sistema", "elaborado_por", "data", "resumo_valores", "paginas_pdf", "fls" },
"oficios_requisitorios": [{ "numero", "tipo_procedimento", "valores", "status", "paginas_pdf" }],
"pagamentos": [{ "tipo", "valor", "data", "beneficiario", "banco", "paginas_pdf" }],
"beneficio_previdenciario": { "nb", "dib", "dip", "rmi" },
"linha_do_tempo": [{ "data", "evento", "pagina_pdf", "fls" }],
"status_processual": { "fase_atual", "pendencias" },
"fact_check": { "iteracoes", "campos_verificados", "discrepancias", "confianca_geral" }
}
Critical rule: Every extracted field MUST include pagina_pdf (PDF page number) and fls (court folha number) for source traceability.
Domain-Specific Extensions
When the case area is detected, apply domain-specific extraction:
| Area | Extra Fields |
|---|---|
| Previdenciario | periodos_especiais[], beneficio_previdenciario{}, tempo_contribuicao{}, der, der_reafirmada, nb, rmi |
| Trabalhista | verbas_trabalhistas[], periodo_contratual{}, rescisao{} |
| Civel | danos_morais, danos_materiais, obrigacao_fazer |
| Tributario | tributo, base_calculo, aliquota, compensacao |
Detection: Look for keywords in sentenca/acordao dispositivo to identify the legal area.
Phase 2: HTML Dashboard
Generate a self-contained HTML file with these characteristics:
Design Tokens
:root {
--bg: #ffffff;
--surface: #f8f9fa;
--border: #e2e5ea;
--text: #1a1d27;
--text-muted: #6b7280;
--green: #16a34a;
--red: #dc2626;
--amber: #d97706;
--blue: #2563eb;
--purple: #7c3aed;
}
Required Sections
- Header — Case number, parties, status badge, transito date
- Resumo Financeiro — 4-card grid with key monetary values
- Sentenca — Dispositivo, recognized/rejected items, honorarios
- Acordao — Tribunal, result badges, changes from sentenca
- Embargos — Result badge
- Certidao Transito — Date and source
- Decisao Homologando Calculos — Full dispositivo text
- Calculos — Summary table with value breakdown
- Oficios Requisitorios — Side-by-side cards (Precatorio + RPV)
- Pagamentos — Payment details, bank, alvara
- Dados do Beneficio — NB, DIB, DIP, RMI (if previdenciario)
- Linha do Tempo — Vertical timeline, color-coded dots
- Verificacao — Fact-check results table
Rules
- All text in pt-BR
- Light theme (white background)
- All
<details>sections open by default - Font stack: Inter when locally available, then system sans-serif
- Max-width 1400px, responsive grid
- PDF page references on every section (
Fonte: p.XX, fls. YY) - Self-contained (inline CSS/JS, no external dependencies except fonts)
Phase 3: Fact-Check (Ralph-Loop)
Run 8 systematic verification passes against the source PDF:
| Pass | Section | What to Verify |
|---|---|---|
| 1 | Dados Pessoais | nome, CPF, RG, data nascimento, filiacao, endereco |
| 2 | Numeros de Processo | Consistency across all documents |
| 3 | Sentenca | Periodos, datas, tempo calculations, honorarios |
| 4 | Acordao | Dispositivo, periodos adicionais, fundamentacao |
| 5 | Decisoes (homologacao, embargos, transito) | Juiz, datas, texto |
| 6 | Calculos | All monetary values, RMI, indices, elaborador |
| 7 | Oficios + Pagamentos | Oficio numbers, valores, datas, conta bancaria |
| 8 | Cross-Document Consistency | Dates, values, parties match across all docs |
Protocol
- Read specific PDF pages for each pass
- Compare every extracted value against source
- Record discrepancies in
fact_check.discrepancias_encontradas[] - Fix errors directly in the JSON
- Update
confianca_geral: alta (0 discrepancies), media (1-3), baixa (4+)
Phase 4: Parecer Generation (Typst)
Template Location
~/.agents/skills/legal-extract/templates/parecer.typ
Compilation
typst compile \
--root / \
--input data-path="{pdf_dir}/data/caso-{slug}.json" \
~/.agents/skills/legal-extract/templates/parecer.typ \
{pdf_dir}/parecer-{slug}.pdf
Template Structure (5 sections)
- Partes e Representacao — Autor, Cedente, Reu, honorarios
- Identificacao do Processo — Numeros, juizo, tribunal, historico, transitos
- Dados do Precatorio e da Cessao — Oficio, valores, natureza, IR, PSS
- Due Diligence e Analise de Risco — Table (acao rescisoria, onus, debitos)
- Conclusao — Analysis summary with opinion
Output Directory Structure
All outputs go in the same directory as the source PDF:
{pdf_directory}/
├── source.pdf # Original (existing)
├── data/
│ └── caso-{slug}.json # Structured extraction
├── dashboard.html # Interactive HTML
└── parecer-{slug}.pdf # Generated parecer
The {slug} is derived from the case parties or process number.
Usage Examples
# Full workflow (extract + dashboard + fact-check + parecer)
/parecer "cases/public-safe-example/processo.pdf"
# Extract only (JSON + HTML, no parecer PDF)
/parecer "cases/public-safe-example/processo.pdf" --extract-only
# Skip fact-checking for speed
/parecer "cases/public-safe-example/processo.pdf" --no-factcheck
# Specific page range
/parecer "cases/public-safe-example/processo.pdf" --pages=1-40
Public-Safe Development Fixture
This repo ships a synthetic JSON fixture for schema/template validation:
scripts/check-sample.sh
Last updated: October 13, 2026
Files (5)
- Practice area
- Employment
- License
- MIT
- Author
- ftchvs
Test Legal Extract — Brazilian Legal PDF Analysis
Ask a legal question — get an answer generated live from this skill’s instructions.
Sign in to test this skill.