charter

module
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT

README

charter

latest release

The problem. An API on Cloudflare Workers needs much more than its handlers: input checked, a spec, SDKs, tools for AI agents, sign-in, rate limits, streams that survive a deploy, tests on the real runtime, CI and docs. Each is usually set up by hand, differently in every repo, and drifts as the API changes. In Go there is more: a Worker is WebAssembly built with TinyGo, whose gaps go test can't see.

What charter does. You write one thing, the contract, in TypeScript (oRPC) or Go (Huma), and the rest follows from it and is checked against it: the OpenAPI and AsyncAPI specs, SDKs in any language Fern supports and a CLI, an MCP tool for every operation that answers once, and the same sign-in and refusals in every API, tested on every run. A Go API is built with TinyGo and tested under workerd, at TypeScript's cost for a warm request (Benchmarks). It is one command, charter, which mise installs: it makes a new API, keeps a repo you have the charter way, and runs each check here as GitHub runs it. Why, and how: docs/, rendered at https://joeblew999.github.io/charter/.

mise use -g github:joeblew999/charter   # charter, the one command
charter new my-api                      # a new API (-go: in Go)
charter init                            # the repo you have, kept the charter way

Directories

Path Synopsis
Package asyncapi generates an AsyncAPI 3.0.0 document from a Huma API, the way Huma itself generates OpenAPI: the Go port of ts/src/asyncapi.ts.
Package asyncapi generates an AsyncAPI 3.0.0 document from a Huma API, the way Huma itself generates OpenAPI: the Go port of ts/src/asyncapi.ts.
Package auth is who may call a Huma API, and with what scopes: the contract declares what each operation needs, and one middleware enforces it, so the specs, the SDKs and the server agree.
Package auth is who may call a Huma API, and with what scopes: the contract declares what each operation needs, and one middleware enforces it, so the specs, the SDKs and the server agree.
authtest
Package authtest is an issuer for tests: it serves its keys over HTTP as Cloudflare Access does (/cdn-cgi/access/certs) and as an OpenID Connect issuer does (/.well-known/openid-configuration, /jwks), and signs tokens with them (go-jose, RS256).
Package authtest is an issuer for tests: it serves its keys over HTTP as Cloudflare Access does (/cdn-cgi/access/certs) and as an OpenID Connect issuer does (/.well-known/openid-configuration, /jwks), and signs tokens with them (go-jose, RS256).
Package bindings is a Go Worker's Cloudflare bindings for app code, called from plain net/http handlers, each with what stands in for it off Workers (go test, an ordinary Go server) built in, so app code needs no file per platform.
Package bindings is a Go Worker's Cloudflare bindings for app code, called from plain net/http handlers, each with what stands in for it off Workers (go test, an ordinary Go server) built in, so app code needs no file per platform.
cmd
charter command
Command charter is a Worker's every step on Cloudflare, and how the repo that holds it is kept, one command for all of them (#100, #121).
Command charter is a Worker's every step on Cloudflare, and how the repo that holds it is kept, one command for all of them (#100, #121).
Package d1 runs statements on a Cloudflare D1 database from a Go Worker.
Package d1 runs statements on a Cloudflare D1 database from a Go Worker.
example module
sdk/go module
examples
notes module
notes-go module
notes/sdk/go module
Package follow is the one way a client receives a live, ordered, gap-free feed (docs/self/streaming.md, rule 3): the Go port of ts/src/follow.ts, with the same tests.
Package follow is the one way a client receives a live, ordered, gap-free feed (docs/self/streaming.md, rule 3): the Go port of ts/src/follow.ts, with the same tests.
Package fragments serves a live feed to browsers as server-sent events, each item rendered by the caller: an HTML fragment for htmx 4's SSE extension, a datastar-patch-elements event for Datastar (docs/self/pages.md).
Package fragments serves a live feed to browsers as server-sent events, each item rendered by the caller: an HTML fragment for htmx 4's SSE extension, a datastar-patch-elements event for Datastar (docs/self/pages.md).
go module
lib module
Package hub is the live signal of a feed: publish an item, and every subscriber gets it.
Package hub is the live signal of a feed: publish an item, and every subscriber gets it.
Package humaworkers runs a Huma API (github.com/danielgtaylor/huma) on Cloudflare Workers through workers-go and TinyGo.
Package humaworkers runs a Huma API (github.com/danielgtaylor/huma) on Cloudflare Workers through workers-go and TinyGo.
internal
bundle
Package bundle builds a TypeScript (or JavaScript) Worker into build/worker.mjs with esbuild, in this process: one ES module, as Cloudflare runs it, from its entry and all it imports (its packages, its JSON), with Cloudflare's own modules (cloudflare:*) and Node's (node:fs, or fs) left to the runtime.
Package bundle builds a TypeScript (or JavaScript) Worker into build/worker.mjs with esbuild, in this process: one ES module, as Cloudflare runs it, from its entry and all it imports (its packages, its JSON), with Cloudflare's own modules (cloudflare:*) and Node's (node:fs, or fs) left to the runtime.
cfapi
Package cfapi is the small Cloudflare REST client shared by cfdeploy and cftail: bearer auth and the {success, errors, result} envelope.
Package cfapi is the small Cloudflare REST client shared by cfdeploy and cftail: bearer auth and the {success, errors, result} envelope.
cfdeploy
Package cfdeploy deploys a Go Worker (TinyGo build from workers-go) to Cloudflare with the REST API: no wrangler, no Node.
Package cfdeploy deploys a Go Worker (TinyGo build from workers-go) to Cloudflare with the REST API: no wrangler, no Node.
cflogs
Package cflogs reads a deployed Worker's stored logs (Workers Logs), which every charter deploy turns on: what it logged before now, where a tail (package cftail) only shows what happens while it is watched.
Package cflogs reads a deployed Worker's stored logs (Workers Logs), which every charter deploy turns on: what it logged before now, where a tail (package cftail) only shows what happens while it is watched.
cftail
Package cftail streams a deployed Worker's live logs (requests, console output, exceptions) without wrangler: it starts a tail with the REST API, reads its WebSocket, and deletes the tail when done.
Package cftail streams a deployed Worker's live logs (requests, console output, exceptions) without wrangler: it starts a tail with the REST API, reads its WebSocket, and deletes the tail when done.
cli/bench
Package bench is charter bench: it measures the CPU a local Worker spends per request: the operating system's count of workerd's CPU time before and after n requests of one kind, divided by n.
Package bench is charter bench: it measures the CPU a local Worker spends per request: the operating system's count of workerd's CPU time before and after n requests of one kind, divided by n.
cli/build
Package build is charter build: it builds a Go Worker into build/ with TinyGo, tuned for Cloudflare Workers, and fills build/ with what runs it: workers-go's JavaScript and this library's Worker glue (worker/*.mjs, go.mjs first).
Package build is charter build: it builds a Go Worker into build/ with TinyGo, tuned for Cloudflare Workers, and fills build/ with what runs it: workers-go's JavaScript and this library's Worker glue (worker/*.mjs, go.mjs first).
cli/builds
Package builds is charter builds build|deploy|configure: what Workers Builds (Cloudflare's GitHub app) runs for each pushed branch, from the charter binary CI published for that commit (charter ci publish), so nothing is compiled at Cloudflare.
Package builds is charter builds build|deploy|configure: what Workers Builds (Cloudflare's GitHub app) runs for each pushed branch, from the charter binary CI published for that commit (charter ci publish), so nothing is compiled at Cloudflare.
cli/ci
Package ci is charter ci run|update|publish|release: an app's CI, and the GitHub side of its previews and releases, so a commit is compiled once, on CI, and Cloudflare deploys that build (charter builds).
Package ci is charter ci run|update|publish|release: an app's CI, and the GitHub side of its previews and releases, so a commit is compiled once, on CI, and Cloudflare deploys that build (charter builds).
cli/deploy
Package deploy is charter deploy: it deploys a Go Worker to Cloudflare with the REST API, no wrangler and no Node: the build charter build wrote, its static assets, bindings (plain text, D1, Durable Objects, rate limiting), D1 and Durable Object migrations and custom domains (internal/cfdeploy documents the steps).
Package deploy is charter deploy: it deploys a Go Worker to Cloudflare with the REST API, no wrangler and no Node: the build charter build wrote, its static assets, bindings (plain text, D1, Durable Objects, rate limiting), D1 and Durable Object migrations and custom domains (internal/cfdeploy documents the steps).
cli/deps
Package deps is charter outdated and charter update: a repo's pins against what upstream has, and moving them all in one step, except what deps.toml holds and why.
Package deps is charter outdated and charter update: a repo's pins against what upstream has, and moving them all in one step, except what deps.toml holds and why.
cli/local
Package local is charter local, serve and with: the Worker on plain workerd from charter.toml, no wrangler and no Node (internal/local writes what workerd runs into .charter/).
Package local is charter local, serve and with: the Worker on plain workerd from charter.toml, no wrangler and no Node (internal/local writes what workerd runs into .charter/).
cli/logs
Package logs is charter logs: a deployed Worker's stored logs (Workers Logs, which every charter deploy turns on), for what happened before now: after a failed live test or deploy, "what did it log in the last ten minutes, errors only".
Package logs is charter logs: a deployed Worker's stored logs (Workers Logs, which every charter deploy turns on), for what happened before now: after a failed live test or deploy, "what did it log in the last ten minutes, errors only".
cli/projectsteps
Package projectsteps is a charter project's own steps, beside the Worker's (build, serve, deploy): what a project with a contract, specs and SDKs runs, in Go or in TypeScript.
Package projectsteps is a charter project's own steps, beside the Worker's (build, serve, deploy): what a project with a contract, specs and SDKs runs, in Go or in TypeScript.
cli/repo
Package repo is how charter keeps a repo: its files (charter init writes them, charter check says when one is stale), the repo on GitHub (charter repo), its jobs here and there (charter ci <job>), its issues and the upstream issues its code works around, its docs, a new project (charter new), and charter's own release (charter release).
Package repo is how charter keeps a repo: its files (charter init writes them, charter check says when one is stale), the repo on GitHub (charter repo), its jobs here and there (charter ci <job>), its issues and the upstream issues its code works around, its docs, a new project (charter new), and charter's own release (charter release).
cli/scaffold
Package scaffold is charter init, tasks, skill, workflow and check's first part: an app set up to run on Cloudflare Workers with charter, the way intl and seo set an app up: a config file, its mise tasks, an agent skill, and a check that says when any of them is stale; and at the repo's top, charter's files in the repo (go doc .../internal/cli/repo).
Package scaffold is charter init, tasks, skill, workflow and check's first part: an app set up to run on Cloudflare Workers with charter, the way intl and seo set an app up: a config file, its mise tasks, an agent skill, and a check that says when any of them is stale; and at the repo's top, charter's files in the repo (go doc .../internal/cli/repo).
cli/self
Package self runs this binary's own steps as commands of their own (charter deploy …), for steps made of others: their flags, output and exit codes stay exactly theirs.
Package self runs this binary's own steps as commands of their own (charter deploy …), for steps made of others: their flags, output and exit codes stay exactly theirs.
cli/tail
Package tail is charter tail: it streams a deployed Worker's live logs (requests, console output, exceptions) without wrangler: flags for internal/cftail, its filters among them (-status error, -method POST, -search text, …), which Cloudflare applies, so a busy Worker's tail keeps what is asked for instead of a sample.
Package tail is charter tail: it streams a deployed Worker's live logs (requests, console output, exceptions) without wrangler: flags for internal/cftail, its filters among them (-status error, -method POST, -search text, …), which Cloudflare applies, so a busy Worker's tail keeps what is asked for instead of a sample.
cli/token
Package token is charter token: whether CLOUDFLARE_API_TOKEN is an active token, before a deploy uses it.
Package token is charter token: whether CLOUDFLARE_API_TOKEN is an active token, before a deploy uses it.
dbcode
Package dbcode is a project's database code, typed, from its schema (migrations/*.sql, the one place the tables are said).
Package dbcode is a project's database code, typed, from its schema (migrations/*.sql, the one place the tables are said).
deps
Package deps is what charter outdated and charter update need to move a repo's pins: the holds it keeps (deps.toml: what stays where it is, and why), the repository's Go modules, the latest version of a Go module, and the pins in mise.toml.
Package deps is what charter outdated and charter update need to move a repo's pins: the holds it keeps (deps.toml: what stays where it is, and why), the repository's Go modules, the latest version of a Go module, and the pins in mise.toml.
fern
Package fern is the SDKs, made with Fern from a project's fern/ (its specs and generators.yml): Fern's settings written from the spec and charter.toml's [sdks]; a group generated (Docker) into sdk/out/<group> when fern/ is newer than what made it; proven in its language (Go: build, vet, and Fern's tests against WireMock; TypeScript: typechecked with the TypeScript its SDKs are written for; Python: mypy and its own tests; the CLI, in Rust: built); and the Go SDK a project commits, in sdk/go.
Package fern is the SDKs, made with Fern from a project's fern/ (its specs and generators.yml): Fern's settings written from the spec and charter.toml's [sdks]; a group generated (Docker) into sdk/out/<group> when fern/ is newer than what made it; proven in its language (Go: build, vet, and Fern's tests against WireMock; TypeScript: typechecked with the TypeScript its SDKs are written for; Python: mypy and its own tests; the CLI, in Rust: built); and the Go SDK a project commits, in sdk/go.
local
Package local writes what runs a Worker (Go or TypeScript) on plain workerd, no wrangler and no Node, from charter.toml: into .charter/ at the app's root, rebuilt by every command that needs it and never committed (.charter/.gitignore).
Package local writes what runs a Worker (Go or TypeScript) on plain workerd, no wrangler and no Node, from charter.toml: into .charter/ at the app's root, rebuilt by every command that needs it and never committed (.charter/.gitignore).
pins
Package pins is the TinyGo and wasm-opt a Go Worker app builds with: mise.toml, which charter tasks writes into an app (ConfFile) and charter build checks the TinyGo on PATH against; and the tools a repo charter keeps starts its mise.toml with (repo.toml, charter init).
Package pins is the TinyGo and wasm-opt a Go Worker app builds with: mise.toml, which charter tasks writes into an app (ConfFile) and charter build checks the TinyGo on PATH against; and the tools a repo charter keeps starts its mise.toml with (repo.toml, charter init).
previewbuild
Package previewbuild hands a commit's build from CI to the Worker Preview deploy, so it is compiled once:
Package previewbuild hands a commit's build from CI to the Worker Preview deploy, so it is compiled once:
promise
Package promise waits for JavaScript promises: the one place the Go Worker's own packages do it (hub and d1).
Package promise waits for JavaScript promises: the one place the Go Worker's own packages do it (hub and d1).
reply
Package reply writes a JSON answer, for what the library answers outside Huma: MCP's endpoint and the documents at /.well-known/.
Package reply writes a JSON answer, for what the library answers outside Huma: MCP's endpoint and the documents at /.well-known/.
run
Package run runs what a project's steps run: a program from the folder's packages or the PATH, its output shown or kept, a server started, waited for and stopped around what uses it, and how long each took; and charter's cache, where a step keeps what it may reuse.
Package run runs what a project's steps run: a program from the folder's packages or the PATH, its output shown or kept, a server started, waited for and stopped around what uses it, and how long each took; and charter's cache, where a step keeps what it may reuse.
standard
Package standard is the standard test: what every API charter serves must do (docs/self/standard.md), checked on a running API from outside, as a client sees it.
Package standard is the standard test: what every API charter serves must do (docs/self/standard.md), checked on a running API from outside, as a client sees it.
twins
Package twins is charter twins <reference> <other>: the same API in two projects (a TypeScript one and its Go twin) must answer the same.
Package twins is charter twins <reference> <other>: the same API in two projects (a TypeScript one and its Go twin) must answer the same.
version
Package version is the version of charter a binary is: the release's, written in by its build (goreleaser), else the one Go records (go install …@v1.2.3, go tool charter in an app), else a build from a checkout's.
Package version is the version of charter a binary is: the release's, written in by its build (goreleaser), else the one Go records (go install …@v1.2.3, go tool charter in an app), else a build from a checkout's.
Package mcp serves a Huma API as an MCP server (Model Context Protocol), the way Huma itself serves it as OpenAPI: every operation is a tool, its input struct is the tool's inputSchema, and a tool call runs the operation's own HTTP handler, so MCP gets the same validation, the same errors and the same code as REST.
Package mcp serves a Huma API as an MCP server (Model Context Protocol), the way Huma itself serves it as OpenAPI: every operation is a tool, its input struct is the tool's inputSchema, and a tool call runs the operation's own HTTP handler, so MCP gets the same validation, the same errors and the same code as REST.
Package problem writes a refusal as RFC 9457 problem details, as Huma writes an operation's (huma.ErrorModel), for what answers outside an operation: an unknown path (404), a method the path lacks (405), /.well-known/.
Package problem writes a refusal as RFC 9457 problem details, as Huma writes an operation's (huma.ErrorModel), for what answers outside an operation: an unknown path (404), a method the path lacks (405), /.well-known/.
Package project reads charter.toml, everything about a Go Worker on Cloudflare in one file at the app's root: its name, compatibility date and modules, its Static Assets, its bindings (D1, Durable Objects, rate limits) and what each environment (production, staging, previews, local workerd) gets.
Package project reads charter.toml, everything about a Go Worker on Cloudflare in one file at the app's root: its name, compatibility date and modules, its Static Assets, its bindings (D1, Durable Objects, rate limits) and what each environment (production, staging, previews, local workerd) gets.
Package ratelimit is how often a caller may call a Huma API's operations, beside auth: the contract declares each limit, and one middleware enforces it, so the specs, the SDKs and the server agree.
Package ratelimit is how often a caller may call a Huma API's operations, beside auth: the contract declares each limit, and one middleware enforces it, so the specs, the SDKs and the server agree.
Package serve serves a charter API the standard way (docs/self/standard.md), so a project gives its contract, its handlers and whom it trusts, and wires nothing itself:
Package serve serves a charter API the standard way (docs/self/standard.md), so a project gives its contract, its handlers and whom it trusts, and wires nothing itself:
Package skills holds the agent skills that ship with charter's Go side; charter skill installs them into an app's .claude/skills.
Package skills holds the agent skills that ship with charter's Go side; charter skill installs them into an app's .claude/skills.
Package specs is the body of a spec command: it writes the specs a contract generates to files, for Fern, or checks that the committed files are what the contract gives.
Package specs is the body of a spec command: it writes the specs a contract generates to files, for Fern, or checks that the committed files are what the contract gives.
Package transport is what a platform puts around the API's handler so that Go can serve WebSockets: workers-go can't answer an upgrade, and net/http needs a WebSocket library.
Package transport is what a platform puts around the API's handler so that Go can serve WebSockets: workers-go can't answer an upgrade, and net/http needs a WebSocket library.
web
Package web is net/http helpers for a Go Worker's pages that work the same under TinyGo on Cloudflare Workers and standard Go:
Package web is net/http helpers for a Go Worker's pages that work the same under TinyGo on Cloudflare Workers and standard Go:
internal/servemux
Package servemux is net/http's ServeMux as of Go 1.26, for builds whose net/http still routes like Go 1.21's: TinyGo's (tinygo-org/net#55; the fix waits in tinygo-org/net#56).
Package servemux is net/http's ServeMux as of Go 1.26, for builds whose net/http still routes like Go 1.21's: TinyGo's (tinygo-org/net#55; the fix waits in tinygo-org/net#56).

Jump to

Keyboard shortcuts

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