[BUG] Nested .claude/skills in a gitignored subdirectory are never discovered (CLAUDE.md and rules there do load)
Summary
Skills in <subdir>/.claude/skills/ are documented to load "the first time Claude reads or edits a file in that subdirectory". This never happens when <subdir> is listed in the root .gitignore. CLAUDE.md and .claude/rules/ in the same gitignored subdirectory do load on demand, so the two discovery paths behave differently.
Why it matters
Meta-repo / polyrepo workspaces commonly clone independent repos as gitignored subdirectories of a root workspace repo, and open Claude Code at the root. Each repo's own skills are then invisible, while its CLAUDE.md and rules work.
Repro (Claude Code 2.1.299, macOS)
git init root && cd root
mk() { mkdir -p "$1/.claude/skills/$2"; printf -- "---\nname: $2\ndescription: Test skill.\n---\nSay hello.\n" > "$1/.claude/skills/$2/SKILL.md"; echo x > "$1/file.txt"; }
mk plain skill-plain
mk ignored skill-ignored
echo "ignored/" > .gitignore
git add -A && git commit -qm init
for d in plain ignored; do
claude -p --max-turns 3 --allowedTools=Read \
"Use the Read tool on $d/file.txt. Then, without any other tool, list available skills whose name starts with 'skill-', or NONE."
done
| Subdirectory | Skill available after Read |
|---|---|
| plain/ | ✅ skill-plain |
| ignored/ (gitignored) | ❌ NONE |
| ignored/ with --add-dir ignored | ✅ skill-ignored |
Also checked: a nested git repo that is not gitignored loads its skills; a symlinked skill directory loads; a gitignored directory without its own .git does not load. So the trigger is the gitignore, not the nested repo nor the symlink.
Expected
Either load nested skills from gitignored subdirectories on Read/Edit like CLAUDE.md and rules, or document the exclusion and provide a setting to opt directories in (permissions.additionalDirectories grants file access but loads no skills).
Related
- #93403 (nested skills only load on Read/Edit/Write, never in auto mode) — different cause, same symptom.