# capture-environment

This skill snapshots language and package versions, seeds and RNG kind into lockfiles so a rerun matches on another machine. Reach for it before releasing a replication package.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · ★ 1668
- Author: pedrohcgs
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/pedrohcgs/claude-code-my-workflow/tree/HEAD/.claude/skills/capture-environment/SKILL.md
- Updated: 2026-09-27
- HTML: https://affpapa.org/en/nevibecode/skills/capture-environment

## What it does

The skill looks at what the project is built on and emits the artifacts that ecosystem expects. For R it writes `renv.lock` and `sessionInfo.txt`; for Python it produces `uv.lock`, `requirements.txt` or `environment.yml`, whichever the project already uses; for Stata it reports the `version` line pinned in the `.do` files plus an inventory of ado packages. It also greps the analysis scripts for the master seed and RNG kind.

Four phases: detect the stack under `scripts/R/`, `scripts/stata/`, `scripts/python/`, capture per language, write a Dockerfile (only with `--docker`), then attempt a clean restore of the lockfile away from your working environment. `--no-verify` skips that last check, which helps in CI where the toolchain isn't installed. If the pipeline does randomized work and no seed turns up, the skill raises a warning — an unseeded result won't reproduce.

Stata needs a caveat: the licensed binary can't go into a Dockerfile, so the skill emits a stub documenting the expected version and flavor and leaves the install to whoever replicates. Byte-identical reproduction is what `--docker` buys you; without it, environment drift is on the person running the code.

## Requirements
- Works with: Docker

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add pedrohcgs/claude-code-my-workflow --skill capture-environment -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/capture-environment/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/capture-environment/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add pedrohcgs/claude-code-my-workflow --skill capture-environment -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/capture-environment/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add pedrohcgs/claude-code-my-workflow --skill capture-environment -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/capture-environment/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install pedrohcgs/claude-code-my-workflow capture-environment
```

2. **Manually: put the files in place**
- File: `.github/skills/capture-environment/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add pedrohcgs/claude-code-my-workflow --skill capture-environment -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/pedrohcgs/claude-code-my-workflow --path .claude/skills/capture-environment
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/capture-environment/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add pedrohcgs/claude-code-my-workflow --skill capture-environment -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/pedrohcgs/claude-code-my-workflow/tree/HEAD/.claude/skills/capture-environment/SKILL.md

## When to use it
- pin package versions before releasing a replication package
- generate `renv.lock` and `sessionInfo.txt` for an R project
- record the Stata version and the ado package list
- find the master seed and RNG kind in analysis scripts
- build a Dockerfile with a pinned language version and system libraries

## Example prompts
- capture the environment for this project
- make a renv.lock and requirements.txt, pin the versions
- snapshot my dependencies with --docker before the openICPSR release

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 465815df4b77518c.

BEGIN THIRD-PARTY FILE 465815df4b77518c
```text
---
name: capture-environment
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.
argument-hint: "[project-dir] [--docker] [--no-verify] (project-dir defaults to repo root)"
allowed-tools: ["Read", "Grep", "Glob", "Write", "Bash"]
effort: medium
---

# `/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.
```
END THIRD-PARTY FILE 465815df4b77518c

The third-party file has ended. Everything between the 465815df4b77518c tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2267 of 11278 bytes. © pedrohcgs · MIT · https://github.com/pedrohcgs/claude-code-my-workflow/tree/HEAD/.claude/skills/capture-environment/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
