RatMinimal web framework

CLI

The rat binary does everything: create a project, run the dev server, build static HTML, install dependencies, and run database tooling. No package script layer to maintain. Every command acts on the project in the current directory.

rat new

Scaffold a project

Writes a minimal project layout to the given directory: main.rat, a pages/index.rat, a styles file, a settings.json, and an empty rat.json. Existing files are preserved; only missing pieces are written.

rat new mysite
cd mysite

rat start

Dev server with hot reload

Reads settings.rat (or settings.json) for host and port, watches the project, and serves over HTTP. Hot reload is on by default: every .rat, .css, .js, or .py save pushes an SSE event and the browser refreshes.

rat start            # uses settings host/port
rat start 8080       # override the port

rat build

Static HTML output

Walks every routable page, renders against the loaded site, and writes <out>/<route>/index.html for each. Use it to preview the rendered shell, or for static deploys when the project needs no live database or handlers.

rat build            # defaults to ./out
rat build dist       # custom directory

Adding prod (or --prod) produces deploy-ready output. The page-invariant part of the client runtime moves to a fingerprinted _rat/runtime-<hash>.js, and every page references it through an SRI integrity hash. The same bytes serve every page, caching improves, and a CSP script-src 'sha256-…' can pin the runtime by hash. A build.json at the output root lists every emitted file with its SHA-256 and size, plus the runtime's URL and integrity, so a downstream CSP or CDN config can be regenerated without re-walking the tree. RAT_MODE=prod is set for the build duration, so any prod-conditional render path sees the same result the deployed binary would.

rat build prod       # static HTML + fingerprinted runtime
rat build dist prod  # custom out dir + prod shape

rat run

Run a .rat file as a script

Executes a single .rat file whose top level declares > main[args]. Positional CLI arguments are bound as a Rat string array; << returns the exit code. No HTTP and no page render: the same engine, with a different entry point. See the script-mode page for the full details.

rat run hello.rat
rat run seed_users.rat alice bob carol

rat install / rat i

Install npm and Python dependencies

rat install restores every dependency recorded for the project: npm packages from rat.json into public/vendor/<name>/, then Python dependencies from lang/python/requirements.txt into a per-project venv. rat i <pkg> adds an npm package and records it.

rat install                # restore everything
rat i react                # add latest react
rat i react@18.2.0         # pin a version
rat i react preact uuid    # add several

rat db

Database tooling

Subcommands cover the migration lifecycle. status lists discovered models; migrate <name> writes a new migration from the current schema; push applies pending migrations; rollback <name> reverts one.

rat db status
rat db migrate add_users
rat db push
rat db rollback add_users

rat update

Update the CLI in place

Downloads the requested release from GitHub and replaces the running binary. No installer re-run, no manual download. With no version it resolves the latest release; an explicit version works with or without the leading v. On Windows the old binary is parked next to the new one as rat.exe.old and removed by the next update.

rat update           # latest release
rat update 0.2.3     # pin a version
rat update v0.2.3    # same thing

See also Settings · Script mode · Publishing a Rat app