Skip to main content
ff is a single binary. Run it with no arguments to print the built-in usage summary; ff -h, ff --help, and ff help print the same.

Errors & exit codes

ff renders its own diagnostics in a fixed shape:
  • error is printed in red and hint in dim when stderr is a TTY. Color is auto-disabled when output is piped or redirected, or when NO_COLOR is set (to any value).
  • Progress, success, and detail lines use a small glyph vocabulary: → for a step in progress, ✓ for a completed step, and • for secondary detail. The glyphs are plain UTF-8; only color is TTY-gated.
  • Every command exits 0 on success and 1 on failure. This includes usage errors (missing arguments, unknown options), a missing or invalid ff.json, network/registry failures, integrity mismatches, and failed tests. Several failure paths that used to print a message but exit 0 — ff upgrade on a network error, ff start/--watch start with no ff.json, ff imprint or ff sever with a malformed manifest, TLS setup errors in ff start — now exit 1.
  • An unknown option prints error: unknown option '--x' and a hint to run ff --help; a missing argument prints the same error: plus the command’s one-line Usage:.
  • JavaScript exceptions are not part of this shape: they keep their own Error: … output from the runtime and REPL. A permission denial is one of these — an Error named PermissionDenied with code: "PERMISSION_DENIED" — so it does not use the error:/hint: CLI shape.

Quick look

Permissions

Native APIs are deny-by-default. A script can only read files, open sockets, inspect the environment, spawn children, or load native code when the launch command grants it with a --allow-* flag. Flags are repeatable and comma-split. A bare flag grants the whole category:
Scope rules:
  • Paths resolve against the launch cwd and stay fixed. --allow-read=. is the launch directory; symlink targets must remain inside a scope.
  • Network scopes are host, host:port, or *.domain. localhost and 127.0.0.1 are distinct. http.serve always checks 0.0.0.0:<port>.
  • Environment scopes are exact, case-sensitive names.
  • Run scopes are basenames (git) or absolute paths. exec / execSync also need /bin/sh in scope.
  • --allow-ffi is bare only. --allow-all is trust-equivalent to full access; run and ffi can execute arbitrary code.
The flags are accepted by every command that starts the runtime — ff <file>, ff -e, ff start, ff test, ff repl, and ff --watch (which forwards them to the restarted child). They are scanned from the full argv, so ff start --allow-net=0.0.0.0:3000 works. CLI-only commands (ff imprint, ff fmt, ff upgrade, ff compile) do not start a runtime and are not gated. A denied call throws before any I/O, job, promise, child, or socket is created:
Full flag and scope reference: Permissions.

Run a file

Runs the given JS file — or .ffbc bytecode (the loader detects the magic). The process exits when the event loop drains.
--ca trusts an extra CA bundle for that run’s outbound fetch / WSS. It is accepted only by ff <file> and ff -e — not by ff start (use FF_CA_FILE there).
Native APIs are denied unless the matching flag is present. A denied call throws before it reaches the OS; see Permissions.
--allow-ffi unlocks the ffi global. Native code and raw pointer/memory helpers bypass every other permission and sandbox guarantee; without the flag every ffi entry point except ffi.allowed denies, and ffi.allowed is false. See FFI for the full API and security contract.

Evaluate inline code

Runs the string as a classic script — no top-level await (it’s a SyntaxError; wrap in an async IIFE when you need await). Accepts --ca like ff <file>. Handy for smoke tests:
Permission flags apply exactly as they do for a file.

Scaffold a project

Prompts (Enter accepts each default), skipped entirely with -y / --yes: Writes ff.json plus the entry file (console.log("Hello from fairyfly!")). Optional [<dir>] scaffolds inside a new directory.
ff init always overwrites ff.json and the entry file. Back them up first if you customized them.

Serve a project

