writ

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: Apache-2.0

README

Writ

Plan, approve, and apply OpenTofu on your own server.

Writ is an open-source control plane for OpenTofu. You point it at a Git repository of stacks. It plans the commits you or your CI job send it, waits for your team to approve the plan, and applies that exact plan. Your CI jobs and laptops never hold a cloud credential or a state key.

It's one Go binary under the Apache 2.0 license, with no limit on users, runs, or resources. A team's control plane keeps its records in Postgres. On your own machine it uses SQLite.

Writ is at version 0. Read Status before you put real infrastructure behind it.

What you get

  • Plans on your server. You or your CI job ask for a commit's plan. writ serve reads that commit from your Git host and runs tofu plan on your server. A plan writes nothing to your state.
  • Approvals for one exact plan. You approve a plan by its id, and the apply runs the plan Writ kept, not a new one. Where an approval rule applies, the author's approval doesn't count. Approvals
  • No cloud keys in CI. A plan runs with the plan role you configure, so make that role read-only. Only an apply gets the apply role: one that its approval rules allowed, or one that someone with override overrode with a recorded reason. Roles and credentials
  • Secrets hidden. One mask covers every plan, run output, and error that Writ stores or shows. Secrets and the mask
  • Policy in Rego. Writ checks each plan when it's created and again before its apply. A mandatory deny has no override. Policy
  • Drift checks. Writ plans each stack on a schedule and shows what changed outside OpenTofu. Drift checks
  • A control UI, a CLI, and an API. Review and approve plans in the browser, or script everything with --json.
  • Imports and agents. writ import bulk writes resource and import blocks for objects you already run. writ mcp lets a coding agent plan and read a plan, and never approve or apply. Import many objects, Use Writ with an agent

Quick start

writ serve --dev runs a control plane on your machine, on loopback, with its records in SQLite. It's the same code as a team's writ serve, without sign-in or approval rules. You don't need a cloud account.

You need Linux, minisign, Git, and OpenTofu 1.13.9 on PATH.

  1. Install writ v0.1.0. The script checks the release's signature and checksum, then puts writ in ~/.local/bin:

    curl -fsSL https://github.com/mr-karan/writ/releases/download/v0.1.0/install.sh | sh
    export PATH="$HOME/.local/bin:$PATH"
    
  2. Start the dev control plane, and leave it running:

    writ serve --dev
    
  3. Open a second terminal, where the first line puts writ on its PATH too. Then create a repository with one stack and add it. A stack is a directory of .tf files with a committed .terraform.lock.hcl:

    export PATH="$HOME/.local/bin:$PATH"
    mkdir -p ~/writ-demo/app
    cd ~/writ-demo
    git init -b main
    cat > app/main.tf <<'EOF'
    terraform {
      backend "http" {}
    
      required_providers {
        random = { source = "hashicorp/random", version = "3.9.1" }
      }
    }
    
    resource "random_pet" "name" {
      length = 2
    }
    EOF
    (cd app && tofu providers lock)
    git add .
    git commit -m "one stack"
    writ repo add .
    
  4. Plan the commit, then apply the plan by its id:

    $ cd app
    $ writ plan --remote
    OpenTofu 1.13.9 plan of app@dev
    
      + random_pet.name (create)
    
    Plan: 1 to add, 0 to change, 0 to destroy.
    Plan 3f613cf08763b0bf56626574288f85af for dev (app), by alice (dev), expires 2026-11-16T04:40:49Z.
    It needs no approval. Apply it with: writ apply --remote 3f613cf08763b0bf56626574288f85af
    $ writ apply --remote 3f613cf08763b0bf56626574288f85af
    OpenTofu apply of app@dev
      random_pet.name: create complete
    Apply: 1 added, 0 changed, 0 destroyed.
    State version 1 of app@dev.
    

    Output of a real run, 2026-11-15, with some lines cut.

The banner that writ serve --dev prints has a link to the control UI, where you can read the plan and the run.

Next, set up Writ for a team: Postgres, sign-in with OIDC, approval rules, and a second person's approval.

Install

  • The install script, as in the quick start. It checks the release's minisign signature.
  • From source, with Go 1.27.3 or later and just: just build puts writ in bin/.
  • Nix. nix run github:mr-karan/writ -- version. The flake also has a NixOS module that runs a team's writ serve with Postgres.
  • Release binaries and the container image. v0.1.0 has static binaries for Linux and macOS on amd64 and arm64, and ghcr.io/mr-karan/writ:0.1.0, a writ serve image with OpenTofu 1.13.9. The macOS binaries haven't run on a Mac yet.

Install has the commands for each.

Status

