Datalad subdatasets

From nipreps/skills-comm · View interactive version

Datalad subdatasets is an AI agent skill from the GitHub repository nipreps/skills-comm. Auto-invoke when the user wants to list nested datasets, inspect the subdataset tree, check which subdatasets are absent or present, set a property on a subdataset registration, or run a command across all subdatasets. Trigger on "list subdatasets", "show nested datasets", "check subdataset status",

How to use this skill

Skill file

Skill: datalad-subdatasets

Inspect the subdataset tree and manage subdataset properties. Lists all registered

subdatasets, their state (present/absent), and the commit SHA they are pinned to.

Steps

  1. Verify DataLad context — check for .datalad/ in the current directory or a

parent:

```bash

ls .datalad/ 2>/dev/null

```

If no dataset is found, inform the user and stop.

  1. Determine action — read from $ARGUMENTS or conversation context:
  1. Construct and run command:

### inspect (default)

```bash

datalad subdatasets

```

### recursive listing

```bash

datalad subdatasets -r

```

### filter absent

```bash

datalad subdatasets --state absent

```

### set property

Show the command and confirm before running — this modifies .gitmodules:

```

datalad subdatasets --set-property <property-name> <value> <subdataset-path>

```

Common properties: url (change where the subdataset is fetched from).

### run a command across subdatasets (datalad foreach-dataset)

When the user wants to execute a command on every subdataset in the tree, use

datalad foreach-dataset. Gather:

```bash

datalad foreach-dataset [-r] [--include-super] -- <command>

```

Examples:

```bash

# Run datalad status on every subdataset

datalad foreach-dataset -r -- datalad status

# Update all subdatasets

datalad foreach-dataset -r -- datalad update --how=merge

# Check annex usage in every subdataset

datalad foreach-dataset -r -- git annex info --fast

```

Always show the full command before executing and warn that errors in one subdataset

will be reported but processing continues for the rest.

  1. Interpret output — explain the results to the user:

files are not accessible

  1. Suggest follow-up based on what's found:

> "Run datalad get -n <path> to initialize the subdataset handle without

> downloading content, or datalad get <path> to initialize and retrieve all files."

> "Run datalad update -s origin --how=merge to pull the latest state."

> "Run datalad get -r . to initialize and retrieve all absent subdatasets and

> their content at once."

Reference

Load ${CLAUDE_PLUGIN_ROOT}/../references/subdataset-patterns.md for the absent/present

model, neuroimaging layout examples, recursive get patterns, and .gitmodules structure.

Constraints

not modify any state.

running — it modifies .gitmodules, which is a tracked file that requires a subsequent

datalad save to record the change.

DataLad's other subdataset management commands.

debugging at the git level — DataLad's abstraction layer must be kept consistent.

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.