Skip to content

tld login, sync & pull

View Markdown

CLI commands use one target at a time: the local database or cloud server. YAML workspaces are optional; sync pushes YAML to the target and pull refreshes it from the target.

Resource mutations apply to a target and refresh the YAML cache when present. Select the target as follows:

TargetBehavior
autoRemote when api_key and org_id are set, otherwise local. Default.
localThe local app database, no cloud.
remote (alias cloud)The tlDiagram cloud server.

Override per command with --target, or set a default in global config:

Terminal window
tld config set apply.target local

Ordinary mutations apply immediately. Preview with --dry-run; use tld context to check the destination.

tld login authenticates the CLI with a tlDiagram server using a device-code flow and writes the resulting key to your global config.

Terminal window
tld login

It prints a verification URL and a short code. Open the URL (or the browser opens automatically), enter the code, and the CLI polls until you approve. On success it writes server_url, api_key, and org_id to tld.global.yaml.

Terminal window
# Print the URL instead of opening a browser
tld login --no-browser

tld pull refreshes YAML from the target after browser edits. Run tld init first, or specify an export directory with --workspace.

Terminal window
tld pull

Pull can overwrite local YAML edits. If it detects changes since the last sync, it prompts first:

Local workspace has uncommitted changes. Pull will overwrite them.
Continue? [yes/no]:
FlagWhat it does
--forceOverwrite local changes without prompting
--dry-runShow what would be pulled without writing
--target localPull from the local app database
--target remotePull from the cloud server
--data-dirData directory for local target state

Remote pulls require a configured API key and an org_id in global config — both are written by tld login.

Terminal window
tld pull --dry-run
# Would pull: 42 elements, 12 diagrams, 35 connectors
tld pull
# Pulled 42 elements, 12 diagrams, 35 connectors

Apply hand-edited workspace YAML to the target in one transaction:

Terminal window
tld sync --dry-run
tld sync --target local
# Or: tld sync --target remote

Existing resources are matched and updated. Sync YAML edits before running another mutation that refreshes the cache.

After a successful pull, .tld.lock records the new sync point: the version, a hash of the workspace, resource counts, and per-resource metadata. It’s how tld knows what changed since the last sync. Don’t edit it by hand.

Commit your .tld/ directory so element and connector definitions travel with the code. Keep machine-specific state — credentials, local server settings, data directory — in global config, which stays on your machine.