Writ is new. Here's what you should know before you rely on it:

  • Version 0. Until 1.0, a minor version can change behavior. Don't move production infrastructure to it yet.
  • OpenTofu only. Writ runs OpenTofu 1.13.9 and no other version, and it doesn't run Terraform. Each stack has one state, with no tofu workspace.
  • GitLab only. GitLab is the only Git host Writ reads, and its CI jobs are for GitLab CI. Nobody has run those jobs on a real GitLab instance yet, and there's no GitHub flow.
  • AWS roles only. The plan and apply roles are AWS roles. For another cloud, your provider gets its credentials from the server's config.
  • Not proven in a real cloud account. The tests run real OpenTofu and real providers against local stand-ins. None reaches a real cloud.
  • One node, on Linux. A second writ serve on the same database fails the other's work.
  • No notifications. You see plans, drift, and runs in the control UI and the API. Nothing sends you a message about them.

Status and limits has the full list, and how each part is tested.

Documentation

The docs are at writ.mrkaran.dev/docs, and in docs/.

Contributing

Bug reports, design questions, and pull requests are welcome. CONTRIBUTING.md says how to build Writ, run its tests, and send a change. Report a security problem privately, as SECURITY.md says.

License

Apache 2.0. The files proto/tfplugin5.proto and proto/tfplugin6.proto are copied from OpenTofu under MPL 2.0, and NOTICE has the notices for the code Writ includes.

Directories

