
Code as Law: How AI Will Let Governments Compile Their Statutes
For most of legal history, the gap between a statute and its enforcement was a feature, not a bug. Laws were written in natural language because natural language is the medium humans use to argue, interpret, and forgive. The slack between the rule on the page and the rule in the world was where judges, juries, and prosecutors did their work -- and where the rest of us found room to live.
That gap is starting to close. Not because lawyers are getting more efficient, and not because legislatures are becoming more precise, but because for the first time in history we can begin to compile statutes the way we compile software. Large language models have made it economically feasible to translate legal text into structured logic, and the surrounding stack -- programmable money, verifiable identity, cryptographic settlement, agentic systems -- is maturing in parallel. Over the next fifteen years, the question will not really be whether governments can implement parts of their law as code. It will be where the line falls, how fast it moves, and what we lose where it crosses.
The Argument We Started in 2018
When Primavera De Filippi and I wrote Blockchain and the Law in 2018, we were extending an argument Lawrence Lessig had made twenty years earlier. Lessig's claim, in Code and Other Laws of Cyberspace, was that code is one of four modalities of regulation -- alongside law, social norms, and markets -- and that as more of life moved online, the architecture of our software would do more of the regulatory work that statutes used to do.
Our extension was that blockchain-based systems don't just regulate behavior the way Lessig described. They establish a parallel normative order -- what we called lex cryptographia -- in which rules are not enforced after the fact by courts but executed automatically by infrastructure. A smart contract does not contemplate breach. It executes, or it does not execute. The remedy is collapsed into the rule. The court is collapsed into the runtime.
We argued this was profound, but we were also careful about its limits. Smart contracts, in 2018, were brittle. They could only handle the kinds of rules that fit cleanly into Boolean logic over on-chain state. Anything requiring judgment about the messy world -- was the goods conforming, was the consent meaningful, was the action reasonable -- had to be punted to an oracle, an arbitrator, or a court. Lex cryptographia could govern transfers and escrows and corporate structures. It could not govern the substance of most law, because most law is a continuous negotiation with ambiguity.
That limit is what AI begins to dissolve.
What the Models Change
The thing the legal academy has been slow to internalize about modern foundation models is that they are not better search engines or better drafting tools. They are the first systems we have ever built that can read a paragraph of statutory text, an evolving fact pattern, and a precedent, and produce a structured output that is good enough most of the time to act on. They turn natural language into a programmable interface.
Three capabilities matter for the trajectory.
The first is statute compilation. A model can take a body of law -- a tax title, a zoning code, a benefits program -- and produce, for any given fact pattern, a structured determination: applicable provisions, computed obligations, required disclosures, ranked ambiguities. Intuit and the IRS already do crude versions of this. The trend line points toward this becoming routine across much of the administrative state, with the structured output gradually treated as a first-class artifact alongside the natural-language text rather than a downstream summary of it.
The second is continuous adjudication. Models can evaluate ongoing conduct against a rule in something close to real time, the way a fraud-detection system evaluates transactions. As agent-readable APIs spread across financial, identity, and physical-world systems, the substrate exists for compliance to be checked at the moment of action rather than reconstructed years later in discovery. Not for everything. But for more and more of what regulators currently police through after-the-fact filings.
The third -- and this is the one most people miss -- is negotiated specificity. Earlier code-as-law systems failed at the boundary where rules met facts that hadn't been anticipated. Models handle that boundary the way a junior associate handles it: by reasoning, by analogy, by asking. They do not eliminate the ambiguity in legal text. They make the ambiguity tractable at machine speed, which is a different and more interesting thing.
Put these three together and you have the missing ingredient for the regime De Filippi and I described. Lex cryptographia without AI was a regime for a narrow set of formal transactions. Lex cryptographia with AI is a regime that can plausibly absorb a meaningful fraction of administrative law over the next decade, and rather more than that over the next two.
Where This Probably Goes
It helps to be concrete about where the trend lands first, while staying honest about the fact that adoption will be uneven, contested, and shaped as much by political economy as by technical capacity. The seven domains below are not a forecast of how things must go. They are an attempt to think through how things probably go if the underlying capability advances on its current curve and the institutional response is no more dysfunctional than usual.
Entity formation and licensing. Starting a small business already involves a stack of essentially deterministic decisions -- entity type, tax election, registered agent, basic licensing -- that has been ripe for compilation for a decade and only lacked a usable interface. The interface is now arriving, and what changes is the structure of the formation industry, not just the speed of formation. Within a few years, an agent will be able to negotiate the structure of an entity with the IRS, the relevant Secretary of State, and the licensing bodies as a single composite transaction, with the obligations that flow from it bound to the firm's operational systems on an ongoing basis. The compliance function inside small and mid-sized firms migrates into the runtime of the software the firm is already running.
The harder problem is professional licensing, which is fragmented across fifty states and captured, in many fields, by incumbents whose moat is the friction of the process itself. The pressure to compile licensing will be intense -- a contractor's agent that can pull a permit instantly is competing against a contractor whose agent cannot -- and the resistance will be intense too. The likely result is a patchwork: aggressive compilation in jurisdictions that view licensing as a hassle to minimize, lagging adoption in jurisdictions that view it as protection, and a slow erosion of state-level licensing as a practical barrier as interstate compacts form around the most contested fields. The legal-services and bookkeeping industries that grew up around formation and licensing shrink substantially. What replaces them is a smaller, higher-skilled exception-handling practice, plus a new market in the design and audit of the compiled rules themselves.
Tax administration. Withholding for W-2 income is already continuous; quarterly estimated tax for the self-employed is a primitive version of the same idea. Over the next decade, expect the platforms that mediate gig and contractor income -- Stripe, Lyft, Shopify, the growing class of agent-to-agent payment rails -- to absorb withholding at the moment of payment, computing the recipient's actual marginal rate from a tax-aware payment standard rather than from a flat 1099 framework. The annual return persists, but the proportion of taxpayers for whom it is anything more than a reconciliation artifact shrinks toward zero.
The harder thing to predict is what happens at jurisdictional boundaries. State and local tax is a mess of more than ten thousand jurisdictions with overlapping authority and inconsistent definitions. Compilation pressure will drive harmonization, but slowly, and against active resistance from jurisdictions that benefit from definitional asymmetry. Internationally, the picture is more interesting. Cross-border income flows that today depend on opacity -- the global tax-haven structure that shelters a meaningful share of global wealth -- become much harder to maintain when the financial infrastructure itself enforces residency, source, and beneficial-ownership rules at transaction time. The OECD's two-pillar framework looks like a sketch of what is possible in the absence of compiled enforcement; with it, much more aggressive harmonization becomes feasible, even if the political appetite to do it remains uncertain.
The political economy here is worth being honest about. The U.S. tax preparation industry generates billions in annual revenue from a problem that compiled tax law substantially eliminates, and that industry will fight, has been fighting, and will keep fighting -- through congressional allies more than through litigation. The IRS itself has institutional reasons to maintain some of the complexity, since a portion of its budget is justified by it. The path to compiled tax administration runs through political coalitions, not just technical capacity, and the result will be a longer adoption curve than the technology alone would predict.
Permitting, zoning, and land use. The most visible compression happens here, because the rule sets are finite, the facts are easily structured, and the friction is unambiguously a deadweight loss. A renovation that fits squarely inside the zoning code, a sign permit, a sidewalk closure, a curb cut -- all collapse from months to something close to instant once the code is compiled and parcel-level data is queryable. The interesting design choice is what to do with the cases that don't fit squarely. Variances, special-use permits, historic-district reviews, and any case turning on community character require human judgment, and the question is whether the compiled system flags those cases without quietly turning every flag into a rubber stamp.
Two second-order effects deserve attention. The first is housing. In jurisdictions where permitting friction is the binding constraint on new supply -- and there are many -- compiling the routine code unlocks substantial amounts of building, particularly accessory dwelling units, lot-line construction, and conversions that today die in administrative delay. Where the binding constraint is something else -- the underlying zoning, neighborhood opposition, infrastructure capacity -- compilation accelerates only the easy cases and may make the contested ones harder, because opponents who lose access to procedural delay tactics will demand new procedural protections in whatever deliberative layer is built atop the compiled one. The fight does not disappear; it relocates.
The second is insurance. Once permit state, code compliance, and inspection history flow through the same compiled system, property and casualty insurers can price in real time at the parcel level, with discounts and surcharges that adjust as the structure changes. This is broadly efficient. It is also a substantial transfer of information advantage from homeowners to insurers, and the political response to the first wave of unaffordable-by-zip-code outcomes will shape how compilation is allowed to flow downstream.
Financial regulation. The financial system is further along than most outsiders realize, because the infrastructure was already digital and the rule sets were already partially encoded. KYC, suitability, BSA reporting, and large-trade surveillance run inside the rails today; what changes over the next decade is depth and continuity, not the basic fact of compilation. Suspicious activity reporting -- currently a process where institutions identify suspicious activity, write narrative reports, and submit them to FinCEN for after-the-fact review -- shifts to a real-time pattern-detection layer where flags are raised at the moment of the transaction and routed for human review with the relevant context already assembled.
The more consequential shift is in capital markets themselves. The line between public and private securities has historically been justified on the cost of disclosure: true public offerings can scale, but the disclosure burden made them economic only at meaningful size. When disclosure can be generated at near-zero marginal cost from already-compiled corporate data, the economic basis for the public/private distinction substantially weakens. Regulation A+ and the equity crowdfunding regime are early sketches of what a compiled-disclosure public market looks like; over fifteen years it is plausible that some version of these absorbs a meaningful chunk of what is today the private capital markets, with corresponding pressure on the IPO process as the canonical liquidity event.
Stablecoins and tokenized money market funds are the testbed. Programmable money makes consumer-protection rules executable in ways that paper-based rules never could be: cooling-off periods, suitability checks, position limits, margin requirements all bind at transaction time rather than depending on intermediary compliance. The institutional question is which regulator owns this. The current SEC/CFTC division reflects an earlier era's distinctions; the most likely outcome is either an explicit reorganization or a quieter division of labor along compiled-versus-uncompiled product lines.
The countervailing force is regulatory arbitrage. The first generation of compiled financial regulation will not be globally harmonized, and jurisdictions that adopt permissive compilations will attract activity, just as Delaware attracted incorporations in the twentieth century and the Cayman Islands attracted fund formation. Convergence is plausible but slow. In the meantime, expect the geography of finance to reshuffle around which jurisdictions compile what -- and to keep reshuffling for at least a decade after the underlying technology has stabilized.
Contract law. Routine commercial agreements -- leases, employment terms, vendor contracts, software licenses, terms of service -- drift toward executable form, with the natural-language version retained as a fallback canon of construction. Bar associations and industry groups will publish signed, versioned default libraries; deviations from the defaults will be flagged automatically, both at drafting and at performance. The economic value of routine commercial drafting approaches zero over fifteen years, in roughly the way the value of routine title-search work approached zero over the prior fifty.
What replaces the routine practice is interesting. Bespoke, high-value, relational contracts -- M&A documents, complex financings, joint ventures, anything where the design of the contract is itself a competitive negotiation -- stay where they are, drafted by humans for humans, and probably become more concentrated in fewer firms because the routine work that subsidized partner training has disappeared. The training pipeline for transactional lawyers, which has historically been associate-level routine drafting, breaks. Firms will need to invent something to replace it, or accept that the partner class shrinks accordingly. Law schools that take this seriously will look very different in a decade than they do now.
There is a quieter point underneath this one. Force majeure, materiality, commercial reasonableness, and the other standard contract concepts that depend on external facts become compiled questions, drawing on structured external feeds -- weather, disease classifications, sanctions lists, supply-chain disruption indices. The interpretive choices baked into those compilations are themselves a form of soft law, because they shape what counts as a triggering event without going through any legislative or judicial process. This is the kind of substantive lawmaking that is easiest to miss and hardest to undo once embedded, and the legal academy should be paying it more attention than it currently is.
Administrative benefits and the social safety net. This is the domain often missed in code-as-law discussions, and it is where compiled law can do the most good and the most harm.
Means-tested benefits in the United States are notoriously hard to access. Administrative burden -- the time, effort, and confusion required to apply, recertify, and appeal -- is itself a rationing mechanism, sometimes deliberately designed and often producing take-up rates well below eligibility. Compiled benefits administration changes this in two directions. It makes auto-enrollment plausible for the first time: a system that already knows your income, household composition, and circumstances can deliver benefits to eligible recipients without requiring them to apply. SNAP, Medicaid, EITC, and child tax credits all become substantially easier to deliver to the people they were designed for. It also makes adverse determinations easier to deliver at scale. Termination of benefits, claw-back of overpayments, and fraud determinations can run as continuous processes against the same data, and the historical pattern when administrative tools become more efficient is that adverse uses scale at least as fast as beneficial ones.
This is the domain where the right to a human is most acute and most contested. The political coalition that supports auto-enrollment is not the political coalition that supports rapid termination, and the same compiled infrastructure can produce either outcome depending on who is writing the rules. What the compilation does, unambiguously, is make the choice more visible: when the rule is in code, the policy is in code, and "we just enforce the law" stops working as a political defense. That visibility is, on balance, a good thing -- but it is a thing the system has historically resisted, and the resistance is not going to disappear just because the technology arrives.
Criminal procedure. The substantive determinations -- intent, reasonableness, proportionality, guilt -- stay with humans. They should. But the procedural surround compiles, and compilation reveals how much of the criminal system has been running on undocumented discretion all along.
Discovery is the easiest case. The volume of digital evidence in a modern criminal case is already beyond human review at trial-preparation timelines; compiled discovery runs an attorney-supervised model over the document set, surfaces Brady material, and produces a structured production log that the defense can audit. The defense bar's resistance to this is real but ultimately unsustainable, because the volume problem is real. Where the fight will land is on the visibility of the model's choices: did it surface the right material, and how does the defense audit that?
Sentencing is harder. Guideline calculations have been compiled for years -- the federal sentencing guidelines are essentially a structured rule set, and tools like COMPAS at the state level have been controversial but persistent. The trajectory is toward more compiled scoring, more visible departures, and a tightening of the political cost of departing from a compiled recommendation, even as the formal authority to depart remains with the judge. This is a subtle erosion of judicial discretion that is worth being clear-eyed about, because the rhetoric of compiled sentencing tends to talk about it as if discretion is unaffected.
Bail and pretrial detention is where the most acute battle over the right to a human will be fought, and probably first. Risk assessment tools are already in use; their bias and opacity are well-documented; the choice ahead is whether they become canonical inputs to compiled bail decisions or whether courts mandate human override authority that is more than nominal. Civil forfeiture, parole and probation conditions, and the sprawling administrative-criminal hybrid that operates outside the normal protections of criminal procedure all compile too, and the compilation exposes how often they have functioned outside any rule at all. The compiled version is in some ways more humane than the discretionary version it replaces, because it is at least bound to a written rule. It is also more efficient, and efficient surveillance is its own concern.
Cross-Cutting Effects
Three things cut across all of these domains and deserve naming directly.
The first is jurisdictional competition and convergence. The first jurisdictions to compile any given body of law will have a temporary structural advantage, and capital, firms, and even some kinds of activity will move to take advantage of it. Over time, the pressure to harmonize is real but slow, and the interim period -- call it ten to fifteen years -- will be marked by visible legal arbitrage of a kind we have not seen at this scale since the early days of the Internet. Some of that arbitrage will be benign (Delaware corporate law was once an arbitrage, and is now infrastructure); some of it will be straightforwardly extractive. Telling the difference, in real time, is going to be one of the harder analytic tasks of the next decade.
The second is the compiler-as-quiet-lawmaker. When a statute is translated into executable form, somebody is making interpretive choices that, in a non-compiled regime, would have been made by judges in published opinions over decades. Those choices accumulate as a kind of de facto common law -- except that they are made by engineers and product managers under procurement contracts, and they are typically not published, not contested, and not subject to the slow refinement that the appellate process imposes on natural-language interpretation. We need to invent something that plays the role for compiled rules that the published opinion plays for ordinary common law: visible, attributable, contestable, and revisable. Without it, an enormous amount of substantive lawmaking simply happens in the dark.
The third is the practicing bar. The bar in 2040 will look meaningfully different from the bar today, in something like the way the bar in 1900 looked different from the bar in 1850 after the codification movement. The routine work that fed the training pipeline shrinks; the high-end work that survives becomes more concentrated and more demanding; a new layer of work -- rule design, contestation strategy, audit of compiled artifacts, policy advocacy at the level of the compiler -- emerges and is not yet well-named. Law schools that prepare students for the bar of 2010 are preparing them for a profession that is in the process of disappearing under their feet. This is not a crisis exactly, but it is a transition that the profession is largely sleepwalking through, and it deserves more institutional attention than it is getting.
None of this arrives all at once or evenly. Some pieces will be in production by 2030, some will still be a pilot in 2040, and some that look obvious now will turn out to be politically impossible. But the underlying capability is real, and capability of this kind tends to find its way into use, eventually, even when the institutional surround takes longer than the technology to catch up.
The Hard Problems We Have to Solve First
I want to be careful here, because there is a triumphalist version of this story I do not believe. The arrival of compilable law does not mean the arrival of better law. It means the arrival of more enforceable law, which is a different thing and sometimes the opposite thing.
There are at least four problems that have to be solved alongside the capability, and none of them are technical.
Contestability. A regime in which compliance is checked at the moment of action is a regime in which the moment of contest has to move forward too. You cannot wait until the appeal to discover that the rule was wrongly compiled. This means we need a new procedural layer -- call it contestation infrastructure -- that runs alongside the executable layer and lets affected parties challenge a determination at machine speed. The court system as currently configured is not capable of this. Building the procedural layer is, I think, the most important and least-discussed legal-engineering problem of the next decade.
Due process for compilation. When a statute is compiled into executable rules, somebody is making interpretive choices that used to be made by judges over decades of common-law development. Those choices have to be visible, attributable, and revisable. The risk is that compilation gets treated as a technical task and gets done by vendors operating under procurement rules, with the substantive choices buried in pull requests nobody reads. The legal-realist insight that interpretation is politics applies even harder when the interpretation is compiled and enforced at scale.
Capture and lock-in. A regime of compiled law has dramatically increased switching costs. The firm that compiles the tax code for the IRS does not need to be corrupt to be a problem. The risk is that the architecture of the compiled artifact becomes the architecture of the law itself, and changing the law starts to require changing the compiler, which becomes a procurement problem rather than a democratic one. Open standards, public reference implementations, and aggressive interoperability requirements need to be built in from the start, not retrofitted later.
The right to a human. There has to be some core set of determinations -- adverse government action against a person's liberty, custody, immigration status, benefits -- where the citizen retains an absolute right to a human decisionmaker, regardless of how good the model gets. This is not a technical claim about model accuracy. It is a constitutional claim about what kind of relationship we want with the state. The European AI Act gestures at this; the U.S. has not yet had the conversation seriously, and we are running out of time to have it before facts on the ground settle the question for us.
What Stays Human
The thing that gets lost in most code-as-law writing is that the part of law that is hardest to compile is also the part that does the most important work. It is not the rule. It is the act of judgment that decides whether the rule applies, and whether, in this case, with this person, the right thing is to apply it.
A model can compile the federal sentencing guidelines. It cannot tell you whether mercy is warranted. A model can determine that a tenant is in technical default. It cannot tell you whether eviction at this moment, of this family, would be a serious wrong. These are not edge cases. They are the cases where law does the work that markets and norms cannot do.
The version of this trajectory I find defensible is one in which compilable law absorbs the routine and frees scarce human attention for the cases that genuinely require it. The version I find frightening is one in which the legibility of compiled law makes the inscrutable, the merciful, and the discretionary look suspect by comparison, and we slowly hollow out the places in the system where being human still matters.
Which version we get is not a question that AI will answer. It is a question that lawyers, judges, and legislators will answer, mostly through small choices about what to compile and what to leave alone.
Where This Leaves Us
When De Filippi and I were writing in 2017 and 2018, the audience we worried about was the technologists, who tended to think the law was an engineering problem they were about to solve. Our message to them was that lex cryptographia would not replace law; it would create a new normative regime alongside it, with its own pathologies and its own need for institutional repair.
The audience I worry about now is the lawyers. The technologists were never going to solve the legal problems on their own -- that part of the 2018 argument has held up. But the lawyers are sleepwalking through a transition that, over fifteen years or so, is likely to reshape the profession more thoroughly than any since the codification movement of the nineteenth century. Compiled law is coming, in pieces, at uneven speed. The choice is whether the people who understand the law shape the compilation, or whether the compilation gets done by people who understand only the code.
The thing I am most certain of, looking out a decade and a half, is that the profession will look meaningfully different. The thing I am most uncertain of is whether the substance of law -- the slow accumulation of judgment, the protection of the weak from the legible, the room for mercy -- survives the upgrade in enforcement.
We have time. Probably less than we think