The scratch command executes the .scratch file located at the project root. The .scratch file is a Python script intended for temporary, experimental code that doesn’t belong in the main source files.
The .scratch file is automatically created by pyrig mkroot:
# Generate .scratchuv run pyrig mkroot# Edit itvim .scratch# Run ituv run pyrig scratch
Default content:
"""Temporary scratch file for ad-hoc code execution.This file is not tracked by version control and is intended for:- Quick prototyping- Debugging- Experimental code- One-off scriptsRun with: uv run pyrig scratch"""print("Hello from .scratch!")
# .scratch# Testing the new authentication flow# Remember to move to proper test file once workingfrom myproject.auth import new_auth_flowresult = new_auth_flow.authenticate(user='test')print(f"Auth result: {result}")
# 1. Write experimental codevim .scratch# 2. Test ituv run pyrig scratch# 3. If it works, move to proper modulemv .scratch src/myproject/new_feature.py# 4. Create testsuv run pyrig mktests
# 1. Reproduce issue in .scratchvim .scratch # Add failing code# 2. Add debugginguv run pyrig -v scratch # See detailed output# 3. Fix issue in sourcevim src/myproject/module.py# 4. Verify fixuv run pyrig scratch # Should work now
# .scratchraise ValueError("Something went wrong")
$ uv run pyrig scratchTraceback (most recent call last): File ".scratch", line 1, in <module> raise ValueError("Something went wrong")ValueError: Something went wrong
The full traceback is displayed, just like running python .scratch.