Skip to main content

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

uv Ruff Python 3.12+ License: MIT

Features โ€ข Installation โ€ข Quick Start โ€ข Examples โ€ข Documentation


[!TIP] Install as Claude Code Plugin

Step 1: Install the CLI tool

# Quick install (Linux/macOS)
curl -sSL https://raw.githubusercontent.com/langchain-ai/langsmith-cli/main/scripts/install.sh | sh

# Or use uv
uv tool install langsmith-cli

Step 2: Add the plugin to Claude Code

Option A: Terminal Command

claude plugin marketplace add gigaverse-app/langsmith-cli
claude plugin install langsmith-cli@langsmith-cli

Option B: Interactive UI Inside Claude Code, run /plugin (without arguments) and use the UI to add the marketplace

This gives Claude Code instant access to all LangSmith commands via skills.


context is all you need

๐ŸŽฏ 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 Dashboard runs watch real-time monitoring โŒ
Advanced Filters Regex, wildcards, time presets Basic only
Stratified Sampling runs sample by tag/metadata โŒ
Aggregate Analytics runs analyze group & metrics โŒ
Tag Discovery runs tags auto-discover patterns โŒ
File Operations View/analyze offline with globs โŒ
Export Formats JSON, CSV, YAML JSON only

100% Feature Parity + 10x Better QoL ๐Ÿš€


โœจ 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

Quick Install (Recommended)

Linux/macOS:

curl -sSL https://raw.githubusercontent.com/langchain-ai/langsmith-cli/main/scripts/install.sh | sh

Windows:

iwr -useb https://raw.githubusercontent.com/langchain-ai/langsmith-cli/main/scripts/install.ps1 | iex

This standalone installer:

  • Creates an isolated environment (no conflicts)
  • Automatically adds langsmith-cli to your PATH
  • Works without manually installing Python packages
  • Requires Python 3.12+

Using uv

uv tool install langsmith-cli

Using pip

pip install langsmith-cli

For Claude Code Users

After installing the CLI above, add the skill:

/plugin marketplace add gigaverse-app/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

[!NOTE] Prerequisites: Install CLI first (uv tool install langsmith-cli), then add skill (/plugin marketplace add gigaverse-app/langsmith-cli)

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 --json as first argument
  • Use --fields to reduce tokens by 90%+
  • Combine smart filters: --failed --recent --slow
  • Keep --limit small (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 --fields for 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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/awesome)
  3. Make your changes with tests
  4. Ensure 100% coverage for new code
  5. Run uv run pre-commit run --all-files
  6. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langsmith_cli-0.2.5.tar.gz (197.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langsmith_cli-0.2.5-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file langsmith_cli-0.2.5.tar.gz.

File metadata

  • Download URL: langsmith_cli-0.2.5.tar.gz
  • Upload date:
  • Size: 197.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langsmith_cli-0.2.5.tar.gz
Algorithm Hash digest
SHA256 1d10912d9d15367bf2d56edd4eb24f0a468dc61f79bf7842d2dedb89c8c402ee
MD5 bdf73849d39ea883f6dc42e7dc78e4f8
BLAKE2b-256 5384b13293d96d2a3ba719bd57ea9499fffcb378af47accf89c6ae5af674dc0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for langsmith_cli-0.2.5.tar.gz:

Publisher: publish.yml on gigaverse-app/langsmith-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langsmith_cli-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: langsmith_cli-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langsmith_cli-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5a4ad43a4648066e88a47b93ea9cd7b594a025bedeb61eefb3f568a90a596723
MD5 157b4fe88781aa0b0226d49f1f9274b3
BLAKE2b-256 ebc2aabdf7b7207635cd375ef00e350252ae985e6b8fdc3d42e36f9107f61e15

See more details on using hashes here.

Provenance

The following attestation bundles were made for langsmith_cli-0.2.5-py3-none-any.whl:

Publisher: publish.yml on gigaverse-app/langsmith-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page