Path Synopsis
bench
skilleval command
Command skilleval measures what the writ skill does for a coding agent on an OpenTofu repository.
Command skilleval measures what the writ skill does for a coding agent on an OpenTofu repository.
cmd
writ command
Command writ is the Writ CLI.
Command writ is the Writ CLI.
internal
addr
Package addr defines resource addresses: the path from a top-level let to a resource, such as ca_key, site.key, or files["a"].
Package addr defines resource addresses: the path from a top-level let to a resource, such as ca_key, site.key, or files["a"].
agent
Package agent holds what Writ puts into an OpenTofu repository for coding agents: the writ skill, and the section of AGENTS.md that points to it.
Package agent holds what Writ puts into an OpenTofu repository for coding agents: the writ skill, and the section of AGENTS.md that points to it.
archtest
Package archtest holds tests that enforce Writ's package boundaries.
Package archtest holds tests that enforce Writ's package boundaries.
authz
Package authz decides what a principal may do in writ serve.
Package authz decides what a principal may do in writ serve.
awsrole
Package awsrole assumes AWS roles for writ serve's runs and hands the credentials to providers.
Package awsrole assumes AWS roles for writ serve's runs and hands the credentials to providers.
awsrole/ststest
Package ststest is a stand-in for AWS STS in tests.
Package ststest is a stand-in for AWS STS in tests.
cli
Package cli implements the writ commands.
Package cli implements the writ commands.
confine
Package confine reads and writes the files of a stack or a repository, either anywhere on the file system or only beneath one directory.
Package confine reads and writes the files of a stack or a repository, either anywhere on the file system or only beneath one directory.
control
Package control is writ serve's own store: the configs it ran with, their teams and grants, the kept plans, approvals, runs, overrides, sessions, used token ids, an audit row for every API call and decision, and the state OpenTofu stacks keep on writ serve's http backend.
Package control is writ serve's own store: the configs it ran with, their teams and grants, the kept plans, approvals, runs, overrides, sessions, used token ids, an audit row for every API call and decision, and the state OpenTofu stacks keep on writ serve's http backend.
control/controltest
Package controltest opens control databases for tests: a SQLite file in the test's temporary directory always, and a scratch Postgres database when pgtest has a server.
Package controltest opens control databases for tests: a SQLite file in the test's temporary directory always, and a scratch Postgres database when pgtest has a server.
control/pgtest
Package pgtest gives tests a scratch Postgres: a socket-only server in a temporary directory, as just e2e-postgres starts one.
Package pgtest gives tests a scratch Postgres: a socket-only server in a temporary directory, as just e2e-postgres starts one.
diag
Package diag defines source positions and the diagnostics every layer of Writ reports: a class, a span, a message, and an optional fix.
Package diag defines source positions and the diagnostics every layer of Writ reports: a class, a span, a message, and an optional fix.
forge
Package forge reads repositories where they are hosted: a project, the head of a branch, the files of a commit, and a file's content by its Git blob id.
Package forge reads repositories where they are hosted: a project, the head of a branch, the files of a commit, and a file's content by its Git blob id.
forge/forgetest
Package forgetest serves a stand-in for GitLab's REST API in a test's process: the project, branch, commit, merge base, repository tree, and raw blob endpoints that writ serve reads, with the response shapes of GitLab's API documentation (docs.gitlab.com/api/projects, /api/branches, /api/commits, and /api/repositories, read 2026-11-10).
Package forgetest serves a stand-in for GitLab's REST API in a test's process: the project, branch, commit, merge base, repository tree, and raw blob endpoints that writ serve reads, with the response shapes of GitLab's API documentation (docs.gitlab.com/api/projects, /api/branches, /api/commits, and /api/repositories, read 2026-11-10).
importer
Package importer takes over objects that already exist into OpenTofu code.
Package importer takes over objects that already exist into OpenTofu code.
mask
Package mask produces every document that leaves an OpenTofu run: the masked plan document, the rows of the state index, and the run's event streams with secrets swept out.
Package mask produces every document that leaves an OpenTofu run: the masked plan document, the rows of the state index, and the run's event streams with secrets swept out.
mcp
Package mcp serves Writ's control plane to coding agents as tools of the Model Context Protocol, over stdio.
Package mcp serves Writ's control plane to coding agents as tools of the Model Context Protocol, over stdio.
oidc
Package oidc checks OIDC tokens for writ serve and signs people in with the team's identity provider.
Package oidc checks OIDC tokens for writ serve and signs people in with the team's identity provider.
oidc/oidctest
Package oidctest runs an OIDC issuer for tests: an HTTPS server with a discovery document and a key set, keys generated in the test, and tokens the test signs.
Package oidctest runs an OIDC issuer for tests: an HTTPS server with a discovery document and a key set, keys generated in the test, and tokens the test signs.
policy
Package policy compiles policy sets, Rego rules about OpenTofu plans, and judges one plan at one point with them.
Package policy compiles policy sets, Rego rules about OpenTofu plans, and judges one plan at one point with them.
provider
Package provider owns everything about Terraform provider binaries: finding them in the registry, pinning them in writ.lock, caching their schemas, and running them over the plugin protocol, version 5 or 6.
Package provider owns everything about Terraform provider binaries: finding them in the registry, pinning them in writ.lock, caching their schemas, and running them over the plugin protocol, version 5 or 6.
repo
Package repo turns one commit of a repository into what the control plane plans.
Package repo turns one commit of a repository into what the control plane plans.
runas
Package runas acts as an OS user with no name: it starts a process as that user, does file work as that user, and checks that a started process holds nothing of writ's.
Package runas acts as an OS user with no name: it starts a process as that user, does file work as that user, and checks that a started process holds nothing of writ's.
schema
Package schema is Writ's own view of a provider's schema: resource types with Writ types on every attribute, refined by the annotation layer.
Package schema is Writ's own view of a provider's schema: resource types with Writ types on every attribute, refined by the annotation layer.
server
Package server is writ serve: the control plane's REST API over HTTPS.
Package server is writ serve: the control plane's REST API over HTTPS.
servetest
Package servetest starts a dev control plane inside a test's process: the real server.Server, which runs no OpenTofu, on an httptest server, with its control database in SQLite in the test's temporary directory.
Package servetest starts a dev control plane inside a test's process: the real server.Server, which runs no OpenTofu, on an httptest server, with its control database in SQLite in the test's temporary directory.
sqldb
Package sqldb owns Writ's SQL drivers: it opens SQLite files and Postgres databases behind one type, rewrites the ? placeholders that every statement is written with into Postgres's $n, and turns driver errors into an *IOError that holds no connection detail.
Package sqldb owns Writ's SQL drivers: it opens SQLite files and Postgres databases behind one type, rewrites the ? placeholders that every statement is written with into Postgres's $n, and turns driver errors into an *IOError that holds no connection detail.
tfcode
Package tfcode reads and writes the OpenTofu code of one stack for writ import: it reads the providers a stack requires and configures, and the names it declares, and it writes literals as HCL tokens.
Package tfcode reads and writes the OpenTofu code of one stack for writ import: it reads the providers a stack requires and configures, and the names it declares, and it writes literals as HCL tokens.
tfplugin6
Package tfplugin6 will hold the Go code generated from proto/tfplugin6.proto by `just proto` (protoc-gen-go and protoc-gen-go-grpc).
Package tfplugin6 will hold the Go code generated from proto/tfplugin6.proto by `just proto` (protoc-gen-go and protoc-gen-go-grpc).
tfstate
Package tfstate serves OpenTofu's http state backend to the runs of writ serve.
Package tfstate serves OpenTofu's http state backend to the runs of writ serve.
tofu
Package tofu runs OpenTofu for one stack: init, a saved plan, its JSON, and the apply of a saved plan, each run in a scratch directory of its own, with bounded time and output, and as the run's own uid when it has one.
Package tofu runs OpenTofu for one stack: init, a saved plan, its JSON, and the apply of a saved plan, each run in a scratch directory of its own, with bounded time and output, and as the run's own uid when it has one.
types
Package types is the type model of provider schemas: scalars, lists, maps, records, string-literal unions, typed references (Id, Pem, Arn, and Name), resource types, and the secret taint.
Package types is the type model of provider schemas: scalars, lists, maps, records, string-literal unions, typed references (Id, Pem, Arn, and Name), resource types, and the secret taint.
ui
Package ui is the control UI: the HTML pages that writ serve renders under /ui/ for people signed in with the team's identity provider.
Package ui is the control UI: the HTML pages that writ serve renders under /ui/ for people signed in with the team's identity provider.
value
Package value is the value model of the importer and the provider client.
Package value is the value model of the importer and the provider client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL