optimize(skills-perso): tri-signal detection (marker/agent-ref/allowlist) + empty fallback (d8 target)

This commit is contained in:
bastien 2026-05-06 18:16:57 +02:00
parent 22bee3aeaa
commit 88cc7b1c90

View File

@ -20,22 +20,58 @@ List only **user-created** skills from `~/.claude/skills/`, excluding framework
## How to detect user-created skills ## How to detect user-created skills
A skill is **personal** if its SKILL.md references an agent file from A skill is **personal** if it satisfies AT LEAST ONE of these signals (in priority order):
`~/.claude/agents/`. All user-created skills delegate work to a dedicated agent,
while framework/gstack skills do not. 1. **Explicit marker** — frontmatter contains `owner: user` (preferred — unambiguous, future-proof)
2. **Agent-reference heuristic** — SKILL.md body references an agent file from `~/.claude/agents/` on a non-comment line
3. **Allowlist** — skill name is in the explicit allowlist below (for self-contained personal skills that do not delegate)
Allowlist of self-contained personal skills (no agent delegation): `skills-perso`.
Framework / gstack skills always FAIL all three signals — that is how they are excluded.
Run this command to get the list of personal skills: Run this command to get the list of personal skills:
```bash ```bash
ALLOWLIST="skills-perso"
is_personal() {
local skill_file="$1" skill_name="$2"
# Signal 1: explicit marker
if grep -qE '^owner:[[:space:]]*user\b' "$skill_file" 2>/dev/null; then
return 0
fi
# Signal 2: agent reference on a non-comment line
if grep -nE '\$HOME/\.claude/agents/|~/\.claude/agents/|\.claude/agents/' "$skill_file" 2>/dev/null \
| grep -vE '^[0-9]+:[[:space:]]*(#|<!--|//)' \
| grep -q .; then
return 0
fi
# Signal 3: allowlist
for allowed in $ALLOWLIST; do
[ "$skill_name" = "$allowed" ] && return 0
done
return 1
}
found=0
for dir in ~/.claude/skills/*/; do for dir in ~/.claude/skills/*/; do
[ -L "${dir%/}" ] && continue [ -L "${dir%/}" ] && continue # skip symlinks (external)
skill=$(basename "${dir%/}") skill=$(basename "${dir%/}")
skill_file="${dir}SKILL.md" skill_file="${dir}SKILL.md"
[ -f "$skill_file" ] || continue [ -f "$skill_file" ] || continue
if [ "$skill" = "skills-perso" ] || grep -qE '\$HOME/\.claude/agents/|~/\.claude/agents/|\.claude/agents/' "$skill_file" 2>/dev/null; then if is_personal "$skill_file" "$skill"; then
echo "$skill" echo "$skill"
found=$((found + 1))
fi fi
done done
if [ "$found" -eq 0 ]; then
echo "⚠️ No personal skills detected. Either only framework skills installed," >&2
echo " or no SKILL.md carries 'owner: user' marker / agent reference." >&2
echo " To mark a skill as personal, add 'owner: user' to its frontmatter." >&2
exit 1
fi
``` ```
## Steps ## Steps