[KongchangAI]
· 2 min read· 1,316 words

Putting Global Law into Git with Claude: The Ambition of Semantic Versioning

Putting Global Law into Git with Claude: The Ambition of Semantic Versioning

Using Claude agents to version national laws into Git repositories, making laws traceable and queryable.

The project topped Hacker News, attempting to use Claude agents to convert global laws into Git repositories: each country is assigned an agent that reads official legal publication platforms, complies with robots.txt and terms of use, and writes scripts to download all versions of each law, recording changes as commit history where the commit date is the law's effective date. When only amendments are officially available, agents reverse-apply them to reconstruct historical full texts, and laws from various countries are interwoven as Git submodules into a unified tree, with build scripts ensuring hash-consistent reproducibility. The article analyzes the value of this concept for legal versioning and AI agent querying, points out practical challenges such as accuracy, copyright differences, and long-term maintenance, and discusses the lessons of multi-agent shared discovery and reproducible builds for broader AI workflows.

When Law Meets Git: A Wild Open-Source Idea

The "Using Claude to put all Global Law into Git" project, which topped Hacker News, attempts to use AI agents to convert the laws of various countries into Git repositories, making every law traceable and queryable. The author, lexifina, shared this idea on Reddit: making all laws semantic, versioned, easy to attribute, and queryable by AI agents. The project uses the CC0 license, with code and data fully open.

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

The core logic of this project isn't complicated: use Claude to create an agent for each country, read the official publication website or API, check robots.txt and terms of use, then write scripts to download all versions of each law, ultimately outputting them as Git history—each change corresponds to a commit, and the commit date is the law's effective date.

Technical Implementation: Multi-Agent Collaboration and Historical Reconstruction

One Agent per Country

The project assigns a Claude agent to each country. The agent needs to autonomously accomplish several things: access the official legal publication platform, comply with robots.txt and terms of use, write download scripts, and handle various edge cases. This "one country, one agent" architecture allows the project to proceed in parallel while preserving the uniqueness of each country's legal system.

Agents share discoveries with each other. For example, handling dates before 1970, daylight saving time edge cases, and other experiences are propagated within the session, reducing repeated pitfalls. This is equivalent to letting AI agents form a collaborative network to jointly solve complex cross-jurisdictional problems.

Reconstructing Historical Versions Using Amendments

Many countries' official publication channels only provide amendments, not historical full-text versions of laws. The project's approach is: starting from the current version, reverse-apply each amendment to reconstruct all past versions. This requires agents to accurately understand the effective dates and modification contents of amendments—technically challenging, but once successful, it provides a complete version timeline for laws.

An amendment is a partial modification made by the legislature to the text of an existing law, usually expressed in forms like "delete Article X" or "change paragraph Y to...", and does not itself contain the full context of the amended law. Therefore, to restore historical full texts from official channels that only preserve amendments, one must reverse-execute each modification along the timeline: first take the current consolidated version, then reverse-undo the most recent amendment, gradually rolling back to the target date. The key difficulty in this process is that an amendment's effective date may differ from its promulgation date, and the same provision may be modified multiple times and in intersecting ways, requiring precise semantic parsing rather than simple text replacement.

The Interwoven History of Multi-Country Laws

The laws of various countries will ultimately be combined into a unified tree. Each country serves as a Git submodule, and all histories are interwoven by effective date. The author also had Claude write build scripts to ensure that two independent builds produce identical hashes—this reproducibility is crucial in version control systems, although the author himself admits this is usually considered over-engineering.

Git submodules allow a repository to embed another independent Git repository as a subdirectory and record the specific commit it points to. In this project, each country's law repository is mounted as a submodule under a unified main repository. The main repository only stores the commit pointers of each submodule, thereby forming a "tree" that can be browsed uniformly by effective date without merging the vast histories of each country. The advantage of submodules is that each jurisdiction can be updated and cloned independently, keeping the main repository lightweight; the cost is that the main repository does not automatically track the latest commits of submodules and requires explicit pointer updates, which imposes additional operational requirements for continuously syncing legal changes across countries.

Version management of legal texts has always been a pain point. It is difficult for ordinary users to trace the exact wording of a law at a specific point in time, and lawyers and judges also need to spend a lot of time verifying historical versions. Git's commit history, blame function, and branching model happen to provide an intuitive solution: each legal change is a commit, and who modified what and when is clear at a glance.

More importantly, Git repositories can be directly queried by AI agents. The project author explicitly states that the goal is to make laws "queryable by agents." This means future AI legal assistants can directly read Git history to answer questions like "what did a certain law stipulate in a certain month of a certain year" without relying on manually curated databases.

Git's blame function annotates each line with the commit, author, and time of the last modification to that line, while git log records the complete change history by commit. After mapping legal texts to Git, each revision of a provision corresponds to a commit, and blame can directly answer "which amendment introduced the current wording of this sentence." However, the paragraph structure of legal texts is more irregular than code, and relying solely on line-level diffs may produce a lot of noise when provisions are rearranged. Usually, semantic commit messages and tags are also needed to mark legal effective nodes so that version history is truly readable and queryable.

The challenges facing this project are equally obvious. The accuracy of legal texts is crucial, and AI agents may make mistakes when downloading and reconstructing historical versions, especially when amendment language is ambiguous or open to multiple interpretations. Although the author emphasizes the reproducibility of build scripts, the reliability of data sources remains uncertain.

Copyright issues are also worth attention. Although the project uses the CC0 license, the copyright status of legal texts varies by country. Some countries' legal texts are in the public domain, while others may have specific terms of use. Agents need to carefully handle these differences when checking robots.txt and terms of use.

Maintenance cost is another practical issue. Laws are constantly changing, and the project needs continuous updates. Although the multi-agent architecture can work in parallel, long-term maintenance requires stable computing power support and human oversight. The author welcomes comments and suggestions on Reddit, indicating that the project is still in its early stages.

Reproducible build means that, under the same input and environment, two independent builds should produce byte-for-byte identical artifacts with consistent hashes. In a pipeline involving AI agents, this means that download sources, parsing rules, amendment application order, and serialization formats must all be completely fixed; any randomness or timestamp differences will break hash consistency. Achieving reproducible builds can effectively verify whether agent outputs have been accidentally tampered with or affected by model non-determinism. It is a fundamental means of making AI-generated legal data auditable, but it also significantly increases engineering constraints and debugging costs.

Implications for AI Agent Workflows

Setting aside the legal domain, this project demonstrates an AI application pattern worth noting: having multiple Claude agents each responsible for an independent subtask and improving overall efficiency through shared discoveries. This "agent cluster" approach can be transferred to other scenarios that need to process large amounts of heterogeneous data, such as organizing academic literature or managing corporate compliance documents.

The project's commitment to reproducible builds is also worth learning from. In today's world where AI-generated content is increasingly common, ensuring that outputs are verifiable and reproducible is key to building trust. By having Claude write build scripts and verify hash consistency, the author is effectively establishing a quality assurance mechanism for AI-generated data.

The project is currently open-sourced on GitHub, and the author hopes for more feedback. Regardless of ultimate success or failure, this attempt provides an interesting sample for the open-sourcing of legal technology.

#Claude#Git#legal versioning#AI agents#open source#semantic versioning#reproducible builds
Share:

Related articles