Reads main from ff.json and runs it as a module (max 10MB). Missing or invalid manifest prints an error and exits. Permission flags are accepted after start, alongside the TLS flags. They are scanned from the full argv, so position does not matter. When the entry starts an HTTP server, ff prints the step and the bound URL:
With TLS (--cert/--key or http.serve({ tls })) the URL uses https://. Both must be given together. On success the same port serves HTTPS/WSS too, and the cert path is trusted by the runtime’s own outbound fetch / WebSocket — convenient for self-signed dev setups. The CLI reads --cert / --key before the runtime starts, so those two files do not need --allow-read. File paths passed to http.serve({ tls: { cert, key } }) are runtime reads and do. The port comes only from http.serve({ port }) (default 3000). There is no --port and no FF_PORT.

Install packages

Only ESM-compatible packages pass the pure-ESM gate. ff imprint is an install command: its registry and archive downloads are not runtime fetch calls and do not require --allow-net. Direct sources also accept https://github.com/owner/repo[#ref] and https://codeberg.org/owner/repo[#ref]; omit #ref to use HEAD. The archive root must contain package.json. Private repositories, authentication, monorepo subdirectories, and build scripts are not supported. The lock pins the archive URL and a computed SHA-512 integrity hash; a moved branch fails the integrity check instead of installing different code.

Remove packages

Names are scope-aware: ff sever @scope/pkg@1.0 strips to @scope/pkg.

Run the test suite

Runs every test/*.test.js through the runtime (same convention as test/run.sh — see the Testing guide). The optional filter is a substring match on the filename. Each file evaluates to success with no FAIL lines; exits 1 if any test fails. Files larger than 10MB are not loaded. The runner executes the files in-process, so the permission flags apply to the code under test. With no flags, any test that touches a native API fails with PermissionDenied. The repository’s test/run.sh passes --allow-all because the suite exercises every gated API; a project suite should use only the flags its tests need. Pass --allow-ffi to run the FFI contract (test/ffi.test.js); without it the FFI tests skip.

Interactive REPL

Line buffer is 8192 bytes. Async work runs after each line via microtasks + event loop. Permission flags apply to every expression evaluated in the session.

Compile to bytecode

Compiles an ES module to QuickJS bytecode with source and debug info stripped. Default output replaces the extension with .ffbc. Input cap: 20MB.
Compiling does not execute the module, so permission flags have no effect here. They apply when the bytecode is run.

Format code

Delegates to npx --yes prettier (needs network, or a global prettier). Without files it prints usage; exit code is non-zero when prettier fails. This is a CLI operation and is not gated by --allow-net or --allow-run.

Self-update

Queries GitHub Releases for AbdElMajidOuhamane/ff (needs curl), compares semver against ff --version:
Releases are published at github.com/AbdElMajidOuhamane/ff/releases — v0.2.0-beta is the first. With a release available, ff upgrade reports up-to-date for current builds, downloads when you’re behind, and only takes the failure row on network errors or a missing release asset.

Watch mode: ff —watch

Runs as a lightweight supervisor process that watches the current directory tree and automatically restarts the child whenever files change:
  • Target: Accepts either a JavaScript entry file (ff --watch <file>) or start (ff --watch start to run main from ff.json).
  • Flags: Forwards custom CA (--ca <path>) and all permission flags (--allow-*) directly to the child.
  • Polling & Debounce: Recursively monitors file modification times (mtime) and file sizes with a 200 ms polling interval and 100 ms debounce window.
  • Ignored paths: Automatically ignores .git, node_modules, zig-out, .zig-cache, and zig-cache.
  • Clean restart: Reaps the previous child process by sending SIGTERM, waits up to 500 ms grace period, escalates to SIGKILL if the child hangs, then spawns a fresh runtime.
  • Signal forwarding: SIGINT and SIGTERM on the supervisor cleanly terminate the child. Sets FF_WATCH_PARENT so the child automatically exits if the parent supervisor terminates.

Proxy environment

Outbound fetch / WebSocket requests in every command honor the standard proxy environment variables. They are read once at process start: Proxy URLs may carry credentials (http://user:pass@proxy:8080). SOCKS is not supported. See fetch Proxies for matching details and examples.

Summary