[KongchangAI]
· 3 min read· 1,516 words

Claude Moves Global Law into Git: A New Paradigm for Semantic, Versioned Legal Queries

Claude Moves Global Law into Git: A New Paradigm for Semantic, Versioned Legal Queries

Developer uses Claude Code to turn global law into Git repositories, enabling versioning and Agent-queryable access.

The「Global Law」project uses Claude Code to convert the legal statutes of various countries into Git repositories, making law semantic, versioned, and traceable. It opens a separate session for each country to scrape official data, reconstructs historical versions in reverse from amendments, and ensures hash consistency and data integrity through build scripts. Open-sourced under CC0 and topping Hacker News, it provides AI Agents with a reliable source of legal knowledge, potentially alleviating hallucination in legal Q&A and spawning new legal tech tools.

Project Overview: When Law Meets Version Control

A project called「Global Law」posted by a developer on Hacker News topped the daily leaderboard and sparked widespread discussion (original thread). The core idea is straightforward: use Claude Code to convert the legal statutes of countries around the world into Git repositories, making law semantic, versioned, and traceable, while also being directly queryable by AI Agents. The author open-sourced it under the CC0 license, with the repository at github.com/lexifina/global-law.

reddit source: Using Claude to put all Global Law into Git

The ambition here is not to build a legal database, but to redefine the "programmability" of law. Traditionally, legal texts are scattered across government websites in various countries, with inconsistent formats and historical versions that are hard to trace. Through Git's commit history, the enactment, amendment, and repeal of every law becomes a commit, with a clearly visible timeline.

A Divide-and-Conquer Scraping Strategy

Rather than using one massive script to handle all countries, the author opened a separate Claude Code session for each country or group of countries. Each session is responsible for reading that country's official publication website or API, checking robots.txt and terms of use, and then writing a script to download every version of every law. This divide-and-conquer strategy reduces complexity and compliance risk, and also lets Claude focus on that country's specific rules within its own context.

robots.txt is a text file in a website's root directory that follows the "Robots Exclusion Protocol," used to tell crawlers which paths may be scraped and which should be avoided. It is not legally binding but an industry convention, and large websites often use it to limit high-frequency access. In legal data scraping scenarios, complying with robots.txt and terms of service is not just technical courtesy but also a matter of compliance risk: some government websites explicitly prohibit bulk downloading, and violations may trigger access restrictions or even legal disputes. Therefore, checking robots.txt separately for each country is essentially establishing a front-line gate between engineering efficiency and legal compliance.

Reconstructing Historical Versions from Amendments

Not all countries directly publish historical versions of their laws. Some sources only provide amending Acts, which means past states must be reconstructed in reverse from the current text. The scripts written by Claude apply each amendment in chronological order, thereby restoring each historical version. This is equivalent to a "reverse compilation" of legal texts, allowing the Git history to fully cover the evolution of the law.

Amending Acts are legal documents through which the legislature makes partial modifications to existing law. They usually only describe incremental changes such as "delete Article X" or "insert Z after Article Y," rather than republishing the full legal text. Official publication channels in many countries retain only the current consolidated version and the successive amendments; the full historical texts are not directly available. To reconstruct the state of the law at a past point in time from these fragments, amendments must be applied in reverse or forward chronological order, handling issues such as clause-number shifts, cross-statute references, and differences in effective dates. This process is known in legal informatics as "legal text version reconstruction" and is the core difficulty in building a trustworthy legal timeline.

Cross-Session Knowledge Sharing

Multiple Claude Code sessions are not isolated. They share discovered issues, such as handling dates before 1970, daylight saving time edge cases, and other special changes. This collaborative mechanism allows each session to benefit from the experience of others, reducing repeated pitfalls. The author mentions that the way these sessions share findings is one of the keys to the project's efficient progress.

Reproducible Builds and Hash Consistency

To ensure the reliability of the version control system, the author asked Claude to write build scripts that ensure two independent builds produce byte-for-byte identical hashes. The author admits that he would normally consider such a requirement "over-engineering," but for a version control system for law that requires high trust, hash consistency is a necessary safeguard. This means that anyone who clones the repository and rebuilds it will get exactly the same result, thereby verifying data integrity.

