Extensibility
Terrabuild extensions are FScript programs that translate target actions into shell operations. They let a workspace add a tool-specific vocabulary without compiling or modifying Terrabuild.
For a guided first example, start with Customize your tools. It builds on the two-project tutorial and explains a complete extension line by line. This section is the reference for extending that example.
FScript is a lightweight language with F#/ML-style functions, records, unions, options, collections, and pattern matching.
Terrabuild currently embeds FScript 0.78.1; the links above open the matching version of the manual.
Use extensions to:
- expose project defaults (
defaulthandler) - expose runnable actions (
dispatchor explicit command handlers) - execute tools consistently on host or in containers
Terrabuild ships built-in extensions (identifiers like @dotnet, @npm, @terraform) and also supports custom extensions implemented as FScript (.fss).
@... identifiers are reserved for built-in extensions.
Use non-@ identifiers for custom extensions.
Two layers to learn
The FScript documentation explains the language: values, functions, type annotations, modules, imports, exports, and the standard library.
The Terrabuild documentation explains the host protocol layered on top:
- extension entrypoints use
export let - the first parameter is always named
context - remaining parameters bind exact, case-sensitive target argument names
- command handlers return
{ Batchable; Operations } - the script's final value describes dispatch, defaults, and cacheability
- Terrabuild grants IO and Threading permissions, denies interactive input and native FFI, and confines filesystem access to the workspace
Start with FScript Extensions, then use Protocol Types and Host Functions as references.
Authoring path
- Learn enough FScript to read functions, records, options, and pattern matching.
- Write a local
.fssscript with one exported command handler. - Add the descriptor that declares dispatch behavior and cacheability.
- Register the script in an
extensionblock inWORKSPACEorPROJECT. - Invoke its actions from targets and add defaults, metadata discovery, or batching only when needed.
Container execution is configured independently from the script protocol; see Container.