sniptrace
Trim noisy terminal output before it reaches your AI coding agent. Save tokens, reduce LLM costs, and keep context windows focused on what matters.
pip install sniptrace
Quick start
Filter a string you already have
from sniptrace import filter_text
raw_output = captured_stderr # string from your agent's code execution
clean = filter_text(raw_output)
llm.complete(f"Fix this error:\n{clean}")
Run a command and get filtered output
from sniptrace import run
result = run(["pytest", "tests/"])
if not result.ok:
llm.complete(f"Fix this error:\n{result.output}")
# result.output has no progress bars, no site-packages frames, no noise
What gets filtered
SnipTrace removes known low-signal output patterns from:
- Python — stdlib/venv traceback frames, pip install chatter
- Node / JS — npm/pnpm/yarn deprecation warnings, progress lines
- Docker — BuildKit step lines, layer pull progress
- pytest / Jest / Vitest — session headers, progress dots, PASSED lines
- Cargo / Gradle / Maven — compile progress,
[INFO]lines - Generic — ANSI escape codes, progress bars, spinner frames, update banners
Lines containing error signals (error, traceback, exception, failed, cannot, etc.) are always preserved, even if they match a strip pattern.
API
filter_text(text: str) -> str
Filter an already-captured string. No CLI required — all filtering is pure Python.
from sniptrace import filter_text
clean = filter_text(raw_stderr)
run(command, *, cwd=None, env=None, timeout=None) -> SnipResult
Run a command and return filtered output. Uses the sniptrace CLI if installed (preserves telemetry), otherwise filters natively in Python.
from sniptrace import run
result = run(["pytest", "-q", "tests/"])
print(result.output) # filtered output
print(result.ok) # True if exit code was 0
print(result.reduction_pct) # e.g. 87.3
print(result.bytes_saved) # original_bytes - filtered_bytes
SnipResult
@dataclass
class SnipResult:
exit_code: int
output: str
original_bytes: int
filtered_bytes: int
reduction_pct: float
filtered: bool # False if filtering was skipped
@property
def ok(self) -> bool: ... # exit_code == 0
@property
def bytes_saved(self) -> int: ... # original_bytes - filtered_bytes
is_available() -> bool
Returns True if the sniptrace CLI is installed on PATH.
Typical agent loop
from sniptrace import run
def agent_loop(task: str, llm, max_rounds: int = 5):
code = llm.complete(f"Write Python code to: {task}")
for _ in range(max_rounds):
write_to_disk(code)
result = run(["python", "solution.py"])
if result.ok:
return code # done
code = llm.complete(
f"The code produced this error:\n{result.output}\n\nFix it."
)
return code
Zero dependencies
The package uses only the Python standard library. No external packages required.
Install the CLI (optional)
The CLI is optional — filter_text() and run() both work without it. The CLI adds telemetry (token savings counter) and shell wrappers for automatic filtering in your terminal.
curl -fsSL https://sniptrace.com/install.sh | sh
Links
Metadata
Release files for sniptrace 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sniptrace-1.2.0.tar.gz | 9.4 kB | Without provenance | Details for sniptrace-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sniptrace-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for sniptrace-1.2.0-py3-none-any.whl |
Total release size: 18.3 kB
Release files / sniptrace-1.2.0.tar.gz
| Download URL | sniptrace-1.2.0.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0c56fb63318ddd8c0bf241858a40224b9f1bad8ec3fba105c5d38835c80b4d7
|
|
BLAKE2b-256 checksum How to use checksums |
036d7127fc57a38da63b10ea5a7374152e42875b91bf0b167b492ed57cf23d62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / sniptrace-1.2.0-py3-none-any.whl
| Download URL | sniptrace-1.2.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f106b0c6951b7f51ed58a7cebafec5f263d45aeb681189c4d7323909667338e1
|
|
BLAKE2b-256 checksum How to use checksums |
dbd54f01989c5fab391eafd1b57677ab38c031dfb40bd7ccf6856d35c3607a18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for sniptrace 1.2.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.