I put all 8,642 Spanish laws in Git – every reform is a commit

https://github.com/EnriqueLop/legalize-es

Commits · EnriqueLop/legalize-es

Spanish legislation as a Git repo — every law is a Markdown file, every reform a commit. 8,600+ laws. - Commits · EnriqueLop/legalize-es

GitHub

I built a pipeline that converts all Spanish state legislation into version-controlled Markdown. Each law is a file, each reform is a real git commit with the historical date. 8,642 laws, 27,866 commits.

The idea: legislation is just patches on patches on patches. Git already solves this. Instead of reading "strike paragraph 3 and replace with...", you get an actual diff.

The repo is the product. Browse any law, git log to see its full reform history, git diff to see exactly what changed.

Built the pipeline in ~4 hours with Claude Code. Source is BOE (Spain's official gazette) consolidated legislation API.

Exploring whether there's a business here — structured legislation API for legaltech/compliance, or just a useful open dataset. Curious what HN would build with this data.

cool idea, how far back (in time) do those 27k commits go?

Just thinking how this could maybe used for (automated) research / visualization on the evolution of (spanish - in this case) law

> how far back (in time) do those 27k commits go

Looking at the commit dates (which seem to be derived from the original publication dates) the history seems quite sparse/incomplete(?) I mean, there have only been 26 commits since 2000.

It seems the commits aren't in proper date order. Here are some newer changes, placed before the latest commits:
https://github.com/EnriqueLop/legalize-es/commits/master/?af...
Commits · EnriqueLop/legalize-es

Spanish legislation as a Git repo — every law is a Markdown file, every reform a commit. 8,600+ laws. - Commits · EnriqueLop/legalize-es

GitHub
Laws intent are often clarified in courts through judgments. If you can overlay the judgements on top of the corresponding law, at correct points in time, I think that will have value. It might, for example, show which laws were referenced the most and which needed to be clarified the most. It might give insights into what legal language constructs stood the test of time and which had to be repeatedly clarified.

That's true, but it might not be as important here.

Spain is not a country with a Common Law legal system entirely like the US or the UK. They have a civil law system where prior court judgement does not form a strictly binding precedent. Prior judgements can be important, but case law is not really a thing.

Laws are often cascaded as well. Specifically in this case, Spain is subdivided into Comunidades Autonomas - each have their own elected parliament. And inside those are cities with their own local laws.

So while this project does track laws, is there any facility to determine which laws from which bodies are relevant to a specific activity in a specific location?

Oooh Can you elaborate a bit how the gazette is publishing them? Like what format did you have to parse. And how many documents were there in total? I tried doing the same for German laws 1-2 years ago but LLMs weren't smart enough yet. And the costs would've been at least a couple of thousand €.

Ed: Nevermind, I missed the "BOE (Spain's official gazette) consolidated legislation API" part. Sending jealous greetings from Germany. We just have a bunch of PDFs in Germany. And the private entity that has been publishing them for decades even claims copyright on them!

I think this is great. Only limit of git is I can't imagine "git blame" works. It would be nice to know who voted for and against each patch. Git isn't structured for collaborative commits.

That could actually be a git commit log with date, votes and other metadata.

But getting the entire country's law into git is already an impressive feat.

Yeah you can, just smash commits on the PR where multiple contributed. It will say it was a collaborative commit in history showing all their avatars.
I did the same with a limited subset of dutch laws a while back: https://github.com/sigio?tab=repositories&q=wetboek
sigio - Repositories

Linux Ops/admin. sigio has 96 repositories available. Follow their code on GitHub.

GitHub

Congratulations! This is a very cool project. A few years ago there were similar ones -- browse gitlaw.

In Brazil we have lexml, a standard to describe the law and their changes over time. It's surprisingly complex.

Hah! XML strikes again. :-)

I understand that Spain was a participant in LexML as well... I gather they've since converted to something else?