Hash consistency means that after executing the same build process on the same input, the cryptographic hash values of the output files (such as SHA-256) are completely identical. It requires the build process to exclude uncertain factors such as timestamps, random numbers, and file system ordering, achieving a "reproducible build." In the software supply chain, this property is used to verify that binary artifacts have not been tampered with; in a legal data repository, it is equally critical: if anyone clones the repository, re-scrapes, and rebuilds, and the hash matches the published version, it proves that the data has not been quietly modified during transmission and storage. This provides cryptographic-level assurance for the integrity and auditability of legal texts.

Design Decisions: Semantic, Versioned, and Agent-Queryable

The project's design goals center on three keywords: semantic, versioned, and attributable. Semantic means that legal texts are no longer flat PDFs or HTML but structured data that is easy for machines to understand and query. Versioning is achieved through Git's commit history, where every modification has a clear timestamp and change content. Attributability is reflected in git blame, where every legal provision can be traced back to a specific commit and source.

The author emphasizes that this information should be freely accessible, hence the choice of the CC0 license, allowing anyone to use it in any way. This openness is consistent with the principle that legal information itself should be public and transparent. For AI Agents, a structured, queryable legal repository means they can answer law-related questions more accurately, rather than relying on potentially outdated or incorrect training data.

Community Response and Potential Challenges

The project topped Hacker News, indicating strong interest in the developer community in making legal data programmable. Issues likely discussed include: how to ensure the accuracy of legal texts, how to handle differences among national legal systems, and whether large-scale scraping will put pressure on government websites. In the post, the author welcomes all comments and suggestions, showing an open and collaborative attitude.

From a technical perspective, turning global law into Git still faces many challenges. Legal texts are updated at different frequencies; some countries amend frequently, while others are relatively stable. The Git repository may become huge, especially when every historical version is fully stored. In addition, the complexity and ambiguity of legal language place high demands on semantic processing, and the accuracy of Claude in parsing and structuring legal texts needs continuous verification.

The most attractive aspect of this project is that it provides AI Agents with a reliable source of legal knowledge. Current large language models often hallucinate in legal Q&A, citing nonexistent statutes or outdated regulations. A versioned legal Git repository can serve as the underlying data for retrieval-augmented generation (RAG), allowing Agents to cite specific commits and versions when answering, thereby improving credibility.

For the legal tech industry, this model may spawn new tools and services. Law firms can use similar methods to manage internal legal knowledge bases, compliance teams can track the impact of regulatory changes on business, and developers can build analytical applications based on legal version history. The CC0 license further lowers the barrier to use, encouraging both commercial and non-commercial innovation.

Of course, the project is still in its early stages, and its coverage and accuracy need community scrutiny. But its direction is worth watching: transforming law from static documents into dynamic, programmable data assets. This may be an important step toward making legal informatics practical.

Retrieval-Augmented Generation (RAG) is a technical architecture that lets large language models retrieve external knowledge bases before generating answers. Unlike relying on training data固化 in model parameters, RAG converts user questions into queries, recalls relevant document fragments from vector databases or structured repositories, and then provides them as context for the model to generate answers. Its advantages are that knowledge can be updated, sources can be traced, and hallucinations can be suppressed. For legal Q&A, RAG enables Agents to cite specific statutes, versions, and commit records rather than fabricating from memory. A versioned Git repository like Global Law can serve precisely as the underlying data source for RAG, anchoring every answer in verifiable legal texts.

One-line Summary

A developer uses Claude Code to turn global law into Git repositories, enabling versioning and Agent-queryable access.

Paragraph Summary

The「Global Law」project uses Claude Code to convert the legal statutes of various countries into Git repositories, making law semantic, versioned, and traceable. The project opens a separate session for each country to scrape official data, reconstructs historical versions in reverse from amendments, and improves efficiency through cross-session experience sharing. Build scripts ensure hash consistency and safeguard data integrity. The design goals are semantic, versioned, and attributable, and it is open-sourced under CC0. The project topped Hacker News, providing AI Agents with a reliable source of legal knowledge, potentially alleviating hallucination in legal Q&A and spawning new legal tech tools.

#Claude Code#Global Law#Git version control#legal tech#AI Agent#retrieval-augmented generation#CC0 open source
Share:

Related articles