AI Anonymous · from JAB Systems / October 21, 2026

AI wrote the script. Can you rerun it?

Keep the code. Record the environment. Give the next run something checkable to work from.

In this field note · 7 sections
  1. Start with the script, not an install command.
  2. Put requirements beside the code.
  3. Download and inspect the handoff.
  4. Save the adjacent lockfile.
  5. Check the rerun—and the lockfile’s boundary.
  6. Make the next run reviewable.
  7. Keep the whole handoff.

You have a useful Python script from an AI chat. Tomorrow, or on a colleague’s machine, the imports fail—or a different package version changes the result. Saving only the code leaves part of the handoff behind.

Use uv to carry a script’s Python requirements and dependencies with it, then keep the resolved package lock beside the file. We will do this with a small fictional example you can inspect without an AI account.

The practical boundary: a stale dependency requirement was rejected in our local check. An edit to the script body was accepted. A lockfile records dependencies; you still review the code and verify its result.
Ivory editorial poster reading “AI wrote the script. Can you rerun it?” Three cream cards labeled SCRIPT, DEPENDENCIES and LOCKFILE are held by a copper binder clip inside a circular replay arrow. An amber tab reads “uv”. Supporting text says “Keep the code. Record the environment.” Footer: “AI Anonymous · from JAB Systems” and “Full walkthrough at jabsystems.io”. AI-generated conceptual artwork, not a software screenshot.
Original AI-generated conceptual artwork. A script, its requirements, and a saved dependency record.
01 / Field guide

Start with the script, not an install command.

A useful AI-assisted script should survive a handoff to your future self or a colleague. Before executing it, inspect imports, paths, network requests, subprocesses and secrets access. Confirm that dependency names point to the intended projects. This guide assumes you have reviewed the code and chosen a suitable execution environment.

An AI tool can help inventory imports, but its answer is a draft. Our proposed review prompt asks for third-party imports, Python requirements and uncertainties. We did not run that prompt or test an AI model. The practice code here was authored for the guide.

The small example converts three fictional timestamp strings with explicit offsets to UTC. This is a visible fixture you can check by hand: 09:00 at −07:00 and 17:00 at +01:00 both equal 16:00 UTC. It does not infer a location, resolve daylight-saving rules, or accept ambiguous dates.

02 / Field guide

Put requirements beside the code.

The Python packaging specification defines a comment block for single-file script requirements. The complete supplied script begins with this block:

# /// script
# requires-python = ">=3.13,<3.14"
# dependencies = ["python-dateutil==2.9.0.post0"]
# ///
"""Authored fictional fixture. No AI calls, files, or network in this body."""
import json
from datetime import timezone
from importlib.metadata import version
from dateutil.parser import isoparse

timestamps = [
    "2026-10-21T09:00:00-07:00",
    "2026-10-21T17:00:00+01:00",
    "2026-10-21T16:00:00Z",
]
normalized = [isoparse(value).astimezone(timezone.utc).isoformat() for value in timestamps]
expected = ["2026-10-21T16:00:00+00:00"] * 3
if normalized != expected:
    raise SystemExit("Fixture check failed: unexpected UTC timestamps")
print(json.dumps({"python_dateutil": version("python-dateutil"),
                  "inputs": timestamps, "utc": normalized,
                  "fixture_check": "passed"}, indent=2))

requires-python limits this exercise to Python 3.13; it does not pin an exact patch release. python-dateutil is the distribution name; dateutil is its import name. The exact package pin is deliberate. Its PyPI release and isoparse documentation are the references for this fixture.

03 / Field guide

Download and inspect the handoff.

Prerequisite: Python 3.13 installed and available as python in Windows PowerShell. The official uv installation guide covers installation options; below we install the tested uv 0.13.4 release in a dedicated local tools environment. That keeps this exercise’s tool separate from a global installation.

Use a new empty folder. First download and inspect the files:

# Run in a NEW empty folder. Download, then inspect before execution.
Invoke-WebRequest 'https://jabsystems.io/ai-anonymous/Social/rerun-the-script-practice.zip' -OutFile '.\rerun-the-script-practice.zip'
Expand-Archive -LiteralPath '.\rerun-the-script-practice.zip' -DestinationPath '.\practice'
Set-Location '.\practice'
Get-Content .\normalize-times.py
Get-Content .\normalize-times.py.lock
Get-Content .\uv-practice-readme.txt

After review, use these commands from the extracted practice folder:

