Auto-invoke when about to execute a command inside a container (Singularity .sif file, Apptainer image, Docker image) that produces output files inside a DataLad dataset. Trigger on "run in container", "run with Singularity", "run with Apptainer", "run with Docker", "containerized analysis", "remove a container", "unregister container", or /datalad-container-run. Records both the command and the container image in dataset provenance. Do NOT trigger for bare datalad run commands without a container — use datalad-run for those.
Instalação
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Auto-invoke when about to execute a command inside a container (Singularity .sif file, Apptainer image, Docker image) that produces output files inside a DataLad dataset. Trigger on "run in container", "run with Singularity", "run with Apptainer", "run with Docker", "containerized analysis", "remove a container", "unregister container", or /datalad-container-run. Records both the command and the container image in dataset provenance. Do NOT trigger for bare datalad run commands without a container — use datalad-run for those.
argument-hint
["container-name command"]
user-invocable
true
disable-model-invocation
false
allowed-tools
Read, Bash, Glob
Skill: datalad-container-run
Wrap a command in datalad container-run to record the container image, the command,
inputs, and outputs in the dataset history. The container image content hash is annexed,
so the full computational environment is reproducible via datalad rerun.
Always load ${CLAUDE_PLUGIN_ROOT}/references/container-run.md before any container
registration or container-run step.
Steps
Identify command and container — read $ARGUMENTS or extract from conversation
context. Determine:
The container image (.sif path, Docker image name, Singularity/Apptainer URL)
The command to run inside the container
If either is ambiguous or missing, ask the user to specify both before continuing.
Verify DataLad context — check whether cwd is inside a DataLad dataset:
ls .datalad/
Dataset found: continue.
No dataset found: ask the user:
"No DataLad dataset detected. Would you like to:
Initialize one here with /datalad-init
Run the container command bare (no provenance tracking)"
Wait for their choice.
Check for unsaved changes — run datalad status. If the output shows modified
or untracked files, prompt the user to save first with /datalad-save or confirm
they want to proceed anyway.
Container registration check — run datalad containers-list to see registered
containers:
Container already registered: proceed to step 5.
Not registered: guide the user through datalad containers-add:
a. Ask for a short name (identifier) for the container.
b. Confirm the image URL or local .sif path (--url).
c. Ask which runtime to use; load ${CLAUDE_PLUGIN_ROOT}/references/container-run.md
and show the call-format options table (Singularity, Apptainer, Docker).
d. Construct and display the datalad containers-add command:
Execute and report — after user confirmation, run the constructed command.
On success: report the commit hash (includes container image hash), output files
recorded, and that the container image and command are now in dataset history.
On failure: show error output; note that nothing was committed.
Removing a registered container (datalad containers-remove)
When the user wants to deregister a container:
List registered containers to confirm the name:
datalad containers-list
Warn the user — removing a container drops its registration and annexed image
from the dataset. Runs that used this container remain in history but cannot be
replayed (the image would need to be re-added):
"Removing '' will drop the container image from the dataset. Past runs
referencing it will no longer be replayable unless you re-add the image. Proceed?"
Remove after confirmation:
datalad containers-remove <name>
Save the change:
datalad save -m "remove container <name>"
Constraints
Always load ${CLAUDE_PLUGIN_ROOT}/references/container-run.md before any container
registration or container-run step.
Never call datalad container-run with an unregistered container name — always verify
with datalad containers-list first.
Never skip showing the full constructed command before executing.
Always require a meaningful -m message — never use empty or placeholder messages.
For pipelines inside the container, wrap as "bash -c 'cmd1 | cmd2'" passed to the
container call.
The --call-fmt must contain both {img} and {cmd} placeholders — if either is
missing, the container will be invoked incorrectly. Flag this to the user.
For containers-remove: always confirm before executing and always follow with
datalad save to record the removal.