Concepts
Environment
Section titled “Environment”An Environment is the top-level container. It holds a collection of entities that together form your local stack.
const env = new Environment("my-app");When you call env.up(), all entities start sequentially in the order they were added. When you call env.down(), they stop in reverse order.
Entities
Section titled “Entities”An Entity is anything that runs — a database, a service process, a browser instance. Each entity has:
- A name (unique within the environment)
- A status lifecycle:
pending→starting→running→stopping→stopped(orerror) - A
start()andstop()method - Zero or more interfaces
Built-in entity types
Section titled “Built-in entity types”| Entity | What it does | Backed by |
|---|---|---|
Postgres | Runs a PostgreSQL database | Docker container |
Service | Runs any command as a process | Bun.spawn subprocess |
Browser | Launches a browser instance | Puppeteer (coming soon) |
Interfaces
Section titled “Interfaces”An Interface describes how an entity is exposed — its protocol, port, and connection details.
// Postgres exposes a PostgresInterfacedb.connectionString // "postgresql://postgres:postgres@localhost:5432/myapp"
// A Service can hold any interfacenew Service("frontend", config, [new BrowserInterface(3000)])new Service("backend", config, [new APIInterface(8000)])Interfaces provide:
protocol—"http","tcp","ws", or"grpc"port— The port numberhost— Defaults to"localhost"getConnectionString()— A URL for connectingisReady()— An async readiness check
Startup Order
Section titled “Startup Order”Entities start sequentially in the order you call env.add(). This matters because later entities often depend on earlier ones:
// db starts firstconst db = env.add(new Postgres("db", { ... }));
// backend starts after db is running — can use db.connectionStringconst backend = env.add(new Service("backend", { env: { DATABASE_URL: db.connectionString }, ...}));
// frontend starts after backend is runningenv.add(new Service("frontend", { ... }));Shutdown happens in reverse order: frontend → backend → db.
Instance Namespacing
Section titled “Instance Namespacing”Each sigil up creates a named instance (default name: "default"). Instance state is stored at .sigil/instances/<name>.json in your project directory.
This means:
- Multiple instances can run simultaneously with different names
sigil downfinds the right process to stop via the state filesigil statusshows all running instances- Stale state files (from crashed processes) are automatically cleaned up
Config File
Section titled “Config File”A sigil.config.ts file exports an Environment as its default export. Sigil dynamically imports this file at runtime — no build step needed.
import { Environment, Postgres, Service } from "sigil";
const env = new Environment("my-app");// ... add entities ...export default env;See the Config File Reference for full details.