Skip to content

tld CRUD Commands

View Markdown

Commands apply immediately to the resolved target. YAML is refreshed only when a workspace is detected or --yaml is used. Run tld context to check the destination.

Target mutations accept:

FlagWhat it does
--target auto|local|remote|cloudWhere the change applies. auto picks remote when api_key and org_id are set, otherwise local.
--data-dirData directory for local target state.
--dry-runPreview the change without applying it; target reads may still occur.

See login, sync & pull for how targets resolve.

Create or update an element. Upsert semantics: running it twice is safe.

Terminal window
# Minimal
tld add my-service
# With workspace refs and metadata
tld init
tld add api-gateway
tld add payment-svc \
--ref payment-svc \
--kind service \
--description "Handles payment processing" \
--technology Go \
--parent api-gateway \
--position-x 100 \
--position-y 200 \
--tags payments,critical \
--view-label "Payments"
FlagDescription
--kindOptional kind metadata, e.g. service or database
--descriptionShort description
--technologyPrimary technology (normalized against the catalog)
--url, --logo-urlExternal and logo URLs
--linkSource file, folder, or anchor, e.g. internal/api.go#Handle
--tagsComma-separated tags
--position-x, --position-yCanvas position
--refWorkspace-only alias (default: slugified name); requires YAML mode
--parentParent element ref (default root)
--view-labelLabel for the diagram created when this element becomes a parent
--dry-run, --target, --data-dirSee above

Create a connector between two elements.

Terminal window
tld connect --from api-gateway --to auth-svc --label "authenticates"
tld connect \
--from api-gateway \
--to payment-svc \
--label "processes payments" \
--relationship calls \
--direction forward \
--tags payments
FlagDescription
--fromSource element ref (required)
--toTarget element ref (required)
--labelEdge label
--descriptionLonger description
--relationshipSemantic type (e.g. calls, publishes, queries)
--directionforward, backward, both, or none (default forward)
--urlExternal URL
--tagsComma-separated tags
--viewExplicit connector view (default: source element’s view)
--no-repositionKeep the newly connected target element’s position
--dry-run, --target, --data-dirSee above
Terminal window
# Remove an element
tld remove element payment-svc
# Remove a connector
tld remove connector --view root --from api-gateway --to auth-svc

Removing an element cleans up all connectors that reference it and its owned view. Removal runs against the target (--target, --dry-run, --data-dir supported).

Change a specific field.

Terminal window
# Element field
tld update element api-gateway description "Routes external requests to internal services"
# Connector field
tld update connector 'root/api-gateway~auth-svc/authenticates' label "validates JWT"
# Tags: append or remove instead of replacing
tld update element payment-svc tags critical --append
tld update element payment-svc tags legacy --remove

--append and --remove are only valid with the tags field. Updating ref also moves the element’s metadata.

Use the exact key from tld list connectors: view/source~target[/label]. Numeric IDs also work.

  • root/api-gateway~auth-svc — unlabeled connector in the root view
  • root/api-gateway~auth-svc/calls — connector labeled calls

tld rename is deprecated. Change a display name in either mode, or a workspace-local ref in YAML mode:

Terminal window
tld update element payment-svc name "Payments"
tld update element payment-svc ref payments

Ref changes update YAML references only; the persisted element ID stays the same.

Link an element to source or an external URL:

Terminal window
tld link api-gateway cmd/gateway/main.go#main
tld link api-gateway --external https://example.com/api
tld link --next

Use --unlink to clear a link or --dry-run to preview it.

Views are the drill-down diagrams owned by elements. An element has a view when has_view is true.

Terminal window
# Create (or ensure) the view owned by an element
tld view create api-gateway --name "API Gateway" --label Container
# Rename it
tld view rename api-gateway "Gateway"
# Set its level label
tld view set-level api-gateway Container
# Place an existing element, move it, or remove just its placement
tld view place api-gateway payment-svc
tld view place root payment-svc --from api-gateway
tld view unplace root payment-svc
# Delete it (the element is kept; the view must be empty)
tld view delete api-gateway

The owning element must already exist — create it first with tld add. Remove or update affected connectors before moving/unplacing endpoints. view delete requires an empty view.

Bulk add or update elements and connectors from a file, atomically.

Terminal window
tld import diagrams.yaml
cat diagrams.yaml | tld import -

The file is YAML or JSON with a top-level elements: map and connectors: list. Existing items are matched and updated atomically; omitted resources and placements are preserved. Use tld import --schema for accepted fields. Connector tags require tld update connector.

FlagWhat it does
--dry-runValidate and report changes without applying
--target, --data-dirSee above

All commands support --format json (and --compact):

Terminal window
tld add my-service --format json
# {"command":"add","status":"ok","items":[{"ref":"my-service","action":"add","resource_type":"element"}]}
tld import diagrams.yaml --format json
# {"command":"import","status":"ok","summary":{"elements_created":3,"connectors_created":2}}