# After inspecting the supplied files. Python 3.13 must be installed.
python --version
python -m venv .uv-tools
.\.uv-tools\Scripts\python.exe -m pip install "uv==0.13.4"
.\.uv-tools\Scripts\uv.exe --version
.\.uv-tools\Scripts\uv.exe run --locked --script .\normalize-times.py
# Repeat the same command; compare the output with uv-observed-results.json.
.\.uv-tools\Scripts\uv.exe run --locked --script .\normalize-times.py

Installation and initial package resolution need network access. uv prepares a separate package environment for the script. That separation is not a sandbox: reviewed code still runs with your user’s permissions.

04 / Field guide

Save the adjacent lockfile.

As documented in uv’s script guide, a standalone script is locked explicitly. For this exercise, the generated file is normalize-times.py.lock; keep it beside normalize-times.py. The supplied ZIP already includes the reviewed lock, so you can run it without regenerating it.

When preparing your own handoff, generate the lock after reviewing requirements, inspect it, then keep both files together:

# For your OWN reviewed script, after choosing dependencies deliberately:
.\.uv-tools\Scripts\uv.exe lock --script .\normalize-times.py --default-index https://pypi.org/simple
# Review the generated normalize-times.py.lock and save it beside the script.
.\.uv-tools\Scripts\uv.exe run --locked --script .\normalize-times.py

The lock records resolved dependencies, including the six dependency used by this dateutil release, with package sources and distribution hashes. It is a dependency record. It does not include your script’s source hash, inputs, operating system or the complete state of your machine.

The uv command reference distinguishes --locked, which checks whether requirements still match the lock, from --frozen, which uses the lock without that freshness check. This walkthrough uses --locked. A mismatch is a reason to inspect the change before deliberately updating the lock.

05 / Field guide

Check the rerun—and the lockfile’s boundary.

Actual local environment: Windows, Python 3.13.15, uv 0.13.4, python-dateutil 2.9.0.post0. Both normal runs produced the same JSON:

{
  "python_dateutil": "2.9.0.post0",
  "inputs": [
    "2026-10-21T09:00:00-07:00",
    "2026-10-21T17:00:00+01:00",
    "2026-10-21T16:00:00Z"
  ],
  "utc": [
    "2026-10-21T16:00:00+00:00",
    "2026-10-21T16:00:00+00:00",
    "2026-10-21T16:00:00+00:00"
  ],
  "fixture_check": "passed"
}

The script checks the fixed expected UTC strings before reporting success. We also checked that the adjacent lockfile’s SHA-256 remained unchanged across both runs. Matching output on this small fixture is evidence about this example, not a guarantee about another script.

Two additional changes were made to separate copies, each starting with the original lock. These are authored checks, not observed AI mistakes:

  • Changed requirement: replacing python-dateutil==2.9.0.post0 with python-dateutil==2.8.2 caused uv run --locked --script to exit 1 with a lockfile update error.
  • Changed code body: appending print("AUTHORED_BODY_CHANGE") left dependency metadata intact. The same command exited 0 and printed the extra marker. The lockfile did not reject the code edit.

That second case is why you also keep a reviewed script version and a known expected result. Source review and fixture checks answer different questions from dependency locking. The ZIP includes the observed check report.

06 / Field guide

Make the next run reviewable.

Keep the reviewed script, adjacent lockfile, small fictional fixture, expected output, Python and uv versions, and a note explaining the intended behavior. Save the source in version control so later code edits are visible. Check actual results after every meaningful change.

Tested: lock creation, two identical local fixture runs, unchanged lock bytes, stale-requirement rejection, and acceptance of an appended code-body marker. The downloaded practice package was also extracted and rerun.

Not tested: AI code generation or review quality, real datasets, other operating systems, other Python builds, offline installation, malicious dependencies, permission or network isolation, production reliability, or performance. A lockfile improves the dependency handoff; it cannot prove safety, correctness or identical behavior on every machine.

07 / Field guide

Keep the whole handoff.

Practice ZIP · Complete script · Adjacent lockfile · Observed fixture output · Observed lock checks · Practice README · Proposed AI prompt

Primary sources were reviewed October 21, 2026. This is an established uv workflow, not a claim about a newly released AI capability. The original portrait is AI-generated conceptual artwork and was visually reviewed.

Explore more AI Anonymous field notes →

Share this post.

Found this useful? Pass it along. Download the artwork, add your own take, and tag @jabsystems.io so I can see your post.