charter

module
v0.34.1 Latest Latest
Warning

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

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

README

charter

Go apps on Cloudflare Workers, one way: pages, an API from a contract, a live feed behind both, languages and search engines, in one Worker.

charter is a Go library and one command. It drives the tools that own each job and adds what they lack:

Job Tool Its file
The Worker: run it, ship it, its bindings wrangler wrangler.jsonc
Go on Workers workers-go go.mod
Components and the dev loop gsx, gsxui gsx.toml
Pages and their routes structpages pages/
The browser's files Vite, as gsx init sets it up vite.config.ts

A charter app runs on Cloudflare, nowhere else. Locally that is wrangler dev (the same runtime), remotely it is Cloudflare. There is no other server, and nothing that stands in for a binding.

You need

Go and Node. go.mod's toolchain line and package-lock.json pin every tool, on macOS, Linux and Windows.

charter picks two more programs for every developer and brings them itself, with charter install or the first time a command needs one:

For charter brings Used by
Secrets fnox, a pinned release checked against its SHA-256, kept in your cache folder deploy and everything else that talks to Cloudflare: wrangler runs under fnox exec, so the token comes from your keychain or password manager, never a file. Once: fnox set CLOUDFLARE_API_TOKEN
Containers Kiri, installed the way its guide says for your system and started when needed pack: Fern's SDK generators run in containers. Where a Docker engine already answers (CI's own), that one is used

go tool charter env says what this machine has.

Start

go run github.com/joeblew999/charter/cmd/charter@latest create my-app
cd my-app
go tool charter dev

That copies example/, the one app that uses all of charter, under your name.

An app, by convention

charter finds everything by where it is. There is nothing to configure for any of this:

