crosshair-tool
Analyze Python code for correctness using symbolic execution.
What it is and what it does
CrossHair is a symbolic execution and theorem-proving tool for Python that bridges testing and type systems. You annotate functions with type hints and optional contracts (preconditions, postconditions, invariants), and CrossHair explores execution paths using an SMT solver to find inputs that violate those contracts—essentially automated counterexample generation. It works by repeatedly calling your functions with symbolic inputs, tracking constraints, and asking the solver whether any path can violate your specifications.
Beyond contract checking, CrossHair can generate unit tests by exploring code paths and detecting behavioral differences between function implementations. It integrates with Hypothesis as an optional backend and offers IDE plugins for VS Code and PyCharm. The tool targets developers who want stronger correctness guarantees than traditional testing alone, particularly for functions with clear specifications. Runtime dependencies include z3-solver (the SMT engine), typing-inspect, pygls (for language server protocol), and typeshed-client.
Use it for:
- Find edge cases and counterexamples in functions with type annotations and contracts before they reach production
- Generate test cases automatically by exploring symbolic execution paths through your code
- Verify that refactored or optimized functions behave identically to their original implementations
- Use as a Hypothesis backend for property-based testing with symbolic reasoning
- Catch off-by-one errors, null-pointer-like issues, and invariant violations in class methods
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
CrossHair uses symbolic execution and SMT solving to find counterexamples to type-annotated functions with contracts, and can generate unit tests or detect behavioral differences between implementations.
Yes, if you work with type-annotated Python and want automated counterexample detection beyond traditional testing. The active maintenance, broad Python version support, and zero known vulnerabilities make it safe to adopt. Install friction is moderate due to z3-solver's compilation requirements, but prebuilt wheels are available. Best suited for projects where correctness is critical and you're willing to write contracts alongside type hints.
Install
crosshair-tool on PyPI
pip
pip install crosshair-tooluv
uv add crosshair-toolpoetry
poetry add crosshair-toolInstalling crosshair-tool
Before you install
Medium install friction due to 7 runtime dependencies including z3-solver, a heavyweight SMT solver. Actively maintained with a release 24 days ago and 1314 repository stars. Supports Python 3.8 through 3.15 with prebuilt wheels across macOS, Linux, and Windows.
License in practice
MIT license permits commercial and private use with minimal restrictions, making it suitable for most development contexts.
Quickstart
pip install crosshair-tool
from crosshair.core import analyze
def example(x: int) -> int:
"""post: _ >= 0"""
return x * 2
analyze(example)
z3-solver is a compiled dependency that may require build tools on some systems; symbolic execution can be computationally expensive for complex functions.
Verify before relying
- Whether IDE integrations for VS Code and PyCharm are actively maintained and compatible with current versions
- Performance characteristics and timeout behavior when analyzing large or complex codebases
- How well symbolic reasoning handles third-party library calls beyond the standard library
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 7 — packaging, typing-inspect, typing_extensions, z3-solver, importlib_metadata, pygls, typeshed-client |
| Maintenance | actively maintained — 24 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 417,304/month — #6,818 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: crosshair_tool-0.0.109-cp310-cp310-macosx_10_9_universal2.whl; crosshair_tool-0.0.109-cp310-cp310-macosx_10_9_x86_64.whl; crosshair_tool-0.0.109-cp310-cp310-macosx_11_0_arm64.whl; crosshair_tool-0.0.109-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; crosshair_tool-0.0.109-cp310-cp310-musllinux_1_2_x86_64.whl; crosshair_tool-0.0.109-cp310-cp310-win32.whl; crosshair_tool-0.0.109-cp310-cp310-win_amd64.whl; crosshair_tool-0.0.109-cp311-cp311-macosx_10_9_universal2.whl; crosshair_tool-0.0.109-cp311-cp311-macosx_10_9_x86_64.whl; crosshair_tool-0.0.109-cp311-cp311-macosx_11_0_arm64.whl; crosshair_tool-0.0.109-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; crosshair_tool-0.0.109-cp311-cp311-musllinux_1_2_x86_64.whl; crosshair_tool-0.0.109-cp311-cp311-win32.whl; crosshair_tool-0.0.109-cp311-cp311-win_amd64.whl; crosshair_tool-0.0.109-cp312-cp312-macosx_10_13_universal2.whl; crosshair_tool-0.0.109-cp312-cp312-macosx_10_13_x86_64.whl; crosshair_tool-0.0.109-cp312-cp312-macosx_11_0_arm64.whl; crosshair_tool-0.0.109-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; crosshair_tool-0.0.109-cp312-cp312-musllinux_1_2_x86_64.whl; crosshair_tool-0.0.109-cp312-cp312-win32.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
dealDeal is a Python library for design by contract…
permissive · top 15,000 on PyPI
icontracticontract enforces design-by-contract in Python…
permissive · top 15,000 on PyPI
PyBoolectorPython wrapper around Boolector, a…
permissive · top 15,000 on PyPI
z3-solverZ3 is a theorem prover and SMT (satisfiability…
permissive · top 5,000 on PyPI
cvc5cvc5 is a satisfiability modulo theories (SMT)…
unclear · top 15,000 on PyPI
mythrilMythril analyzes EVM bytecode for security…
permissive · top 15,000 on PyPI
cisco-ai-skill-scannerScans AI Agent Skills for prompt injection,…
permissive · top 15,000 on PyPI
hypothesisHypothesis is a property-based testing library…
copyleft · top 1,000 on PyPI
pyvcgPyVCG generates verification conditions for SMT…
copyleft · top 15,000 on PyPI
pytest-astropyA meta-package that bundles pytest plugins and…
permissive · top 15,000 on PyPI