Skip to content

tld login & pull

View Markdown

tlDiagram keeps three things in sync: your local YAML files, the local app database, and the cloud server. This page covers authentication and pulling state down.

Every mutating command — add, connect, update, remove, view, import — applies to a target and then write-through updates your YAML cache. The target is resolved in this order:

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

Because commands apply immediately, there is no separate plan/apply step. Preview with --dry-run, and refresh YAML after browser edits with tld pull.

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 downloads the current state from the target and refreshes your local YAML files. Use it after making changes in the web editor.

Terminal window
tld pull

By default it does a surgical merge: updates existing resources and adds new ones without blindly overwriting local edits. If it detects uncommitted local changes it warns 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

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.