# Capture Environment

Snapshot the computational environment for a replication package, detects the analysis...

- Repository: https://github.com/pedrohcgs/claude-code-my-workflow (1676 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-09-27
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add pedrohcgs/claude-code-my-workflow --skill capture-environment -g -a claude-code -y`
Codex: `npx skills add pedrohcgs/claude-code-my-workflow --skill capture-environment -g -a codex -y`
Cursor: `npx skills add pedrohcgs/claude-code-my-workflow --skill capture-environment -g -a cursor -y`
Gemini CLI: `npx skills add pedrohcgs/claude-code-my-workflow --skill capture-environment -g -a gemini-cli -y`

## Description

Snapshot the computational environment for a replication package, detects the analysis stack (R / Stata / Python) and emits the right lockfiles (renv.lock + sessionInfo.txt, requirements.txt / environment.yml / uv.lock, Stata version + ado package list), records seeds and RNG kind, optionally writes a pinning Dockerfile, and produces a paste-ready "Computational requirements" block. Use when user says "capture the environment", "snapshot my dependencies", "pin the versions", "make a renv.lock / requirements.txt", "make this byte-reproducible", or before releasing a replication package to openICPSR / the AEA Data Editor.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# `/capture-environment`, snapshot the computational environment

A replication package that runs on the author's laptop in 2026 and nowhere else in 2029 is not reproducible. This skill captures the *exact* computational environment, language versions, package versions, seeds, RNG kind, and (optionally) the OS layer, so a referee, the AEA Data Editor, or future-you can reconstruct it. It detects which stack the project uses and emits the artifacts that stack's ecosystem expects, then verifies the lockfile installs clean.

**Core principle:** Pin everything a result depends on. Display rounding aside, a re-run on a pinned environment should reproduce the paper to the [`replication-protocol.md`](../../rules/replication-protocol.md) tolerances, *byte-identical* when the optional Dockerfile is used.

## When to use

- **Before releasing a replication package** to openICPSR, Zenodo, Dataverse, or a journal archive, the AEA Data Editor / DCAS standard expects a documented, version-pinned environment.
- **Before submission**, alongside [`/audit-reproducibility`](../audit-reproducibility/SKILL.md), that skill checks the *numbers*; this one captures the *environment* those numbers were produced in (its `sessionInfo.txt` requirement is satisfied by this skill).
- **After adding or upgrading a package** mid-project, re-snapshot so the lockfile doesn't drift from what the code actually loads.
- **When handing a project to a co-author or RA** who needs to reconstruct your stack.

## Inputs

- `$0`, project directory. Defaults to the repo root. The skill looks under `scripts/R/`, `scripts/stata/`, `scripts/python/`.
- `--docker`, also emit a `Dockerfile` pinning OS + language version + system libraries for byte-identical reproduction.
- `--no-verify`, skip Phase 3 (the best-effort clean-install check). Useful in CI or when the toolchain isn't installed locally.

## Workflow

### Phase 0: Detect the stack

The rest: https://github.com/pedrohcgs/claude-code-my-workflow/blob/HEAD/.claude/skills/capture-environment/SKILL.md
