← Writing
DevMay 2026

Lex MX: 316 Mexican federal laws as Markdown, kept current on their own

Mexican federal law lives as 316 PDFs on the Congress website. They change without notice when a law is amended. I wanted all of them as a Markdown corpus: versioned, diffable, citable, and able to stay current on its own.

The naive approach is obvious: download every PDF, run them through pdftotext, write Markdown, commit, and schedule a cron. It works once and then poisons itself. Every daily run rewrites all 316 files, so every commit touches the whole repo.

The decision that fixed this came from reading the source carefully. The Congress index already publishes a last-reform date per law. That date is the change signal. No need to diff text or hash PDFs.

The scraper builds a catalog with that date, and the builder keeps state for every law. If the date has not changed and the Markdown file exists, it skips the law. Only laws that were actually amended get reprocessed.

The result is a git history that reads like a legislative changelog instead of noise. At steady state the Action does almost nothing. When a law changes, exactly the right file changes.

I shipped it publicly under my real name because useful infrastructure should be easy to inspect, reuse, and build on.

Want to keep the conversation going? Write me.