Skip to content

Review and commit what the agent produced

Quick step  about 5 min

In this exercise, you initialize Git version control, configure .gitignore exclusions to safeguard raw datasets and credentials, review the exact code diff produced by the agent, and commit an immutable snapshot of your project.

Before you start: A project directory with analytical scripts and documentation, and Git installed on your system (Setup). For a comprehensive guide, see Git and GitHub.

Background

Version control creates permanent cryptographic snapshots of your project. Reviewing the line-by-line unified diff before staging files is the most effective supervisory mechanism for auditing code authored by an agent (Version control).

Strictly exclude non-source files from version control: sensitive or high-volume datasets, intermediate binary build outputs, Python virtual environment trees (.venv/), and configuration files containing access credentials (Secrets, Privacy and data handling).

General methodology

Direct the agent to initialize the repository, configure exclusions, and display staged files without executing the commit autonomously:

Initialize a Git repository here if none exists. Create a .gitignore file explicitly excluding raw data directories, generated output files, .env credential files, and virtual environments (.venv/). Display git status and a unified diff summarizing staged changes. Do not commit yet.

Review the output carefully to verify that no excluded assets appear in the staging area. Then instruct the agent to commit the approved files:

Commit scripts/, notes/, README.md, AGENTS.md, and custom skills with an informative commit message. Do not execute git push.

Publishing commits to a remote hosting platform (such as GitHub) is an operation with external side effects that should always require explicit human authorization (Steering).

Workshop example · Imaging: chest radiographs

Start from: the evaluated checkpoint plus the tool and skill from the previous step (how to restore)
Produces: a local Git repository with one commit

Prompt

Initialise a git repository here if there is none. Create a .gitignore that excludes the images (*.dcm and the images/ folder), the data files (*.csv, *.xlsx, *.docx, *.pdf), the out/ and data/ folders, any .env file, and .venv. Show me git status and what would be committed. Do not commit yet.

Then commit: Commit scripts/, notes/, README.md, AGENTS.md and .agents/ with a clear message. Do not push.

What should be committed: scripts/, notes/cleaning-decisions.md, README.md, AGENTS.md, references.bib, refs/search-log.md, and the skill folder.

What should not be: the DICOM files (they hold patient information in the header and sometimes in the pixels), the other original data files, out/, data/, and any .env. A single git add . here would add 280 images and about 70 MB, and the history keeps them forever, even if you delete them in a later commit.

Note on the data. The images in this material are a public research sample and the headers are synthetic. With real clinical images, committing them, even to a private repository, may breach your institution's rules. Check before you do (Privacy).

Verification criteria

  • Clean staging area: No raw datasets, private credentials, or large binary outputs appear in git status.
  • Informative commit message: The commit message clearly characterizes the analytical additions and tools introduced.
  • Local confinement: The repository was committed locally without pushing to remote servers.

Common pitfalls

Symptom Underlying cause Resolution
Datasets or .venv/ appear in git status .gitignore pattern was missing or misconfigured Add missing directory patterns to .gitignore and re-verify with git status
Credential committed to Git history .env was staged prior to adding to .gitignore Treat the token as compromised: revoke and rotate the secret immediately (Secrets)

Concepts behind this

  • Version control. Version control provides an immutable audit trail and safety net, allowing researchers to inspect every line changed by an agent and roll back errors instantly. Go deeper →
  • Secrets. Credentials must never enter prompts, session logs, or version control. Use isolated environment variables and enforce immediate revocation protocols if exposed. Go deeper →
  • Privacy and data handling. Data read by an agent is transmitted to the model provider as context. Determining whether data is permitted to leave your infrastructure must precede deciding what tasks to delegate. Go deeper →

Builds on: Turn the analysis into a tool and a skill