Managing LangGraph Cloud deployments through listing, filtering, and cleanup operations...
Manage LangGraph Cloud deployments using the Langstar CLI with focus on test deployment cleanup, filtering, and environment handling.
LangSmith API:
LANGSMITH_API_KEY - API key for Control Plane authenticationLANGSMITH_WORKSPACE_ID - Workspace ID (optional if using organization)Location: /workspace/.devcontainer/.env (gitignored)
All operations use langstar graph commands:
langstar graph list - List with filteringlangstar graph get <id> - Get detailslangstar graph delete <id> - Delete deploymentAlways check if credentials exist BEFORE sourcing:
# ā
CORRECT: Check first
if [ -z "$LANGSMITH_API_KEY" ] || [ -z "$LANGSMITH_WORKSPACE_ID" ]; then
echo "š Sourcing credentials..."
source /workspace/.devcontainer/.env
fi
# Verify (never expose actual values)
[ -n "$LANGSMITH_API_KEY" ] && echo "ā LANGSMITH_API_KEY set" || echo "ā Not set"
Security Rule: Never expose credential values:
# ā WRONG: Exposes sensitive data
echo "Key: $LANGSMITH_API_KEY"
# ā
CORRECT: Only check presence
[ -n "$LANGSMITH_API_KEY" ] && echo "Set" || echo "Not set"
# Source credentials if needed
if [ -z "$LANGSMITH_API_KEY" ]; then
source /workspace/.devcontainer/.env
fi
# List deployments
langstar graph list --limit 20
Output:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāā
ā Name ā ID ā Status ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāā¤
ā langstar-test-1763668434 ā 97dff6a5-f844-472... ā Ready ā
ā test-deployment-1763666536 ā 8665a96b-4620-407... ā Ready ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāā
# Source credentials
if [ -z "$LANGSMITH_API_KEY" ]; then
source /workspace/.devcontainer/.env
fi
# Filter by substring
langstar graph list --name-contains "test"
langstar graph list --name-contains "langstar-test"
# Combine filters
langstar graph list --name-contains "test" --status READY --limit 100
# Source credentials
if [ -z "$LANGSMITH_API_KEY" ]; then
source /workspace/.devcontainer/.env
fi
# Interactive deletion (prompts for confirmation)
langstar graph delete <deployment-id>
# Skip confirmation
langstar graph delete <deployment-id> --yes
Recommended: Interactive review before each deletion
# Source credentials
if [ -z "$LANGSMITH_API_KEY" ]; then
source /workspace/.devcontainer/.env
fi
# List test deployments to review
langstar graph list --name-contains "test" --limit 100
# Get deployment IDs
deployment_ids=$(langstar graph list --name-contains "test" --limit 100 --format json | jq -r '.resources[].id')
# Delete with confirmation for each
for id in $deployment_ids; do
echo "Deployment: $id"
langstar graph get "$id" | jq '{name, status, created_at}'
read -p "Delete? (y/n): " confirm
[ "$confirm" = "y" ] && langstar graph delete "$id" --yes && echo "ā Deleted"
done
Alternative: Bulk deletion (use with caution)
See examples/batch-cleanup.md for non-interactive scripts.
Available filters:
READY, AWAITING_DATABASE, UNUSED, AWAITING_DELETEdev_free, dev, prod# Source credentials
if [ -z "$LANGSMITH_API_KEY" ]; then
source /workspace/.devcontainer/.env
fi
# Filter by status
langstar graph list --status READY
langstar graph list --status UNUSED
# Filter by type
langstar graph list --deployment-type dev_free
# Combine filters
langstar graph list --name-contains "test" --status READY
langstar graph list [OPTIONS]
Options:
-l, --limit <N> Max to return [default: 20]
--offset <N> Pagination offset [default: 0]
--name-contains <STR> Filter by name substring
--status <STATUS> Filter: READY, AWAITING_DATABASE, UNUSED, etc.
--deployment-type <TYPE> Filter: dev_free, dev, prod
-f, --format <FORMAT> Output: text, json [default: text]
langstar graph get <DEPLOYMENT_ID>
Returns full deployment JSON including source config, status, timestamps, and revisions.
langstar graph delete <DEPLOYMENT_ID> [OPTIONS]
Options:
-y, --yes Skip confirmation prompt
ā Check before sourcing
if [ -z "$LANGSMITH_API_KEY" ]; then
source /workspace/.devcontainer/.env
fi
ā Never expose values
[ -n "$LANGSMITH_API_KEY" ] && echo "ā Set" || echo "ā Not set"
ā Review before deleting
# List first, verify, then delete
langstar graph list --name-contains "test"
langstar graph delete <id> --yes
ā Interactive confirmation for batch
# Confirm each deletion
for id in $ids; do
read -p "Delete $id? (y/n): " confirm
[ "$confirm" = "y" ] && langstar graph delete "$id" --yes
done
ā Use specific patterns
# Specific reduces false matches
langstar graph list --name-contains "langstar-test-"
ā Combine filters for precision
langstar graph list --name-contains "test" --status READY --deployment-type dev_free
# Source credentials
if [ -z "$LANGSMITH_API_KEY" ]; then source /workspace/.devcontainer/.env; fi
# List test deployments
langstar graph list --name-contains "langstar-test"
langstar graph list --name-contains "test-deployment"
# Delete each
langstar graph delete <id-1> --yes
langstar graph delete <id-2> --yes
# Source credentials
if [ -z "$LANGSMITH_API_KEY" ]; then source /workspace/.devcontainer/.env; fi
# List unused
langstar graph list --status UNUSED --limit 100
# Review and delete manually
langstar graph list --limit 100 --format json | \
jq '.resources[] | select(.status == "UNUSED") | {name, id, created_at, status}'
# Source credentials
if [ -z "$LANGSMITH_API_KEY" ]; then source /workspace/.devcontainer/.env; fi
# Filter by username/CI prefix
langstar graph list --name-contains "alice-"
langstar graph list --name-contains "ci-build-"
langstar graph list --name-contains "pr-"
Diagnosis:
[ -n "$LANGSMITH_API_KEY" ] && echo "Set" || echo "Not set"
[ -n "$LANGSMITH_WORKSPACE_ID" ] && echo "Set" || echo "Not set"
Solution:
source /workspace/.devcontainer/.env
# Verify
[ -n "$LANGSMITH_API_KEY" ] && echo "Set" || echo "Not set"
Cause: Deployment deleted or incorrect ID.
Solution:
# Verify ID from list
langstar graph list --limit 100
langstar graph list --name-contains "<name-fragment>"
Solution:
# Try without filters
langstar graph list --limit 100
# Try broader patterns
langstar graph list --name-contains "test"
sdk/src/deployments.rs - Full API clientcli/src/commands/graph.rs - ImplementationClean up after test runs:
# After integration tests
cd /workspace/wip/<worktree-name>
if [ -z "$LANGSMITH_API_KEY" ]; then source /workspace/.devcontainer/.env; fi
langstar graph list --name-contains "langstar-test"
Works in any location - credentials source the same:
# Works in main or worktree
cd /workspace
# or
cd /workspace/wip/claude-188-deployment-management
# Source once
if [ -z "$LANGSMITH_API_KEY" ]; then source /workspace/.devcontainer/.env; fi
langstar graph list
if [ -z "$LANGSMITH_API_KEY" ] || [ -z "$LANGSMITH_WORKSPACE_ID" ]; then
source /workspace/.devcontainer/.env
fi
[ -n "$LANGSMITH_API_KEY" ] && echo "ā" || echo "ā"
if [ -z "$LANGSMITH_API_KEY" ]; then source /workspace/.devcontainer/.env; fi
langstar graph list --name-contains "test" --limit 100
if [ -z "$LANGSMITH_API_KEY" ]; then source /workspace/.devcontainer/.env; fi
for id in $(langstar graph list --name-contains "test" --format json | jq -r '.resources[].id'); do
langstar graph get "$id" | jq '{name, status, created_at}'
read -p "Delete? (y/n): " confirm
[ "$confirm" = "y" ] && langstar graph delete "$id" --yes
done