What are Tools?
Tools in pyrig are type-safe wrappers around command-line utilities used in Python development workflows. Each tool provides a clean, composable API for constructing commands without sacrificing the flexibility of raw CLI usage.The Tool Pattern
All tools follow a consistent pattern:- Each tool is a
Toolsubclass - Provides a consistent interface - Tool methods return
Argsobjects - Immutable command argument tuples Argsobjects execute directly - Call.run()to execute- All command construction is centralized - Easy to test and maintain
Benefits
Type Safety
Arguments are validated at construction time, catching errors before execution
Composability
Args objects can be combined and extended for complex workflows
Testability
Command construction can be tested without executing subprocess calls
Discoverability
IDE autocomplete shows all available commands and their parameters
Quick Example
Available Tools
Pyrig includes wrappers for common development tools:Package Manager
UV package manager wrapper for dependency management
Version Controller
Git wrapper for version control operations
Linter
Ruff linter and formatter wrapper
Type Checker
Ty type checker wrapper
Project Tester
Pytest test runner wrapper
The Tool Base Class
Location
pyrig.rig.tools.base.base.Tool (rig/tools/base/base.py:49)
Core Methods
All Tool subclasses must implement:The args() Method
The baseargs() method constructs command arguments:
Example Usage
The Args Class
Location
pyrig.src.processes.Args (src/processes.py:121)
Overview
Args is an immutable tuple subclass that represents a complete command ready for execution:
Execution Methods
- run()
- run_cached()
Execute the command immediately:
Common Parameters
Bothrun() and run_cached() accept:
check: bool = True- Raise exception on non-zero exit codecapture_output: bool = True- Capture stdout/stderrcwd: str | Path | None = None- Working directorytimeout: int | None = None- Command timeout in secondstext: bool = True- Decode output as text
Customizing Tools
You can customize tools by subclassing them:Tool Groups
Tools are organized into groups for badge organization:Best Practices
Use the singleton instance .I
Use the singleton instance .I
All tools provide a singleton instance via
.I:Compose args for complex commands
Compose args for complex commands
Build complex commands incrementally:
Test without execution
Test without execution
Test command construction without running subprocesses:
Handle errors gracefully
Handle errors gracefully
Use
check=False for commands that may fail:Next Steps
Package Manager
Learn about UV package management
Version Controller
Explore Git operations
Code Quality
Configure linting and formatting