Skip to content

Remove per-skill symlinks pointing into gstack script in README.md is broken #1130

@dgrant

Description

@dgrant

Small issue... this script in README.md is broken:

# 2. Remove per-skill symlinks pointing into gstack/
find ~/.claude/skills -maxdepth 1 -type l 2>/dev/null | while read -r link; do
  case "$(readlink "$link" 2>/dev/null)" in gstack/*|*/gstack/*) rm -f "$link" ;; esac
done

It assumes per-skill entries in ~/.claude/skills are themselves symlinks. But in an actual install, the top-level skill directories are real directories, and only SKILL.md inside each skill directory is symlinked into ~/.claude/skills/gstack/... .

Example:
~/.claude/skills/context-restore/SKILL.md -> ~/.claude/skills/gstack/context-restore/SKILL.md

Because the script uses:
find ~/.claude/skills -maxdepth 1 -type l

it only searches for symlinks directly under ~/.claude/skills and does not find nested SKILL.md symlinks. As a result, it removes nothing.

Fix:

find ~/.claude/skills -mindepth 1 -maxdepth 1 -type d ! -name gstack 2>/dev/null |
while IFS= read -r dir; do
  link="$dir/SKILL.md"
  [ -L "$link" ] || continue
  target=$(readlink "$link" 2>/dev/null) || continue
  case "$target" in
    gstack/*|*/gstack/*)
      rm -rf -- "$dir"
      ;;
  esac
done

and a dry-run version for testing:

remove_file=$(mktemp)
keep_file=$(mktemp)

find ~/.claude/skills -mindepth 1 -maxdepth 1 -type d ! -name gstack 2>/dev/null |
while IFS= read -r dir; do
  link="$dir/SKILL.md"

  if [ -L "$link" ]; then
    target=$(readlink "$link" 2>/dev/null) || target=""
    case "$target" in
      gstack/*|*/gstack/*)
        printf '%s\n' "$dir" >> "$remove_file"
        ;;
      *)
        printf '%s    (SKILL.md symlink target: %s)\n' "$dir" "$target" >> "$keep_file"
        ;;
    esac
  else
    printf '%s    (no symlinked SKILL.md)\n' "$dir" >> "$keep_file"
  fi
done

echo 'Would be removed:'
sort "$remove_file"
echo
echo 'Would NOT be removed:'
sort "$keep_file"

rm -f "$remove_file" "$keep_file"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions