Context-efficient CLI for LangSmith. Built for humans and agents.
Project description
๐ ๏ธ LangSmith CLI
The Modern CLI for LangSmith Lightning-fast โข Context-efficient โข Built for humans and AI agents
Features โข Installation โข Quick Start โข Examples โข Documentation
๐ฏ Why LangSmith CLI?
Traditional tools are slow, verbose, and waste tokens. LangSmith CLI is different:
| Feature | LangSmith CLI | Official MCP Server |
|---|---|---|
| Startup Time | < 100ms (lazy loading) | ~2s (heavy imports) |
| Context Usage | 96% reduction with --fields |
Full objects always |
| Human UX | Rich tables with colors | JSON only |
| Agent UX | Strict --json mode |
Mixed output |
| Live Updates | runs watch dashboard |
โ |
| Advanced Filters | Regex, wildcards, smart presets | Basic only |
| Export Formats | JSON, CSV, YAML | JSON only |
100% Feature Parity + Superior Quality of Life ๐
โจ Features
๐๏ธ Performance First
- <100ms startup via lazy-loaded imports
- Streams large datasets without memory bloat
- Async-ready architecture
๐ง Agent Optimized
# Traditional: Returns 20KB trace object (1000+ tokens)
langsmith-cli runs get abc123
# Agent Mode: Returns only what you need (40 tokens)
langsmith-cli --json runs get abc123 --fields inputs,outputs,error
96% context savings on large traces!
๐จ Human Friendly
- Beautiful Rich tables with syntax highlighting
- Color-coded statuses (๐ข success, ๐ด error, ๐ก pending)
- Smart column truncation for readability
- Export to CSV/YAML for spreadsheets
๐ Power User Features
# Regex filtering
langsmith-cli runs list --name-regex "^prod-.*-v[0-9]+"
# Wildcard patterns
langsmith-cli runs list --name-pattern "*auth*"
# Smart filters
langsmith-cli runs list --slow --failed --today
# Live dashboard
langsmith-cli runs watch
๐ฆ Complete Coverage
Every LangSmith resource at your fingertips:
- โ Projects - List, create, inspect
- โ Runs - Search, stats, watch, open in browser
- โ Datasets - CRUD + bulk JSONL uploads
- โ Examples - Full lifecycle management
- โ Prompts - Version control your prompts
๐ Installation
Using uv (Recommended)
uv tool install langsmith-cli
Using pip
pip install langsmith-cli
From Source
git clone https://github.com/gigaverse-app/langsmith-cli.git
cd langsmith-cli
uv sync
uv run langsmith-cli --help
๐ Quick Start
1๏ธโฃ Authenticate
langsmith-cli auth login
# Creates .env with your LANGSMITH_API_KEY
2๏ธโฃ Explore Your Projects
langsmith-cli projects list
โโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโณโโโโโโโโโโโโโโโ
โ Project โ Run Count โ Last Run โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ production โ 12,450 โ 2 mins ago โ
โ staging โ 3,241 โ 15 mins ago โ
โ development โ 892 โ 1 hour ago โ
โโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
3๏ธโฃ Inspect Recent Runs
langsmith-cli runs list --project production --limit 5
4๏ธโฃ Debug Errors Fast
langsmith-cli runs list --failed --recent --fields error
๐ก Examples
๐ Advanced Filtering
Find authentication runs that failed in the last hour:
langsmith-cli runs list \
--name-pattern "*auth*" \
--failed \
--recent
Search for specific versioned services:
langsmith-cli runs list \
--name-regex "^prod-api-v[0-9]+" \
--min-latency 5s \
--today
Multi-tag filtering (AND logic):
langsmith-cli runs list \
--tag production \
--tag experimental \
--slow
๐ Aggregated Insights
langsmith-cli runs stats --project production
{
"run_count": 12450,
"error_rate": 0.023,
"latency_p50": 0.234,
"latency_p99": 1.892,
"total_cost": 45.67,
"last_run_time": "2026-01-14T20:15:30Z"
}
๐ด Live Monitoring
langsmith-cli runs watch --project production
๐ด Live Dashboard (Ctrl+C to exit)
โโโโโโโโโโโโโโโโโโโโณโโโโโโโโโณโโโโโโโโโโโณโโโโโโโโโโโ
โ Run โ Status โ Latency โ Time โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ ChatOpenAI โ ๐ข โ 0.234s โ Just now โ
โ RetrievalChain โ ๐ข โ 1.456s โ 2s ago โ
โ AuthService โ ๐ด โ 5.123s โ 5s ago โ
โ WebScraper โ ๐ก โ - โ 8s ago โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโ
๐พ Bulk Dataset Uploads
# Export examples to JSONL
langsmith-cli --json examples list --dataset my-dataset > examples.jsonl
# Upload to new dataset
langsmith-cli datasets push examples.jsonl --dataset production-eval
๐ Open in Browser
langsmith-cli runs open <run-id>
# Opens trace in LangSmith UI
๐ค Export for Analysis
# Export to CSV for Excel
langsmith-cli runs list --format csv > runs.csv
# Export to YAML for configs
langsmith-cli projects list --format yaml > projects.yml
๐ค AI Agent Integration
As a Claude Code Skill
The CLI is optimized for Claude Code agents:
# In Claude Code, agents can run:
langsmith-cli --json runs list --project default --limit 10 --fields inputs,outputs,error
# Returns clean JSON without Rich formatting
# Uses --fields to minimize context usage
# Filters with --failed, --slow, --recent for targeted debugging
Key Agent Patterns:
- Always use
--jsonas first argument - Use
--fieldsto reduce tokens by 90%+ - Combine smart filters:
--failed --recent --slow - Keep
--limitsmall (default: 10)
Example Agent Usage
import subprocess
import json
# Agent efficiently fetches only errored runs
result = subprocess.run(
["langsmith-cli", "--json", "runs", "list",
"--failed", "--limit", "5", "--fields", "error,inputs"],
capture_output=True,
text=True
)
runs = json.loads(result.stdout)
# Analyze errors with minimal context usage
๐ Documentation
Command Reference
langsmith-cli --help
# Core Commands
auth login # Authenticate with LangSmith
projects list # List all projects
runs list # Search and filter runs
runs get <id> # Inspect a specific run
runs stats # Aggregate statistics
runs watch # Live run dashboard
runs open <id> # Open trace in browser
datasets list # List datasets
datasets create # Create new dataset
datasets push # Bulk upload from JSONL
examples list # List dataset examples
examples create # Add example to dataset
prompts list # List prompt repositories
prompts get # Pull a prompt template
prompts push # Push local prompt to LangSmith
Global Flags
--json # Machine-readable JSON output (no Rich formatting)
--format {json|csv|yaml} # Export format
--help # Show help
--version # Show version
Runs Filtering
| Option | Description | Example |
|---|---|---|
--project |
Filter by project | --project production |
--status |
Filter by status | --status error |
--failed |
Only failed runs | --failed |
--succeeded |
Only successful runs | --succeeded |
--slow |
Runs >5s latency | --slow |
--recent |
Last hour | --recent |
--today |
Today's runs | --today |
--min-latency |
Min latency | --min-latency 2s |
--max-latency |
Max latency | --max-latency 10s |
--since |
Since time | --since "1 hour ago" |
--last |
Last duration | --last 24h |
--tag |
Filter by tag (repeatable) | --tag prod --tag beta |
--name-pattern |
Wildcard match | --name-pattern "*auth*" |
--name-regex |
Regex match | --name-regex "^prod-.*" |
--model |
Filter by model | --model gpt-4 |
๐๏ธ Architecture
Design Principles
1. Lazy Loading Performance
# โ Don't import heavy libraries at top level
from langsmith import Client
# โ
Import inside command functions
@runs.command("list")
def list_runs(...):
import langsmith # Only loads when command executes
client = langsmith.Client()
2. Context Efficiency
- Default JSON output is "sparse" (only essential fields)
- Field pruning with
--fieldsfor targeted data extraction - No full trace blobs unless explicitly requested
3. Dual UX Pattern
# Check JSON flag for output mode
if ctx.obj.get("json"):
click.echo(json.dumps(data)) # Strict JSON for agents
else:
console.print(rich_table) # Beautiful tables for humans
4. DRY Utilities
- Shared helpers in
utils.py(100% test coverage) - Consistent error handling with field context
- Reusable filtering, sorting, and formatting functions
๐งช Development
Setup
# Clone and setup
git clone https://github.com/gigaverse-app/langsmith-cli.git
cd langsmith-cli
uv sync
# Install pre-commit hooks
uv run pre-commit install
Testing
# Run all tests
uv run pytest
# With coverage
uv run pytest --cov=src --cov-report=term-missing
# E2E tests (requires LANGSMITH_API_KEY)
export LANGSMITH_API_KEY="lsv2_..."
uv run pytest tests/test_e2e.py -v
Code Quality
# Linting and formatting
uv run ruff check --fix
uv run ruff format
# Type checking
uv run pyright
Project Stats
- 79% Test Coverage (116 tests)
- 100% Utils Coverage (47 tests for helpers)
- Zero Type Errors (Pyright clean)
- 100% MCP Parity (13/13 tools)
๐ค Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/awesome) - Make your changes with tests
- Ensure 100% coverage for new code
- Run
uv run pre-commit run --all-files - Submit a pull request
๐ License
MIT License - see LICENSE for details.
๐ Acknowledgments
Built with:
- Click - CLI framework
- Rich - Terminal formatting
- LangSmith SDK - Official Python client
- uv - Fast Python package installer
Made with โค๏ธ for the LangChain community
Report Bug โข Request Feature โข Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langsmith_cli-0.1.6.tar.gz.
File metadata
- Download URL: langsmith_cli-0.1.6.tar.gz
- Upload date:
- Size: 136.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c49de200476e6620cee2342015d8087e8ef2873fe3f8f2d109c3f108f0cf3699
|
|
| MD5 |
7aac542f2d7e904d296119db9e02cd08
|
|
| BLAKE2b-256 |
35fea693272a3da4b36b2af1c60fa7ec925b4352a24b200ed3a308080bae2ea4
|
Provenance
The following attestation bundles were made for langsmith_cli-0.1.6.tar.gz:
Publisher:
publish.yml on gigaverse-app/langsmith-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langsmith_cli-0.1.6.tar.gz -
Subject digest:
c49de200476e6620cee2342015d8087e8ef2873fe3f8f2d109c3f108f0cf3699 - Sigstore transparency entry: 823077246
- Sigstore integration time:
-
Permalink:
gigaverse-app/langsmith-cli@bef517a02b630de6a0397e7df41c58c797c88e45 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/gigaverse-app
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bef517a02b630de6a0397e7df41c58c797c88e45 -
Trigger Event:
push
-
Statement type:
File details
Details for the file langsmith_cli-0.1.6-py3-none-any.whl.
File metadata
- Download URL: langsmith_cli-0.1.6-py3-none-any.whl
- Upload date:
- Size: 26.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
673495bc55f5c5dc1a44facc8ffb85929a399bb9f9aa1308d72092c3cf2c8386
|
|
| MD5 |
b2591e3c3ce0bafaeaf8bdf884885165
|
|
| BLAKE2b-256 |
d118f63012e7c4dcc37f93679aec4ca5861e3c2611b0ed4da56f22883e23e0ac
|
Provenance
The following attestation bundles were made for langsmith_cli-0.1.6-py3-none-any.whl:
Publisher:
publish.yml on gigaverse-app/langsmith-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langsmith_cli-0.1.6-py3-none-any.whl -
Subject digest:
673495bc55f5c5dc1a44facc8ffb85929a399bb9f9aa1308d72092c3cf2c8386 - Sigstore transparency entry: 823077277
- Sigstore integration time:
-
Permalink:
gigaverse-app/langsmith-cli@bef517a02b630de6a0397e7df41c58c797c88e45 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/gigaverse-app
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bef517a02b630de6a0397e7df41c58c797c88e45 -
Trigger Event:
push
-
Statement type: