@leangetic-ai/cli
v0.4.0
Published
Turn your AI agent into a cheaper hybrid: map steps to deterministic code, tune the AI (cache/compaction/routing), judge cheaper+equal-or-better on your traffic, switch over in one command.
Maintainers
Readme
Leangetic CLI
The Leangetic CLI is the local collector and client for the Leangetic cloud compiler. It scans your agent, gathers evidence, ships an optimization job to the Leangetic cloud, and lets you apply and verify the optimized package before you promote it.
Learn more at leangetic.com.
Requirements
- Node.js 18+ (to run the CLI wrapper via
npx). - Python 3 on your
PATH. The wrapper invokespython3(orpython). If Python lives somewhere non-standard, setLEANGETIC_PYTHONto its full path, e.g.export LEANGETIC_PYTHON=/usr/local/bin/python3.11.
Install / run
No global install needed — run it on demand with npx:
npx @leangetic-ai/cli --help
npx @leangetic-ai/cli --versionOr install it as a project/dev dependency and call leangetic directly:
npm install --save-dev @leangetic-ai/cli
npx leangetic --helpCommands
Run npx @leangetic-ai/cli <command> --help for the full flag list of any
command.
Account
# Create an account
npx @leangetic-ai/cli signup --api-url https://api.leangetic.com \
--email [email protected] --password '<password>'
# Log in (email/password or an existing API key)
npx @leangetic-ai/cli login --api-url https://api.leangetic.com \
--email [email protected] --password '<password>'
# Check your remaining credits
npx @leangetic-ai/cli creditsScan and assess
# Scan an agent and build an evidence bundle
npx @leangetic-ai/cli scan ./agents/support-agent \
--tasks ./leangetic-tasks.json \
--traces ./leangetic-traces \
--entrypoint 'python agent.py'
# Check whether the bundle is ready to optimize
npx @leangetic-ai/cli readiness .leangetic/bundle.jsonOptimize, apply, verify
# Send the optimization job to the Leangetic cloud compiler
npx @leangetic-ai/cli optimize ./agents/support-agent \
--tasks ./leangetic-tasks.json \
--traces ./leangetic-traces \
--entrypoint 'python agent.py'
# Apply an optimized package onto your agent
npx @leangetic-ai/cli apply .leangetic/artifacts/<package> \
--target ./agents/support-agent
# Verify the optimized package against the original — and measure real
# original-vs-optimized behavior, cost, latency, and equivalence
npx @leangetic-ai/cli verify \
--against ./agents/support-agent \
--package .leangetic/artifacts/<package> \
--measure --tasks ./leangetic-tasks.jsonAlways run verify --measure before promoting an optimized package to confirm
equivalence and the cost/latency gains.
Optimize at the per-call level (optional, advanced)
The flow above wraps your whole agent with a safe exact-input cache. The
per-call engine goes deeper: it intercepts each individual model call, so it can
also win on non-repeating inputs (prompt-cache compaction), verified routing
to a cheaper model tier, and exact-cache reuse. It defaults to SHADOW (it
measures what each optimization would save and never changes your output);
ACTIVE applies only the safe, proven-equivalent wins. It fails open — any error
or missing SDK falls back to your original call — and a kill switch
(LEANGETIC_ENGINE=off) disables it entirely.
Because the wrap package runs your agent as a subprocess, the engine cannot inject itself for you. Adopt it one of two honest ways:
# 1) Python, in-process (one line). Download the engine next to your agent:
curl -fsSL https://leangetic.com/downloads/leangetic_engine.py -o leangetic_engine.py
# then add this as the FIRST line of your agent entrypoint:
# import leangetic_engine as e; e.install()
# 2) Any language: reverse proxy + ANTHROPIC_BASE_URL (no code change):
curl -fsSL https://leangetic.com/downloads/leangetic_engine.py -o leangetic_engine.py
curl -fsSL https://leangetic.com/downloads/leangetic_proxy.py -o leangetic_proxy.py
python leangetic_proxy.py --port 8788
export ANTHROPIC_BASE_URL=http://127.0.0.1:8788 # then run your agent as usualRun your agent, then read the honest, measured savings ledger:
npx @leangetic-ai/cli engine-reportThe Python one-liner only intercepts calls made through the Anthropic Python
SDK; agents that shell out to a subscription CLI are measured-but-not-intercepted
in-process — use the proxy for those. See docs/PER_CALL_ENGINE.md for the five
phases, SHADOW vs ACTIVE, and the promote ratchet.
License
Proprietary. See LICENSE and the Leangetic terms.
