Skill: datalad-diff
Compare file-level state between two points in a DataLad dataset's history. datalad diff
reports which files changed and their annex state transitions — it does not show line-level
content diffs.
Steps
- Verify DataLad context — check for
.datalad/in the current directory or any
parent:
```bash
ls .datalad/ 2>/dev/null || git rev-parse --show-toplevel
```
- Dataset found: continue.
- No dataset found: inform the user; suggest plain
git difffor non-DataLad repos.
- Determine the comparison scope — read
$ARGUMENTSand conversation context to
identify what the user wants to compare. Map to one of these forms:
| User intent | Command form |
|-------------|-------------|
| Working tree vs last commit | datalad diff (no args) |
| Working tree vs specific commit | datalad diff --from <hash> |
| Two specific commits | datalad diff --from <hash-a> --to <hash-b> |
| Named revision (branch, tag) | datalad diff --from <ref> |
If the scope is ambiguous, ask the user:
> "Are you comparing the current working tree to HEAD, or two specific commits?
> If comparing commits, please provide the commit hashes or branch names."
- Construct and run the diff command:
```bash
datalad diff [--from <ref>] [--to <ref>] [paths...]
```
Show the command before running it. Present the full output to the user.
- Interpret the output — explain the change types shown:
| Type | Meaning |
|------|---------|
| added | File did not exist in the earlier revision; exists in the later one |
| deleted | File existed in the earlier revision; removed in the later one |
| modified | File content changed between revisions |
| untracked | File is present locally but outside the compared revision range |
For annexed files, note that datalad diff reports pointer-level changes (key
changed), not byte-level diffs.
- Clarify line-level diffs if asked —
datalad diffis file-level only. If the
user needs to see line-by-line content changes, point them to:
```bash
git diff <hash-a> <hash-b> -- <path>
```
This works for git-tracked files; annexed file content must be retrieved first with
datalad get <path> before git diff can show it.
Constraints
- Read-only — never stage, commit, or modify any file.
- Always show the constructed command before running it.
- Always explain that
datalad diffis file-level, not line-level, and direct the user
to git diff when they need line-level comparisons.
- If the user provides only one hash/ref, treat it as
--from(compare that ref to the
current working tree) and confirm this interpretation before running.
- Do not use
git diffas a substitute —datalad diffcorrectly handles annexed file
pointers and subdataset boundaries.