agentleFS
hsigstadhsigstad/research-kit/skills/diarios/SKILL.md

diarios

Skill0 starsChanged 4 months agoMITView on GitHub

Reference for the shared diarios Python module — API lookup, usage patterns, and gotchas. Use when writing code that involves court data, legal text parsing, Brazilian administrative data cleaning, or when checking if a utility already exists before writing a new one.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read $ROOT/research-kit/meta/diarios_api.md for the full module inventory.

    line 14
  2. Distinctive:

    Do NOT duplicate diarios functionality: If you're about to write a function for cleaning CPFs, parsing case numbers, normalizing …

    line 77
  3. Distinctive:

    Write a new text cleaning function for Brazilian data

    line 87
  4. Very specific:

    Before writing new code, check if diarios already has the function you need.

    line 94

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

diarios Module Reference

The diarios package is a shared Python module used across projects for Brazilian court and administrative data processing. Always check here before writing new utility functions.

Quick API reference

The workspace root contains CLAUDE.md alongside projects/, pipelines/, diarios/, research/. If the current directory is inside a project or pipeline, search upward to find the root.

Read $ROOT/research-kit/meta/diarios_api.md for the full module inventory. Key areas:

Text & Data Cleaning (diarios.clean.text)

  • clean_text() — clean text (character removal, case, accents)
  • map_regex() / remove_regexes() / extract_series() — regex utilities
  • add_leads_and_lags() — panel data lag/lead construction
  • read_csv() — CSV reader with sensible defaults

Number & ID Cleaning (diarios.clean.numbers)

  • clean_cnj_number() / is_cnj_number() — CNJ case number normalization
  • clean_reais() / parse_brl() — Brazilian currency parsing
  • clean_cpf() — CPF tax ID cleaning
  • clean_oab() — OAB lawyer number cleaning
  • get_tribunal() / get_filing_year() — extract metadata from case numbers

Legal Domain (diarios.clean.legal)

  • clean_parte() / clean_parte_key() — party name cleaning
  • clean_classe() — case class normalization
  • get_procedencia() / get_plaintiffwins() — outcome extraction
  • load_datajud_jsonl() / normalize_datajud() — DataJud data loading

Geography (diarios.clean.geo)

  • TRT / TRF classes — Regional Labor/Federal Court representations
  • clean_municipio() / get_municipio_id() — municipality normalization
  • clean_comarca() / clean_vara() — court jurisdiction cleaning

Court Parsing (diarios.parse)

  • CaseParser class — parse court cases with customizable regex
  • parse_diario_extract() — parse diary extracts
  • inspect() — inspection utility

Court Docket Parsers (diarios.consulta)

  • consulta.TJSP — parse_consulta_tjsp_from_zip()
  • consulta.STF — parse_consulta_stf()
  • consulta.STJ — parse_consulta_stj()
  • consulta.TRF1 — parse_consulta_trf1()

Decision Parsing (diarios.decision)

  • DecisionParser class — parse court rulings into structured components

Other

  • diarios.database — query(), insert(), connect()
  • diarios.io — read_files(), extract_pdf_text(), ocr_file()
  • diarios.politica — split_coalition(), get_district(), get_office_type()
  • diarios.close_election — is_close() for RDD analysis

Common patterns

When you need to...Use...
Parse BRL currencydiarios.clean.numbers.clean_reais()
Normalize municipality namesdiarios.clean.geo.clean_municipio()
Clean CNJ case numbersdiarios.clean.numbers.clean_cnj_number()
Clean party namesdiarios.clean.legal.clean_parte()
Parse TJSP docket datadiarios.consulta.TJSP.parse_consulta_tjsp_from_zip()
Extract text from PDFsdiarios.io.extract_pdf_text()
Determine plaintiff windiarios.clean.legal.get_plaintiffwins()
Add leads/lags to paneldiarios.clean.text.add_leads_and_lags()

Gotchas

  • Always import from the specific submodule, not top-level, for non-exported functions. E.g., from diarios.clean.numbers import clean_reais, not from diarios import clean_reais.
  • Top-level exports are limited to: CaseParser, DiarioParser, parse_diario_extract, inspect, Extractor, query, normalize_datajud. Everything else requires submodule imports.
  • Do NOT duplicate diarios functionality. If you're about to write a function for cleaning CPFs, parsing case numbers, normalizing municipalities, etc. — check this reference first. The function almost certainly exists.
  • Do NOT modify diarios unless the user explicitly instructs you to. If you find a bug or need an enhancement, flag it to the user.
  • The module has optional dependencies: ocr (pytesseract, pdf2image) and db (SQLAlchemy). Code using these features needs the optional extras installed.
  • map_regex() returns the first match — order patterns most-specific-first.
  • clean_municipio() and clean_parte() handle accent removal internally via Unidecode — don't pre-clean accents before calling them.
  • For the full source code, read files in $ROOT/packages/diarios/diarios/. For the API summary, read $ROOT/research-kit/meta/diarios_api.md.

When this skill triggers automatically

This skill should be consulted (even without explicit /diarios invocation) whenever you're about to:

  • Write a new text cleaning function for Brazilian data
  • Parse court case numbers or docket data
  • Clean party names, CPFs, OAB numbers, or municipality names
  • Work with DataJud data
  • Extract text from PDFs or perform OCR
  • Build panel data with leads/lags

Before writing new code, check if diarios already has the function you need.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.