/machin:machin-deployfrom machin
Ships machin (MFL) HTTP services to production behind a reverse proxy. Covers hardening, proxy-awareness (trust-proxy, secure cookies), body limits, timeouts, access logs, systemd units, and Docker images.
Ships in machin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A machin web service is one static-ish native binary (it links libc, OpenSSL, and maybe libsqlite3 — not fully static, but no runtime/interpreter). The standard production shape is that binary behind a reverse proxy that terminates TLS — nginx, Caddy, Traefik, or Cloudflare. You do not need machin to speak TLS itself; the proxy does HTTPS and forwards plain HTTP to your app. This skill is about making the app correct and safe in that setup.
serve_tls(port, certfile, keyfile, handler) (framework/machweb.src) lets machweb
terminate HTTPS itself with no proxy in front — for a simple/internal service where you
already have a cert+key file and don't want another moving part. It's not yet a
replacement for the proxy setup below for anything public-facing: no ACME/Let's Encrypt
auto-renewal (bring your own cert, renew it yourself), and res.is_hijack/res.is_stream
(protocol upgrades, SSE) aren't supported over it yet — use serve behind a proxy for
those. Reach for serve_tls when you want zero infra for a small/internal HTTPS service;
reach for the reverse-proxy shape below for anything public production-facing.
Build the app with the
machin-web/machin-backendskills; this is the operate it in production how-to.
main)All default off, so dev is unchanged. Enable what you need before serve:
func main() {
harden(20 * 1024 * 1024, 15000) // body cap 20 MB, 15 s read timeout, +trust-proxy,
// +Secure cookies, +access log — the common set
serve(8080, func(req) { return handle(req) })
}
harden(max_body_bytes, read_timeout_ms) is shorthand; the individual switches are:
| Call | Effect |
|---|---|
set_trust_proxy(1) | trust X-Forwarded-Proto / X-Forwarded-For (only behind a proxy you control) |
set_secure_cookies(1) | add ; Secure to every cookie (you're served over HTTPS) |
set_max_body(n) | reject a request body larger than n bytes with 413 — without buffering it |
set_read_timeout(ms) | cap a slow client's request read (anti slow-loris) |
set_access_log(1) | one JSON access-log line per request on stderr (fd 2) |
Behind a TLS-terminating proxy the socket is plain HTTP, so without help your app thinks
every request is http:// and sees the proxy's IP. With set_trust_proxy(1):
scheme(req) → http/https from X-Forwarded-Proto. Use it so redirects, OAuth
redirect_uris, and emailed links are https, not http.base_url(req) → scheme://host — build absolute URLs that survive the proxy.client_ip(req) → the real client (left-most X-Forwarded-For hop), for logging /
rate-limiting / audit. req.remote is the raw socket peer (the proxy) if you need it.set_secure_cookies(1) → sessions get Secure so they're never sent in clear.Only trust these headers behind a proxy that sets them — a client can forge
X-Forwarded-*. If the app is ever directly exposed, leave set_trust_proxy(0).
nginx — forward the headers machweb reads, and don't buffer SSE:
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off; # let Server-Sent Events stream (machweb also sends X-Accel-Buffering: no)
}
Caddy — TLS + the forwarded headers are automatic:
app.example.com {
reverse_proxy 127.0.0.1:8080
}
A single binary is a trivial unit. Type=simple, run as a non-root user, restart on
failure, and rely on set_access_log(1) → journald:
[Unit]
Description=machin app
After=network.target
[Service]
ExecStart=/opt/app/server
Environment=PORT=8080 APP_SECRET=change-me
User=app
Restart=on-failure
RestartSec=2
# SIGTERM stops it; in-flight requests are short-lived goroutines.
[Install]
WantedBy=multi-user.target
listen sets SO_REUSEADDR, so a restart rebinds immediately (no TIME_WAIT wait).
By default the binary needs libc + OpenSSL (libssl/libcrypto, for sessions/crypto) and
libsqlite3 (if you use SQLite) at runtime, so ship it on a slim base:
FROM debian:stable-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
libssl3 libsqlite3-0 ca-certificates && rm -rf /var/lib/apt/lists/*
COPY server /usr/local/bin/server
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/server"]
(Multi-stage: build with machin build in a builder stage, copy just the binary.)
FROM scratch for a SQLite-only service: machin build --static compiles the SQLite
amalgamation in (no libsqlite3); with CC=musl-gcc you get a libc-free ~1 MB binary that
runs from an empty image — FROM scratch / COPY server / ENTRYPOINT. This works when the
program uses no OpenSSL — i.e. no HTTPS client (https_*) and no crypto builtins
(hmac_sha256/sha256/rand_bytes/…, which signed sessions use). Those still link OpenSSL
(so the slim base above) until native TLS lands (issue #260).
set_trust_proxy(1) only behind a proxy that
overwrites X-Forwarded-*. Directly exposed → keep it off, or a client spoofs its IP.set_secure_cookies(1) requires HTTPS. On a Secure cookie set over plain http://
the browser drops it — turn it on only once TLS (via the proxy) is in front.Content-Length — an over-cap request is 413'd before
its body is read (no OOM, no draining megabytes).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
machin, mfl, machweb, production-deployment, reverse-proxy, systemd
npx claudepluginhub javimosch/machin --plugin machin5 skills in this plugin
/machin-backendBuild a single-binary backend service in machin (MFL) — HTTP/JSON APIs, five pooled datastores (SQLite, PostgreSQL, MySQL/MariaDB, Redis, MongoDB), signed sessions, OAuth2/OIDC SSO, and agent-first CLIs — all pure MFL, one static binary, no Node/ORM/cgo. Use when writing or debugging a machin backend: a REST/JSON service, a database client or migration, an auth flow, a daemon, or a headless-CMS-style tool. Covers the machweb/postgres/mysql/redis/mongo/bson/sso frameworks, the uniform JSON-rows + parse() pattern, connection pooling for concurrency, the agent-first CLI contract, and the hard-won gotchas. Distilled from the backend dogfood (machin v0.60–v0.74) and the MachNotes / machin-db-migrate / machin-cms apps./machin-gamedevBuild native games and interactive desktop/terminal apps in machin (MFL) — the canonical setup, build-and-verify workflow, raylib C-FFI surface, audio, and the hard-won caveats/gotchas. Use when writing or debugging a machin game (terminal TUI or raylib GUI), or any machin program that draws a window, plays sound, or reads real-time input. Covers terminal TUI, raylib GUI/audio, 3D cameras, GPU meshes (pointer/array FFI), instancing, shaders, procedural worlds (noise), fixed-timestep sim loops, a pure-MFL math3d module (Vec3), verlet physics (position-based dynamics, constraint relaxation, collision), rlgl point-cloud rendering (RL_POINTS for particle systems and star fields), ballistic physics (gravity + quadratic drag + wind, trajectory prediction), and first-person player controllers (walking, jumping, platform stepping, object pushing, walk/fly toggle). Distilled from machin-game-demo-snake / -2048 / -flappy / -simon / -3d / -terrain / -planet / -cyberpunk / -solar / -physics / -galaxy / -ballistics / -player./machin-startDecide whether to build something in machin (MFL) and bootstrap it fast — the entry point that comes BEFORE the domain how-tos. Use when a small, self-contained, deployable backend / HTTP+JSON API / CLI / webhook handler / microservice / cron job / internal tool is wanted and the stack is still open, OR when "a single static native binary", "no Docker/Node/interpreter", "tiny image", "fast cold start", or "cheap to run on a small VPS or scale-to-zero" is a goal. Covers when machin wins (with measured numbers) vs Go/Node/Python, when NOT to reach for it, and a zero→running→shipped quickstart (install → a 12-line REST+SQLite service → static musl build → a 92.9 kB FROM-scratch image). Routes to the web / backend / gamedev / deploy skills. Read this first./machin-webBuild web apps in machin (MFL) — a native HTTP server, a JSON API, server-side rendering, and a reactive WebAssembly UI, all in one language with no Node/bundler. Use when writing or debugging a machin web app: a backend service, an SSR page, a wasm SPA, an isomorphic full-stack app, or a CRUD back-office. Covers the machweb/reactive/router/flags frameworks, cookies + signed sessions, OAuth2/OIDC SSO, the wasm bridge + host↔wasm marshaling, the generic JS host, the pure-MFL Postgres/MySQL/Mongo/Redis drivers, build-and-verify, and the hard-won gotchas. Distilled from the web + backend dogfood (machin v0.50–v0.73).Other plugins' skills for the same job