Skip to main content

toolbelt

Format or run checks on files by running tools on them

NOTE: This is a work in progress. Documentation is being updated to reflect the latest changes.

What Makes Toolbelt Natural

Toolbelt abstracts away the complexity of different tool behaviors into a unified interface. Once a tool is configured, developers don't need to remember:

  • Does this tool take directories or files?
  • Does it discover files itself or need them listed?
  • Does it edit in-place or output to stdout?
  • What are the right flags for this specific tool?

Instead, you just run tb check python or tb format yaml and toolbelt figures out how to orchestrate everything properly.

The Three Execution Modes

Toolbelt handles any file-processing tool through three fundamental approaches:

  • Discovery Mode: Tools like ruff check . or prettier --check . that naturally discover and process files based on their own logic
  • Per-file Mode: Tools that work best when given explicit file lists, where toolbelt discovers the files and passes them to the tool
  • File Rewriting: Tools that output formatted content that needs to be written back to files

This creates a seamless developer experience - toolbelt becomes the universal interface to all your development tools, and you don't have to context-switch between different tool syntaxes and behaviors.

Offline tools

  • pnpm dlx => env NPM_CONFIG_OFFLINE=true tb check prettier.
  • uvx => env UV_OFFLINE=1 tb check python.

Configuration Presets and Environment Variables

Toolbelt provides configuration presets that you can include and customize rather than writing tool configurations from scratch. This approach promotes reuse and consistency across projects.

Python Development Preset (python-dev.yaml)

The python-dev.yaml preset includes a coverage profile that runs pytest with coverage reporting. Instead of overriding the entire configuration, you can customize it using environment variables:

Coverage Environment Variables

  • TB_PROJECT_SOURCE (default: src) - Primary source directory to measure coverage for
  • TB_COVERAGE_TARGET (default: tests) - Directory containing test files to run
  • TB_COVERAGE_EXTRA_ARGS (default: empty) - Additional arguments to pass to pytest

Usage Examples

# Basic usage with defaults
tb check coverage
# Runs: pytest -v --tb=short --cov=src --cov-report=term-missing --cov-report=html:.coverage-files/htmlcov tests

# Cover a different source directory
TB_PROJECT_SOURCE=toolbelt tb check coverage
# Runs: pytest -v --tb=short --cov=toolbelt --cov-report=term-missing --cov-report=html:.coverage-files/htmlcov tests

# Add extra coverage directories and options
TB_COVERAGE_EXTRA_ARGS="--cov=tests --cov-fail-under=90 --cov-branch" tb check coverage
# Runs: pytest -v --tb=short --cov=src --cov=tests --cov-fail-under=90 --cov-branch --cov-report=term-missing --cov-report=html:.coverage-files/htmlcov tests

# Combine multiple customizations
TB_PROJECT_SOURCE=myapp TB_COVERAGE_TARGET=test_suite TB_COVERAGE_EXTRA_ARGS="--cov=scripts --cov-fail-under=80" tb check coverage

Dynamic Argument Expansion

The TB_COVERAGE_EXTRA_ARGS variable supports automatic argument splitting - if you provide multiple space-separated arguments, they will be properly split into separate command arguments:

# This single environment variable:
TB_COVERAGE_EXTRA_ARGS="--cov=lib --cov=scripts --cov-fail-under=85"

# Automatically becomes these separate arguments:
# --cov=lib --cov=scripts --cov-fail-under=85

This makes it easy to add multiple coverage directories, set thresholds, enable branch coverage, or add any other pytest/coverage options without needing to override the entire tool configuration.

Tab Completion (argcomplete)

Toolbelt supports tab completion for its CLI using argcomplete.

Bash / Zsh

Add this to your shell or .bashrc / .zshrc:

eval "$(register-python-argcomplete tb)"

After setup, you can use tab completion for all CLI options and arguments.

Metadata

Release files for tbelt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tbelt 0.1.0
File Size Uploaded
tbelt-0.1.0.tar.gz 28.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tbelt 0.1.0
File Interpreter ABI Platform
tbelt-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 69.4 kB

Release files / tbelt-0.1.0.tar.gz

Download URL tbelt-0.1.0.tar.gz
Size 28.1 kB
Tags Source
SHA-256 checksum
How to use checksums
19c178dd2690315b36702a675f4b377ebd643f3d6e9d8bce205f473080980152
BLAKE2b-256 checksum
How to use checksums
8b70c1d3cf3b22282fce3f9d908bfbcf6e13e6e1afdc28524f8a61b841592313
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.20

Release files / tbelt-0.1.0-py3-none-any.whl

Download URL tbelt-0.1.0-py3-none-any.whl
Size 41.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78da2a965baa0603aff76b6efeb718f289232c0977fc5d50d5fd2aba8b3e5160
BLAKE2b-256 checksum
How to use checksums
e4a21898cffb306c28b94d44ca93afbdf771c23990df1be947bd1b0193e88bf0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.20

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page