Datalad container run

From nipreps/skills-comm · View interactive version

Datalad container run is an AI agent skill from the GitHub repository nipreps/skills-comm. 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

How to use this skill

Skill file

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

  1. Identify command and container — read $ARGUMENTS or extract from conversation

context. Determine:

If either is ambiguous or missing, ask the user to specify both before continuing.

  1. Verify DataLad context — check whether cwd is inside a DataLad dataset:

```bash

ls .datalad/

```

> "No DataLad dataset detected. Would you like to:

> 1. Initialize one here with /datalad-init

> 2. Run the container command bare (no provenance tracking)"

Wait for their choice.

  1. 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.

  1. Container registration check — run datalad containers-list to see registered

containers:

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:

```

datalad containers-add <name> \

--url <image-url-or-path> \

--call-fmt "<call-format>"

```

e. Execute after user confirmation. On failure, show error and stop.

  1. Gather run parameters — ask the user (or infer from context) for:
  1. Construct and show the full command — build the complete invocation and display

it before executing:

```

datalad container-run \

--container-name <name> \

-m "<message>" \

[-i <input>...] \

[-o <output>...] \

"<command>"

```

Then ask: > "Ready to execute? (yes / edit)"

  1. Execute and report — after user confirmation, run the constructed command.

recorded, and that the container image and command are now in dataset history.

Removing a registered container (`datalad containers-remove`)

When the user wants to deregister a container:

  1. List registered containers to confirm the name:

```bash

datalad containers-list

```

  1. 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 '<name>' will drop the container image from the dataset. Past runs

> referencing it will no longer be replayable unless you re-add the image. Proceed?"

  1. Remove after confirmation:

```bash

datalad containers-remove <name>

```

  1. Save the change:

```bash

datalad save -m "remove container <name>"

```

Constraints

registration or container-run step.

with datalad containers-list first.

container call.

missing, the container will be invoked incorrectly. Flag this to the user.

datalad save to record the removal.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.