Skip to content

Check_hierarchy

FieldValue
TypeSkill Resource
Source~/.copilot/skills/frontend/scripts/check_hierarchy.sh
DescriptionNot specified

Source Content

#!/usr/bin/env bash
# Check meta.title values across a set of story files for hierarchy hygiene:
# consistent "/"-separated Category/Subcategory/Name casing, and no title that
# looks like it was copy-pasted from a filesystem path (backslashes, drive
# letters, leading "./").
#
# Usage: check_hierarchy.sh <dir-or-glob-of-stories-files>
set -uo pipefail
TARGET="${1:-.}"
fail=0
files=$(find "$TARGET" -name '*.stories.tsx' 2>/dev/null)
if [[ -z "$files" ]]; then
echo "⚠️ no *.stories.tsx files found under $TARGET"
exit 0
fi
for f in $files; do
title=$(grep -oE "title:[[:space:]]*['\"][^'\"]+['\"]" "$f" | head -1 | sed -E "s/title:[[:space:]]*.(.*).$/\1/")
if [[ -z "$title" ]]; then
echo "$f: no meta.title found"
fail=1
continue
fi
if [[ "$title" == *"\\"* || "$title" == ./* || "$title" =~ ^[A-Za-z]: ]]; then
echo "$f: title '$title' looks like a filesystem path, not a hierarchy label"
fail=1
elif [[ "$title" != */* ]]; then
echo "⚠️ $f: title '$title' has no Category/Name segment — confirm this is intentional (top-level only)"
else
echo "$f: title '$title'"
fi
done
exit "$fail"