pages/         the page tree (structpages) and its gsx: routes, links, the sitemap
api/           contract.go: the API, from which come its specs, MCP tools and SDKs
db/            migrations/*.sql and queries.sql, written as typed Go (db/queries.gen.go)
locales/       <language>.toml: the languages are the files here
web/  public/  what the browser loads (Vite)
ui/            gsxui's components
test/          tests of the pages (a real browser) and the API (its SDK), on wrangler dev and deployed
  dev/         only a local Worker
  deployed/    only a deployed one
sdk/go/        the app's own Go client, generated from the contract
wrangler.jsonc the Worker and its bindings, without ids
charter.toml   only url, and what Fern should generate
main.go
func main() {
	(&app.App{Name: "My App", Dist: dist, Pages: pages.Mount, API: api.Handler(env)}).Run()
}

What you never have to remember

  • Skills for your coding agent. gsx, gsxui, structpages and charter each ship their skill inside their Go module. charter install copies them into .claude/skills/ (the machine's, like node_modules: not in git) from the versions go.mod pins, and dev and check do it again whenever go.sum has moved. Updating a module updates its skill.
  • Generation. Two kinds, told apart by name. What is built from your sources each time is not in git: gsx's *.x.go (as gsx's own scaffold has it), charter's *.built.go, and .charter/, build/, dist/. dev, build and check write it, so a fresh clone needs only go tool charter check. What something reads from the repository is committed, and check holds it to its source: *.gen.go, db/migrations/, fern/, sdk/go/. check --fix writes what is committed and held to its source: db/queries.gen.go, db/migrations/, fern/, sdk/go/. Everything generated is named for it (*.gen.go, *.x.go) or in a folder of its own, and .gitattributes marks it.
  • The database. db/schema.sql is the one place a table is written down. dev keeps the local database in step with it as you edit, keeping its rows; check --fix writes the migration for what changed (one for everything not yet committed) and the typed Go for db/queries.sql; deploy applies it. A change that would lose data is refused until you ask for it (check --fix --drop); a renamed column says -- was: old_name. A column's comment (-- example: 42) becomes its tag, so the row is also what the API's contract serves: a note is written down once.
  • The upstream tools. gsx generate, gsx fmt, gsx dev, gsxui migrate rtl, structpages-lint, sqlc, vite build, wrangler d1 migrations apply all run inside dev, check, test and deploy, at the moment they are needed.

Commands

The commands are Vite+'s verbs. Run them as go tool charter <command> in the app's folder.

Command What it does
create A new app, from the example
dev The loop you work in, on the real runtime. Leave it running and run everything else beside it
check What can be said without running the app: format, lint, the contract, the languages. --fix writes what it can
test The Worker on wrangler dev: the standard API test, test/ (pages in a real browser, the API through its own SDK), the search-engine audit. --deployed asks the deployed one the same
deploy wrangler deploy and the D1 migrations. The first deploy makes the database, KV namespace, bucket and queue wrangler.jsonc names
pack The SDKs, from the contract, in containers (Kiri). pack -prove generates every language and proves each
run <task> Everything that is no verb, by what it is about: intl:translate, intl:status, seo:audit, seo:lighthouse, db:status, db:reset, db:seed, db:execute, db:export, ui:list, ui:theme, logs, bench, and the app's own. Alone, it lists them
add, remove add locale:de, add ui:dialog, a Go module, an npm package
build, preview, fmt, lint, install, exec, update, outdated, upgrade, staged, cache, env As in Vite+

Before a push: go tool charter check && go tool charter test.

The library

Six packages, github.com/joeblew999/charter/<name>:

Package For
app The app as a Worker: app.App (pages, API, Vite, languages, search engines in one value), <app.Head>, and app/apptest for its tests: Browser (Chrome), Get, Events, Secret, Local
api An API from a contract: Huma on Workers, OpenAPI and AsyncAPI, MCP tools, auth, rate limits
live A feed declared once (live.Feed): a D1 table as the log, a Durable Object to wake followers, and from it the page's live fragments, the API's stream and its WebSocket channel
cloud What workers-go lacks or gives differently: D1 as typed rows and batches, rate limits, email. For everything else, import workers-go's own packages
intl Languages, from the runtime's Intl: messages, plurals, numbers, dates, direction, a URL per language
seo What search engines read: robots.txt, the sitemap, the head, and the audit

The example

example/ is deployed at https://charter-example.gedw99.workers.dev. It has pages in three languages (one right to left, with ages, counts and times formatted by Intl), a notes API with tokens, limits, a stream and SDKs in Go, Python and as a CLI, one feed behind the page's live list and the API's stream, and /bindings: a card for everything Cloudflare gives a Worker (KV, R2, Queues, D1, Cron Triggers, the Cache API, Durable Objects, sockets, fetch, email), each used through workers-go's own package. Its tests use its own generated Go SDK as the client, and run unchanged against the local and the deployed Worker.

Directories

Path Synopsis
api
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.
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).
app
Package app runs a Go app as a Cloudflare Worker: its pages, its API, its browser files, its languages and its answers to search engines, in one value.
Package app runs a Go app as a Cloudflare Worker: its pages, its API, its browser files, its languages and its answers to search engines, in one value.
apptest
Package apptest is for an app's tests of its Worker (the app's test/ folder), which go tool charter test runs against the Worker on wrangler dev, and go tool charter test --deployed against the deployed one.
Package apptest is for an app's tests of its Worker (the app's test/ folder), which go tool charter test runs against the Worker on wrangler dev, and go tool charter test --deployed against the deployed one.
Package cloud is what Cloudflare gives a Go Worker that workers-go does not, or gives differently: for everything else, import workers-go's own packages (github.com/syumai/workers-go/cloudflare/…).
Package cloud is what Cloudflare gives a Go Worker that workers-go does not, or gives differently: for everything else, import workers-go's own packages (github.com/syumai/workers-go/cloudflare/…).
cmd
charter command
Command charter is the one command of a Go app on Cloudflare Workers.
Command charter is the one command of a Go app on Cloudflare Workers.
example module
sdk/go module
examples
notes module
notes-go module
notes/sdk/go module
go module
lib module
internal
badge
Package badge draws a small two-part SVG badge, label and value, as README badges look (shields.io's flat style), with no service and no fonts to fetch: charter run seo:search's Lighthouse and audit badges (charter run seo:badges).
Package badge draws a small two-part SVG badge, label and value, as README badges look (shields.io's flat style), with no service and no fonts to fetch: charter run seo:search's Lighthouse and audit badges (charter run seo:badges).
command
Package command is charter's commands for an app: a Go Worker on Cloudflare, laid out as its upstreams document.
Package command is charter's commands for an app: a Go Worker on Cloudflare, laid out as its upstreams document.
command/intl
Package intl is the languages' commands, which charter's verbs and tasks call (add locale:, check, build, run translate, …): an app's languages, from its charter.toml's intl (found up from the working directory).
Package intl is the languages' commands, which charter's verbs and tasks call (add locale:, check, build, run translate, …): an app's languages, from its charter.toml's intl (found up from the working directory).
command/seo
Package seo is charter seo: how a Go web app answers search engines, from its charter.toml's seo (found up from the working directory): the live site audited as Googlebot reads it, Lighthouse on Google's servers, the README's badges, and Google Search Console.
Package seo is charter seo: how a Go web app answers search engines, from its charter.toml's seo (found up from the working directory): the live site audited as Googlebot reads it, Lighthouse on Google's servers, the README's badges, and Google Search Console.
dbcode
Package dbcode is a project's database code, typed, from its schema (db/migrations/*.sql, the one place the tables are said).
Package dbcode is a project's database code, typed, from its schema (db/migrations/*.sql, the one place the tables are said).
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 [pack]; 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 [pack]; 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.
intlkit/catalog
Package catalog is an app's message catalogs as charter intl sees them ([intl] catalogs directory: <locale>.toml per shipped locale, ICU MessageFormat, the source locale first): read and checked against the source (Read), compiled for package intl (Generate), and what is left to translate (Locale.Todo).
Package catalog is an app's message catalogs as charter intl sees them ([intl] catalogs directory: <locale>.toml per shipped locale, ICU MessageFormat, the source locale first): read and checked against the source (Read), compiled for package intl (Generate), and what is left to translate (Locale.Todo).
intlkit/js
Package js is intl's JavaScript, which charter build copies into an app:
Package js is intl's JavaScript, which charter build copies into an app:
intlkit/setup
Package setup is charter add locale:<id>: it sets a gsx app up for intl, from its go.mod's directory.
Package setup is charter add locale:<id>: it sets a gsx app up for intl, from its go.mod's directory.
project
Package project reads what charter knows about an app: the Worker from wrangler.jsonc, which wrangler runs and deploys (https://developers.cloudflare.com/workers/wrangler/configuration/), and charter's own settings from an optional charter.toml beside it.
Package project reads what charter knows about an app: the Worker from wrangler.jsonc, which wrangler runs and deploys (https://developers.cloudflare.com/workers/wrangler/configuration/), and charter's own settings from an optional charter.toml beside it.
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.
seokit/pagespeed
Package pagespeed runs Lighthouse on a live page through Google's PageSpeed Insights API: on Google's servers, so no Node and no local Chrome.
Package pagespeed runs Lighthouse on a live page through Google's PageSpeed Insights API: on Google's servers, so no Node and no local Chrome.
seokit/searchconsole
Package searchconsole talks to the Google Search Console API with a service account, standard library only: submit and read sitemaps, and inspect how Google indexed a URL.
Package searchconsole talks to the Google Search Console API with a service account, standard library only: submit and read sitemaps, and inspect how Google indexed a URL.
standard
Package standard is the standard test: what every API charter serves must do, 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, checked on a running API from outside, as a client sees it.
tools
Package tools is the two programs charter picks for every developer, beside Go and Node, and brings itself when a machine lacks them, so that nobody sets either up or has to remember to:
Package tools is the two programs charter picks for every developer, beside Go and Node, and brings itself when a machine lacks them, so that nobody sets either up or has to remember to:
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 intl is a gsx app's languages: the runtime's own Intl, written in markup with gsx's own mechanisms.
Package intl is a gsx app's languages: the runtime's own Intl, written in markup with gsx's own mechanisms.
config
Package config reads an app's languages from its charter.toml: [intl], the languages it ships and where their catalogs are.
Package config reads an app's languages from its charter.toml: [intl], the languages it ships and where their catalogs are.
filters
Package filters is intl as gsx pipeline filters.
Package filters is intl as gsx pipeline filters.
intltest
Package intltest gives go test the Intl a Worker has: intl's js/intl-worker.mjs, with the app's catalogs, on workerd (intl/workerd), set as intl.Runtime.
Package intltest gives go test the Intl a Worker has: intl's js/intl-worker.mjs, with the app's catalogs, on workerd (intl/workerd), set as intl.Runtime.
registry
Package registry is a registry of gsx components that an app copies in and then owns, the way gsxui add copies gsxui's (https://ui.gsxhq.dev): each component a gsx template made of gsxui components, with its text already translated and, for one that runs in the browser, the files it loads there.
Package registry is a registry of gsx components that an app copies in and then owns, the way gsxui add copies gsxui's (https://ui.gsxhq.dev): each component a gsx template made of gsxui components, with its text already translated and, for one that runs in the browser, the files it loads there.
screens
Package ui is intl's own screens, which charter add screen:<name> copies into an app the way gsxui add copies components: the language list, the offer of the page in the reader's language, and the time zone and clock dialog.
Package ui is intl's own screens, which charter add screen:<name> copies into an app the way gsxui add copies components: the language list, the offer of the page in the reader's language, and the time zone and clock dialog.
workerd
Package workerd is intl's Intl outside a Cloudflare Worker: workerd, the Workers runtime, serving intl's js/intl-worker.mjs with the app's catalogs, set as intl.Runtime.
Package workerd is intl's Intl outside a Cloudflare Worker: workerd, the Workers runtime, serving intl's js/intl-worker.mjs with the app's catalogs, set as intl.Runtime.
Package live is a feed that browsers and API clients follow as it grows, with no item lost or sent twice:
Package live is a feed that browsers and API clients follow as it grows, with no item lost or sent twice:
seo
Package seo is how a site answers search engines: Site, the middleware that serves robots.txt, the sitemap and llms.txt, marks what isn't a page noindex and gives every page one address; Sitemap and LLMsTxt, what it serves; and SnippetWidth, how wide Google shows a title.
Package seo is how a site answers search engines: Site, the middleware that serves robots.txt, the sitemap and llms.txt, marks what isn't a page noindex and gives every page one address; Sitemap and LLMsTxt, what it serves; and SnippetWidth, how wide Google shows a title.
audit
Package audit reads a live site as Googlebot does, robots.txt, the sitemap and every page in it, and returns what would keep a page out of Google's index or look wrong in a result: what charter run seo:audit runs, and what an app's own tests run on a local build (Audit), so a page Google couldn't index fails before it ships.
Package audit reads a live site as Googlebot does, robots.txt, the sitemap and every page in it, and returns what would keep a page out of Google's index or look wrong in a result: what charter run seo:audit runs, and what an app's own tests run on a local build (Audit), so a page Google couldn't index fails before it ships.
config
Package config reads how an app answers search engines from its charter.toml: [seo], the live site and how Lighthouse scores it.
Package config reads how an app answers search engines from its charter.toml: [seo], the live site and how Lighthouse scores it.

Jump to

Keyboard shortcuts

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