A phase object is a layered and versioned image with instructions for building and updating it. Each beam micro-VM uses a specific phase image.
To create your first phase, use Getting Started. For troubleshooting, read troubleshooting guide.
The phase object
A phase object records its name, immutable parent, build configuration, and current build status.
The status field is read only. Check build states before using a phase image.
Create a phase
The CLI shortcuttsh phase add [name] starts an interactive build beam micro-vm with phase operations enabled.
Use --from=parent to create a child following that parent’s successful images; without it, a new phase starts from default:v1.
Creation returns the phase and its provisioned build beam.
Creation parameters
CLI parameters
| Parameter | Meaning / default |
|---|---|
name (positional) |
Optional, omit to generate a name. It is required when replace is true. At most 54 lowercase letters, digits, or hyphens and begins and ends with a letter or digit. In CLI, omit to generate a name, required for phase edit |
--from=parent |
New phase defaults to default:v1; use phase edit to replace an existing phase |
--fork-from=source, --commands-file=path, --copy=destination:source |
Select the build input; see Build choices below |
--region=region |
Select region for a beam. |
--roles=role-a,role-b |
Narrow the roles delegated to builds, cannot accompany replacement. |
--no-console |
Does not connect to the build shell or logs. |
--format |
Format output. |
Build permissions inherit owner’s standing roles that could be delegated. You can narrow permissions by explicitly selecting roles.
The first build pins the phase’s region. Children, refreshes, and beams consuming its images stay in the region. Changing proxies does not move an image. Build beams count against beam quota and expire. See tsh beams ls for the deadlines. Expiry does not save unsaved files.
Build choices
Build type selects what one build does. It is separate from the phase’s refresh strategy.
CLI build choices
| Build input | Completion |
|---|---|
phase add, phase edit |
Interactive SNAPSHOT build; explicitly save a snapshot, optionally ending the build |
--fork-from=source, edit --from=source |
Start from a saved snapshot, then work interactively |
--commands-file=path, command stages in phase apply |
REBUILD successful command result is saved automatically. |
--copy=destination:source, file stages in phase apply |
COPY; CLI finishes the copy before returning |
--no-console suppresses shell/log connection. Interactive and raw command builds then return after provisioning, with a build_beam identifier: success means started, not saved or finished. Without it, command builds stream logs and wait. Copy builds still finish before returning. --format=json or --format=yaml provides structured results for add, edit, apply, snapshot, and listings; an interactive shell connection requires text output.
Examples
# --no-console will return an ID of the build beam
tsh phase add sdk-work --from=app-config --no-console --format=json
tsh beams ssh [id-of the beam]{
"name": "sdk-work",
"owner": "alice",
"strategy": "snapshot",
"parent": "app-config",
"state": "building",
"build_beam": "example-build-beam",
"region": "example-region"
}Edit or replace a phase
In CLI, tsh phase edit name opens an interactive build from that phase’s saved snapshot. tsh phase edit name --from=source starts from another eligible snapshot with the same parent. For commands or files, use --commands-file or --copy, those cannot also use --from.
- Interactive edits - use fork and supply source name. To supply a resolved snapshot directly, use phase build’s “interactive from” parameters.
- For command replacement update commands.
- For copy replacement update copy and finish copy build.
Replacement requires an existing phase and keeps its parent and role selection. A copy phase accepts only copy snapshots and replacements. Command replacement keeps the existing parent; a copy replacement rebuilds the copy layer from the current parent.
Replace operation returns the result as create: the current phase and a new build beam. Connect to that beam, edit, and save the changes you want to keep.
CLI parameters
| Parameter | Meaning |
|---|---|
name (positional) |
Existing phase to edit |
--from=source |
Eligible saved snapshot with the same parent; cannot accompany command or copy input |
--commands-file=path, --copy=destination:source |
Replace using commands or files instead of an interactive snapshot |
--no-console, --format |
Return without connecting; use structured output |
Snapshot and edit restrictions
A phase cannot have two active edits. A snapshot phase cannot be edited or saved while it has snapshot descendants, including indirect descendants or snapshot builds in progress. Rebuild and copy children alone do not prevent editing. Fork to a new phase when descendants prevent replacement. Recovery steps are in Troubleshoot phases.
exit and Ctrl-D disconnect without saving or ending the build. To end without another save, use tsh beams rm <build-beam>. Ending or expiring the build discards unsaved changes, not previously saved checkpoints.
Examples
tsh phase edit sdk-work --no-console --format=json{
"name": "sdk-work",
"owner": "alice",
"strategy": "snapshot",
"parent": "app-config",
"state": "building",
"build_beam": "example-edit-beam",
"image_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"region": "example-region",
"published_at": "2026-06-01T12:00:00Z"
}Fork a phase
Use tsh phase add experiment --fork-from=source to create an independent phase from the source’s saved snapshot. Inside a build beam, use tsh phase add experiment --fork to capture the current allowed files and create a fork. --fork takes no source argument.
A fork keeps the source’s parent. Later edits to the source do not update the fork. A child created with --from=source has the source itself as its parent. Future source images affect the child.
--fork-from excludes unsaved edits in the source beam. You cannot fork rebuild or copy phases, even with an explicit digest. Use those phases as parents instead.
Outside a beam, you must supply the original region when using an explicit built-in-parent snapshot. For example, use tsh phase add experiment --fork-from='default:v1@sha256:<digest>' --region=<original-region>. An explicit reference does not move an image across regions.
CLI parameters
| Parameter | Meaning |
|---|---|
name (positional) |
New phase name. Omit it to generate a name. |
--fork-from=source |
Saved source phase or snapshot reference. Excludes unsaved edits. Choose this or --fork inside a build beam. |
--fork |
Capture current allowed files inside a build beam. Takes no source argument. Choose this or --fork-from. |
--region=region |
Supply the original region when using an explicit built-in-parent snapshot outside a beam. |
Forking returns the new phase and its build beam in a creation result. It does not return the source phase. Save the new build to publish its image.
Examples
tsh phase add experiment --fork-from=sdk-work --no-console --format=json{
"name": "experiment",
"owner": "alice",
"strategy": "snapshot",
"parent": "app-config",
"state": "building",
"build_beam": "example-fork-beam",
"region": "example-region"
}Save and publish snapshots
Inside the interactive build beam, use tsh phase snapshot to save allowed changes and keep working. Add --final to end the build after a successful save.
The examples below save sdk-work after editing. Do the work you want to keep before running a save.
CLI parameters
| Parameter | Meaning / default |
|---|---|
name (positional) |
Target phase name. Inside a build beam, omit it to use the beam’s phase. |
--final |
End the interactive build after successful publication and verification. Without this flag, the build keeps running. |
--force |
Omit disallowed changes from the image. The running filesystem stays unchanged. False by default. |
--from=reference |
Publish a captured snapshot for the target. Cannot be combined with --final. |
--format |
Return a structured result. |
You cannot combine --final with --from. Publishing a snapshot alone does not end the build or change its command configuration. A supplied snapshot must belong to the target and match its parent and provenance.
If a final save fails or its outcome is uncertain, the build stays available for diagnosis. See Verify an uncertain save.
Snapshot helpers return the saved phase directly, not wrapped in a phase field. The low-level methods publish_phase and publishPhase return PublishPhaseResponse. A final CLI save also writes Quitting this build. to stderr.
Publishing a snapshot does not clean up the build. Use the final-save helper when you also need to end an interactive build.
Filesystem capture rules
Interactive snapshots save allowed changes under /home. By default, capture rejects changed paths outside the allowed set. It also rejects paths reserved by ancestor rebuilds.
Use --force to omit those changes from the saved image. The files in the running beam stay unchanged. Omitted changes disappear when the beam is removed.
Some files are always excluded, regardless of strategy or --force:
- Temporary/runtime trees:
/run,/tmp,/var/tmp,/proc,/dev, and/sys. - Per-beam configuration:
/etc/environment,/etc/hosts,/etc/hostname,/etc/resolv.conf, and/etc/motd. - Under
/home/beams:.tsh,.cache, and.kube. - Platform Codex/Claude configuration under
/etc/codexand/etc/claude-code, login accounting files, and protected platform launcher/helper binaries.
Snapshots save build output in /var/log/beam/build.log. You can also save personal settings, repositories, instructions, and allowed tool state under /home. Credentials in saved paths can be included too. The exclusions do not detect all secrets. A snapshot does not push Git commits or restore a running agent session.
Rebuild commands must leave /home unchanged except for paths declared in metadata.rebuild_home_paths. These must be clean absolute paths. Rebuild commands regenerate those paths. Descendant interactive snapshots cannot save them.
Snapshot references and retention
| Context | Reference | Prefix identifies |
|---|---|---|
| Build input, fork, or publication | parent@sha256:<digest> |
Base parent of the captured snapshot |
| Runtime or failed-build inspection | producing-phase@sha256:<digest> |
Phase that produced the image and controls access |
A canonical digest is sha256: plus 64 lowercase hexadecimal digits. <digest> is a placeholder, not a usable digest. Prefer phase names for routine work.
To publish a captured snapshot for its existing target, use --from. This does not capture current files:
Snapshot history is not guaranteed to be retained indefinitely. Successful snapshots have no guaranteed retention period.
You can inspect up to three recent failed rebuild snapshots, listed newest first. Their estimated expiry is normally 24 hours after failure. See Inspect failed builds before the images expire.
Examples
tsh phase snapshot --final --format=json{
"name": "sdk-work",
"owner": "alice",
"strategy": "snapshot",
"parent": "app-config",
"state": "ready",
"image_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"region": "example-region",
"published_at": "2026-06-01T12:00:00Z"
}tsh phase snapshot sdk-work --from='app-config@sha256:<digest>'Apply a configuration
Use tsh phase apply -f phase.yaml to create or replace command and copy stages. Stages run in document order. The command waits for each stage to finish.
--region selects the region for new phases. --no-console suppresses command logs but still waits for completion. Progress goes to stderr. Structured results for completed stages go to stdout.
Reapplying a configuration preserves existing parents and strategies. Each stage runs once during application. Children being explicitly replaced do not also refresh automatically during application. Dependents outside the file still follow updates.
If a stage fails, later stages do not run. Completed stages remain saved. Applying a configuration is not an all-or-nothing transaction.
CLI parameters
| Parameter | Meaning |
|---|---|
-f path |
Local YAML configuration file. Stages run in document order. |
--region=region |
Region for new phases. Does not move existing images. |
--no-console |
Suppress log connection. The command still waits for its stages. |
--format |
Return structured results for the applied phases. |
YAML configuration reference
Each YAML document must contain either a nonempty commands list or files, not both. Use files: [] for an empty copy stage.
Separate documents with ---. Each stage must have a unique name. The first stage can omit metadata.from to use default:v1. Each later stage must name the immediately preceding stage as its parent.
| Field | Meaning / default |
|---|---|
version |
Authoring format version. Must be v1. |
metadata.name |
Phase name. Up to 54 characters. |
metadata.from |
Immutable parent. The first stage defaults to default:v1. Later stages must name the preceding stage. |
metadata.rebuild_home_paths |
Home paths that command stages may change. Use clean absolute paths, not globs. Applies only to command stages. |
commands |
Commands to run as root, in order. Command stages require a nonempty list. |
files |
Local file or directory mappings. Required for copy stages. |
files[].from |
Source for each mapping. Required. Relative paths resolve against the YAML directory. |
files[].to |
Destination for each mapping. Required. Use a clean absolute path outside /home. |
files[].comment |
Description of the copy. |
services |
Named startup programs saved in the image. |
Commands and services share these fields:
| Field | Meaning |
|---|---|
shell |
Shell script run with /bin/sh -ec. Cannot be combined with command or args. |
command |
Executable to run. Use instead of shell. |
args |
Argument list. No implicit shell expansion. |
comment |
Description displayed before a build command. Optional. |
env |
List of {name, value} environment overrides. |
workdir |
Working directory. Use a clean absolute path. Defaults to / for commands and /home/beams for services. |
Validation rejects unknown fields, malformed paths, duplicate names, and incompatible stage kinds. Encoded command configuration cannot exceed 32 KiB. Copied file bytes do not count toward that limit.
Two-stage example
Save the configuration below as phase.yaml. Create ./config/app.json relative to the YAML file’s directory. Applying the configuration installs tools and copies local files. Reading this page does not run it.
Apply the configuration. Running the commands below creates or replaces real phases.
Applying the configuration returns the completed stages in order. The CLI response below shows stdout only. Stage progress and command logs go to stderr.
Examples
version: v1
metadata:
name: app-tools
commands:
- comment: Install development tools
shell: apt-get update && apt-get install -y git curl python3
---
version: v1
metadata:
name: app-config
from: app-tools
files:
- from: ./config
to: /opt/app-config
services:
- name: prepare-config
type: pre-start
context: user
shell: cp /opt/app-config/app.json /home/beams/app.jsontsh phase apply -f phase.yaml --no-console --format=json[
{
"name": "app-tools",
"owner": "alice",
"strategy": "rebuild",
"parent": "default:v1",
"state": "ready",
"image_digest": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
"region": "example-region",
"published_at": "2026-06-01T11:00:00Z"
},
{
"name": "app-config",
"owner": "alice",
"strategy": "copy",
"parent": "app-tools",
"state": "ready",
"image_digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
"region": "example-region",
"published_at": "2026-06-01T11:05:00Z"
}
]Run command builds
Command builds run stored commands as root. They save successful output automatically. Use command stages in phase apply for a YAML configuration. To use a single raw configuration, supply --commands-file:
The raw file must contain exactly one YAML document with a nonempty commands list. Each command requires command. You can also supply args, comment, env, and workdir. The raw format has no shell shortcut. Optional services must use the executable form.
protected_paths is the raw equivalent of metadata.rebuild_home_paths. Validation rejects unknown fields and multiple documents.
Creation starts the build. Use the wait and log methods to observe completion. You do not need to take a snapshot after a successful command build.
CLI parameters
| Parameter | Meaning |
|---|---|
--commands-file=path |
Raw builder YAML. Must contain exactly one document with a nonempty list of executable commands. |
--no-console |
Return after the build beam is provisioned. Do not follow logs or wait for the build to finish. |
Examples
tsh phase add raw-tools --commands-file=raw-build.yaml
tsh phase edit raw-tools --commands-file=raw-build.yamlCopy files into a phase
Use file stages in phase apply for repeatable configuration. For a one-off copy, use --copy=/absolute/destination:local-source. Repeat --copy for each mapping:
Destinations must be outside /home. Directory copies merge without deleting unrelated parent files. A file destination ending in / keeps the local filename. Otherwise, the destination specifies the output filename.
A copy replacement starts from the current parent, not the previous copy layer. Include every file you want to retain. You cannot combine --copy with command input, forking, or phase edit --from.
The finish helper uploads files, captures a snapshot, publishes it, and ends the build. Creating a copy build alone does not upload or save files.
CLI parameters
| Parameter | Meaning |
|---|---|
--copy=destination:source |
Repeat for each local mapping. Destinations must be outside /home. Relative sources resolve against the local working directory. |
name (positional) |
New or existing phase name. phase edit replaces the copy layer from its current parent. |
Examples
tsh phase add app-files --copy=/opt/app/config:./config
tsh phase edit app-files --copy=/opt/app/config:./updated-configConfigure startup services
Save startup programs in the services list of a command or file stage. Apply the YAML with phase apply.
See the configuration fields and the parameters under Apply a configuration or Copy files into a phase.
Service lifecycle
| Field | Meaning / default |
|---|---|
name |
Service name. Reusing an inherited name replaces that service. |
type |
Defaults to background. |
context |
Selects the beam contexts that run the service. Defaults to user. |
Each service requires name and a shell script or executable. Use the shared command fields. Reusing an inherited name replaces the whole definition, including type and context.
Services run as beams. Command builds run their commands as root. Use explicit sudo only when a service needs elevated privileges.
Services with type: pre-start run in declaration order before background services. Use type: background for long-running programs. It is the default.
A pre-start failure is logged. The remaining services still run. In a command build, a pre-start failure fails the build before commands run. SSH remains available for diagnosis. To read service logs, use beamctl logs <service-name> inside the beam.
context |
Interactive snapshot build | Command build | Runtime beam |
|---|---|---|---|
user (default) |
Yes | No | Yes |
snapshot |
Yes | No | No |
rebuild |
No | Yes | No |
runtime |
No | No | Yes |
build |
Yes | Yes | No |
all |
Yes | Yes | Yes |
Copy builds never run services, including inherited services. They save the definitions for later beams.
Refresh a phase
Non-static phases refresh every 24 hours. They also refresh after a successful refresh of a non-static parent. The strategy determines what repeats:
| Strategy | Saved content | Refresh behavior |
|---|---|---|
STATIC |
Initial interactive or non-rebase-safe image | Does not refresh automatically. Cannot be the parent of a new phase. |
REBUILD |
Commands and their output | Reruns commands on the parent. |
SNAPSHOT |
Rebase-safe interactive filesystem layer | Applies saved changes to the parent. Does not replay interactive work. |
COPY |
Protected-path file layer | Applies saved changes to the parent. Does not run services during copying. |
An interactive phase starts with the static strategy. Publishing an eligible snapshot can change the strategy to snapshot or copy. Once a phase uses the copy strategy, it accepts only copy snapshots and replacements.
Saved child files override the corresponding parent files. A parent update can change the child’s digest even if you have not edited the child.
Automatic refresh needs no separate call and has no parameters. To rebuild command or copy configuration yourself, use phase edit or reapply the YAML. Use tsh phase ls to check the result.
See the replacement parameters or configuration parameters for your language.
If a build fails, the previous successful image stays usable when one exists. Dependents of a failed parent keep their images and wait. A phase with no successful image is not ready for runtime use.
Inspect phases and builds
Use tsh phase ls to list your phases. Add --all to list all phases you are authorized to access. Use tsh phase ls-failed [--all] to list retained failed-build snapshots for inspection. Both commands support --format=json and --format=yaml.
CLI parameters
| Parameter | Meaning / default |
|---|---|
--all |
List all phases you are authorized to access. Without this flag, list only your phases. This does not grant unrestricted access. |
--format |
Return structured results for phase ls and phase ls-failed. |
phase ls-failed |
List retained failed-build snapshots for inspection. |
Phase responses include build status and retained failed-build snapshots.
The listing helpers collect all pages and return a collection directly. They do not return ListPhasesResponse or a pagination token. Use get_phase(name) or getPhase(name) to get one phase directly, as in the saved-phase example.
CLI JSON uses a flattened, formatted resource.
Build states
| State | Meaning |
|---|---|
UNSPECIFIED |
No build has started |
BUILDING |
Build or refresh is active |
READY |
Most recent build succeeded |
FAILED |
Most recent build failed. An older image may remain usable. |
BLOCKED |
A usable image exists. Refresh is waiting for the parent. |
DELETING |
Cleanup is in progress. New work is prevented. |
Examples
tsh phase ls --all --format=json[
{
"name": "sdk-work",
"owner": "alice",
"strategy": "snapshot",
"parent": "app-config",
"state": "ready",
"image_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"region": "example-region",
"published_at": "2026-06-01T12:00:00Z"
}
]Start a beam from a phase
Use tsh beams add --phase=name to start a runtime beam from the phase’s latest successful image. Beams that are already running keep the image they started with.
If you start a runtime beam like that cannot save or fork its filesystem back to a phase. Use an interactive phase build using tsh phases add to get interactive snapshots and forks.
To inspect a saved or failed image, use tsh beams add --phase='producing-phase@sha256:<digest>'. An inspection beam cannot save its filesystem back to a phase.
You must be authorized to use the phase that produced the image. The image must have a valid recorded phase identity. The image must not have expired. Creating a new phase with a deleted phase’s name does not grant access to the deleted phase’s snapshots.
CLI parameters
| Parameter | Meaning |
|---|---|
--phase=name |
Phase name. The beam uses the phase’s latest successful image. You can also supply a saved-image reference. |
--no-console |
Create the beam without opening a shell. |
--format |
Return the beam’s identifiers as structured output. |
Creation returns a beam name. You’d need the name to connect to or delete the beam.
The CLI example creates the beam without opening a shell. To connect, use tsh beams ssh with the returned id (alias) or uuid.
Examples
tsh beams add --phase=sdk-work --no-console --format=json{
"id": "example-runtime",
"uuid": "example-runtime-beam",
"owner": "alice",
"expires": "2026-06-01T14:00:00Z",
"region": "example-region",
"phase": "sdk-work"
}Delete a phase
Deleging phase also deletes any active build beam.
You have to delete dependent phases first. You cannot delete a parent while dependent phases still use it. Deleting the build beam loses any unsaved work in the beam.
If you get a concurrent-change error, check whether deletion took effect before retrying.
CLI parameters
| Parameter | Meaning |
|---|---|
name |
Phase name to delete. Required. Delete dependent phases first. |
Examples
tsh phase rm sdk-workPhase "sdk-work" successfully deleted.