Skill: datalad-save
Record code changes, configuration edits, and non-run file modifications in a DataLad
dataset. datalad save is the correct replacement for git add + git commit inside
a DataLad dataset — it handles both git-tracked and annexed files correctly.
Steps
- Verify DataLad context — check for
.datalad/in the current directory or any
parent directory:
```bash
ls .datalad/ 2>/dev/null || git rev-parse --show-toplevel
```
- Dataset found: continue.
- No dataset found (plain git repo or not tracked): fall back to standard
git add + git commit workflow and inform the user:
> "No DataLad dataset detected — using plain git commit instead."
- Run
datalad status— show the user what has changed:
```bash
datalad status
```
Present the output. If nothing is modified or untracked, stop:
> "Nothing to save — working tree is clean."
- Determine save scope — based on
$ARGUMENTSand conversation context:
- If specific paths are given (e.g.,
code/analysis.py configs/), save only those paths - If no paths given, save all changes (
datalad savewithout path arguments saves everything) - Show the user which scope will be used and confirm if ambiguous
- Get or confirm the commit message — read from
$ARGUMENTSor ask:
> "What should the commit message be? (describe what changed and why)"
Wait for the user's message. Never proceed with an empty or placeholder message.
- Construct and show the save command:
```
datalad save -m "<message>" [paths...]
```
Show it to the user before executing.
- Execute and confirm — run the command. Then run
datalad statusagain and show
the output to confirm the working tree is clean. Report the commit hash.
Constraints
- Always require a meaningful
-mmessage — never save with an empty string or
placeholder like "save" or "update".
- Never use
git addorgit commitinside a DataLad dataset —datalad savehandles
both annexed and git-tracked files correctly; raw git commands can corrupt annex state.
- Never use
git annex addmanually — DataLad manages annex staging automatically. - Always make the save scope explicit: tell the user whether all changes or specific
paths are being saved.
- Always run
datalad statusbefore saving to show the user what will be recorded. - Always run
datalad statusafter saving to confirm a clean working tree. - If the user asks to save outputs produced by a script, redirect them to
datalad run
instead — outputs should be recorded with the command that created them, not as
standalone saves.
- Use
datalad save --to-git <path>to force a file into git tracking rather than annex
(useful for small config files, .gitignore fragments, etc. that should not be annexed).
- Use
datalad save --version-tag <tag>to tag an analysis milestone after saving.