grat

module
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT

README

CI Release Go Downloads License Last commit Repository size

grat

grat

grat = grat runs approved tasks

grat replaces the terminal tabs used to run a local development stack. Declare the commands for a frontend, an API, a dashboard, or a background worker once in grat.config, then manage them together.

grat discover  # reads the project and writes grat.config
grat start     # starts every service and waits until each one answers
grat status    # what runs, on which port, under which PID
grat stop

One project can start a React frontend, a Laravel or Vapor API, and a queue worker with one command. grat keeps their logs together, assigns ports by service role, checks that HTTP services are actually ready, and stops the complete process groups it started.

Does grat fit your project?

grat manages long-running development commands on macOS and Linux. A configured command has to stay in the foreground and be one of two things:

  • An HTTP service that takes a configurable local port and answers its health path with a status from 200 through 299.
  • A worker that has no HTTP port and only has to stay alive, such as a queue consumer or a file watcher.

An HTTP service can also publish one path to the internet at an address that stays the same, which is what a webhook from a payment provider or any other server-to-server callback needs. Which path that is has to be said, either in the configuration or on the command line, so a development server never goes public because nobody said otherwise.

Each command runs from the project root through non-login /bin/sh, and receives its port in PORT. A command that puts itself in the background leaves nothing for grat to watch, and a service whose port is held by a separate daemon never becomes ready.

Installation

On macOS, and on Linux where Homebrew is installed:

brew install phranck/grat/grat

That route installs the man pages as well, so man grat works straight away.

On Linux without Homebrew, take the release binary. It is one file and depends on nothing:

version=$(curl -fsSL https://api.github.com/repos/phranck/grat/releases/latest | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p')
curl -fsSL -o grat "https://github.com/phranck/grat/releases/download/$version/grat_${version}_linux_amd64"
gh attestation verify ./grat \
  --repo phranck/grat \
  --signer-workflow phranck/grat/.github/workflows/release.yml \
  --source-ref "refs/tags/$version" \
  --deny-self-hosted-runners
chmod +x grat
sudo install -m 0755 grat /usr/local/bin/grat

The verification runs before the install, because installing first and checking afterwards is checking a file that is already on the path. It proves the binary was built by this repository's release workflow from that exact tag, and it needs the GitHub CLI. Without that, take the checksum instead: Documentation.md carries both.

The version is read from the newest release rather than written here, so this stays current. Use linux_arm64 on ARM. macOS binaries are published the same way, as darwin_amd64 and darwin_arm64. A binary installed this way carries no man pages; grat.1 and grat.config.7 sit beside it in the same release, and Documentation.md says where to put them.

Or build it with Go 1.26.10 or newer:

go install github.com/phranck/grat/v2/cmd/grat@latest

Documentation.md covers verifying a release binary against its checksums and its signed attestation.

Quick start

Run the setup in a project directory:

cd ~/Developer/example
grat discover
grat start
grat status

grat discover reads the project and proposes the services it recognises, so most projects need nothing written by hand. Angular, Astro, Next.js, Nuxt, React Router, SvelteKit and Vite are recognised on the frontend, Django, Laravel, Symfony, Rails, Phoenix, Spring Boot, FastAPI, Flask and ASP.NET Core on the backend, along with Go modules, Rust crates using Axum or Actix, Deno and Bun projects, Hugo and Jekyll sites, and Swift packages using Vapor. A Docusaurus site or a Storybook is reported in addition to the application it sits beside, on a port of its own.

Express, Fastify, NestJS and Go are different: none of them reads PORT on its own and none has a flag for it, so the port lives in the line of your own code that starts the server. grat looks there, and where it does not find it, it says so instead of proposing a command that would never become ready. Eleventy is refused for its own reason: its development server binds every interface with no flag to pin it to loopback, and it moves to another port when the assigned one is taken. What grat recognises explains both.

Anything grat does not propose can be given explicitly:

grat discover --name example-api \
  --service 'backend=swift run App serve --hostname 127.0.0.1 --port $PORT'

The resulting grat.config is regular TOML and can be read and edited before the first start.

For a repository you cannot write into, grat discover --registry keeps the same configuration in grat's own registry and leaves the directory untouched. Everything else works as it does otherwise, and grat status says where the configuration came from. The file stays the default because it travels with a clone and with a branch, so a colleague types grat start and it works.

Given a path, grat discover searches below it instead and shows what it found as a list you move through, so a folder of twenty projects is set up in one pass and you decide per project whether its configuration is written:

grat discover ~/Developer

Reading further

  • man grat for every command and how grat works, and man grat.config for every option the configuration file takes. Both are generated by the binary, so they describe the version you have. grat help prints a short overview of the commands without leaving the terminal.
  • Documentation.md for the configuration reference, the roles and their port ranges, what readiness and shutdown guarantee, and how public access works.

Contributing and support

Read CONTRIBUTING.md, SECURITY.md, CODE_OF_CONDUCT.md, and SUPPORT.md before participating.

License

This repository has been published under the MIT license.

Directories

Path Synopsis
cmd
grat command
Command grat manages configured local development processes from any project.
Command grat manages configured local development processes from any project.
internal
cli
Package cli maps user-facing commands to project-scoped services.
Package cli maps user-facing commands to project-scoped services.
config
Package config loads, validates, and writes declarative grat configurations.
Package config loads, validates, and writes declarative grat configurations.
detect
Package detect reads a directory and reports the services grat could manage there.
Package detect reads a directory and reports the services grat could manage there.
maintenance
Package maintenance implements grat's installation maintenance commands.
Package maintenance implements grat's installation maintenance commands.
manual
Package manual builds grat's manual as a document and renders it.
Package manual builds grat's manual as a document and renders it.
operations
Package operations serializes state-changing grat commands for one user.
Package operations serializes state-changing grat commands for one user.
ports
Package ports scans declarative configs and allocates conflict-free ports.
Package ports scans declarative configs and allocates conflict-free ports.
ports/procnet
Package procnet reads the Linux /proc tables that report which process owns a listening TCP socket.
Package procnet reads the Linux /proc tables that report which process owns a listening TCP socket.
presentation
Package presentation renders consistent, terminal-safe service command output.
Package presentation renders consistent, terminal-safe service command output.
project
Package project resolves the project root selected by the current directory.
Package project resolves the project root selected by the current directory.
publish
Package publish holds the rules that decide what of a project reaches the public internet, and which published funnel belongs to which service.
Package publish holds the rules that decide what of a project reaches the public internet, and which published funnel belongs to which service.
runtime
Package runtime supervises project-local service processes.
Package runtime supervises project-local service processes.
settings
Package settings manages grat's user-local configuration and scan roots.
Package settings manages grat's user-local configuration and scan roots.
tailscale
Package tailscale is everything grat asks of Tailscale, and nothing more.
Package tailscale is everything grat asks of Tailscale, and nothing more.
tailscale/tailscaletest
Package tailscaletest provides a Tailscale client that records what it was asked to do, so commands can be tested on a machine without Tailscale.
Package tailscaletest provides a Tailscale client that records what it was asked to do, so commands can be tested on a machine without Tailscale.
textsafe
Package textsafe identifies and neutralizes Unicode characters that can change terminal layout or conceal the visual order of untrusted text.
Package textsafe identifies and neutralizes Unicode characters that can change terminal layout or conceal the visual order of untrusted text.
version
Package version exposes the semantic version of the installed grat binary.
Package version exposes the semantic version of the installed grat binary.

Jump to

Keyboard shortcuts

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