sft
The Swiss army knife for
.safetensorsfiles.
sft is a single-binary CLI for inspecting, editing, and diffing .safetensors files — and an interactive terminal browser for poking around large checkpoints. Most commands read the file header only, so multi-gigabyte models open in milliseconds.
It also ships a skill that teaches AI coding agents (Claude Code, Cursor, Codex CLI) when to reach for it and how to parse the output.
Install
uv tool install sft-cli # recommended
pip install sft-cli # or pip
uv tool install 'sft-cli[torch]' # + .pt/.pth conversion
🚀 Quick start
sft model.safetensors # open the interactive browser
sft info model.safetensors # one-shot summary
sft info model.safetensors --json # machine-readable
The bare sft <file> form is a shortcut for sft browse <file>. Inside the browser: ↑↓ to navigate, / to filter, L on a LoRA file for LoRA Mode, D to diff against another file, q to quit.
What it does
Inspect a file without loading it:
sft info model.safetensors # size, tensor count, dtypes, metadata
sft ls model.safetensors # flat list, sort/filter friendly
sft tree model.safetensors --depth=2 # hierarchical view
sft stat model.safetensors # per-tensor mean/std/min/max/sparsity
sft check model.safetensors # corruption + NaN/Inf scan
Compare two checkpoints:
sft diff base.safetensors finetuned.safetensors --delta \
--include='**.self_attn.**' # cosine, L2, max-abs per tensor
Edit without writing Python:
sft slice big.safetensors --include='**.weight' -o weights-only.safetensors
sft strip big.safetensors --exclude='*lora_*'
sft cast model.safetensors --dtype fp16
sft cat a.safetensors b.safetensors -o merged.safetensors
sft rename model.safetensors --sub 'model\.' 'backbone.'
sft split model.safetensors --max-size 4GB
sft convert pytorch_model.bin # → safetensors
Every write command supports --dry-run and never overwrites the input — outputs default to {stem}.{suffix}.safetensors.
Adapter workflows (PEFT and Kohya):
sft lora info adapter.safetensors # rank, alpha, target modules
sft lora svd adapter.safetensors # singular-value spectrum
sft lora compat base.safetensors adapter.safetensors
sft lora extract base.safetensors ft.safetensors --rank 16
sft lora resize adapter.safetensors --rank auto # per-pair adaptive rank
sft lora stack a.safetensors b.safetensors -a 0.7 -b 0.3
sft lora merge base.safetensors adapter.safetensors
sft lora convert adapter.safetensors --to peft # Kohya ↔ PEFT
--rank auto picks each pair's output rank from its singular-value spectrum (ceil(stable_rank) + 1), so over-parameterized pairs compress harder than rich ones. auto+N adds a safety margin.
The browser
Press a key, get a result.
| Key | Action |
|---|---|
↑ ↓ |
Navigate |
← → |
Collapse / expand tree |
Tab |
Switch between tree and table |
/ |
Search / filter |
s |
Cycle sort |
Enter |
Tensor stats popup |
m |
File metadata |
c |
Cast file dtype |
L |
LoRA Mode (per-pair stats, SVD, compress) |
D |
Diff against another file |
: |
Command palette |
q |
Quit |
🤖 AI agents
sft skill install # auto-detects Claude / Cursor / Codex
sft skill status
sft skill uninstall
The installer symlinks sft's skill into your agent's well-known skills directory (~/.claude/skills/sft, ~/.cursor/skills/sft, etc.), so it stays in sync when you uv tool upgrade sft-cli. Pass --mode copy for a frozen snapshot.
Every command supports --json for clean parsing:
sft info model.safetensors --json | jq '.tensors'
sft lora info adapter.safetensors --json | jq '.rank'
sft stat model.safetensors --json --include='**.q_proj.*'
License
MIT — see LICENSE.
Release files for sft-cli 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sft_cli-0.2.2.tar.gz | 195.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sft_cli-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 298.4 kB
Release files / sft_cli-0.2.2.tar.gz
| Download URL | sft_cli-0.2.2.tar.gz |
|---|---|
| Size | 195.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a56fd13f887c99146cac85041b0d159b59e4769f236a0dd7136621d722d815e6
|
|
BLAKE2b-256 checksum How to use checksums |
b906dbeeb1eabaa3ea5acf7278d40b61e08143bf8085e68ad6577f55af2121f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.
Transparency logRelease files / sft_cli-0.2.2-py3-none-any.whl
| Download URL | sft_cli-0.2.2-py3-none-any.whl |
|---|---|
| Size | 102.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a5a9d6648737bb98f1a2e3b4f4b82b8f74e7379dd574be9d04eacaae912cb0f
|
|
BLAKE2b-256 checksum How to use checksums |
e64993d52842d11a39e1134dd9a477eef2fdfb9ed3ae1e3c0c2feb50dee1ce7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.
Transparency log