From 2e72ee99be1c6592503a4fd83a67b5f119ac284f Mon Sep 17 00:00:00 2001 From: Dachary Date: Tue, 10 Mar 2026 08:56:42 -0400 Subject: [PATCH] Revert "Rework skill validator script (#11)" This reverts commit 7a4ace96f2a4fa0cbaa81b0c1f00c37a0fdcea48. --- .github/scripts/validate-skills.sh | 70 +++++++++++++++++++++++++++ .github/workflows/validate-skills.yml | 9 +++- CONTRIBUTING.md | 23 --------- tools/validate-skills.sh | 60 ----------------------- 4 files changed, 77 insertions(+), 85 deletions(-) create mode 100755 .github/scripts/validate-skills.sh delete mode 100644 CONTRIBUTING.md delete mode 100755 tools/validate-skills.sh diff --git a/.github/scripts/validate-skills.sh b/.github/scripts/validate-skills.sh new file mode 100755 index 0000000..1f8da13 --- /dev/null +++ b/.github/scripts/validate-skills.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# Validates all skill directories changed in a pull request. +# +# Usage: validate-skills.sh +# base-ref The base branch name to diff against (e.g. "main"). +# When omitted or when the remote is unavailable, all skills are validated. +# +# Exit codes: +# 0 All validated skills passed. +# 1 One or more skills failed validation. + +# -e is intentionally omitted: all error paths are handled explicitly, +# so abort-on-error would conflict with the || FAILED=1 accumulator pattern. +set -uo pipefail + +BASE_REF="${1:-}" + +# Find unique skill directories containing files changed in this PR. +# The three-dot diff requires fetch-depth: 0 and a properly configured remote, +# which is always the case on GitHub Actions but may not be in local act runs. +changed_skills=() +if [ -n "$BASE_REF" ]; then + mapfile -t changed_skills < <(git diff --name-only "origin/${BASE_REF}...HEAD" -- skills/ \ + 2>/dev/null \ + | cut -d'/' -f2 \ + | sort -u \ + | grep -v '^$') +fi + +if [ "${#changed_skills[@]}" -eq 0 ]; then + # Fallback: validate all skill directories (e.g. when git remote is unavailable + # in local act testing, or when a PR only deletes files with no remaining dirs). + echo "Could not determine changed skills from git diff; validating all skills." + mapfile -t changed_skills < <(find skills -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sort -u) +fi + +if [ "${#changed_skills[@]}" -eq 0 ]; then + echo "No skill directories found, skipping validation." + exit 0 +fi + +FAILED=0 +for skill in "${changed_skills[@]}"; do + # Skip skills whose directories were deleted in this PR. + if [ ! -d "skills/$skill" ]; then + echo "Skipping deleted skill: $skill" + continue + fi + + # Run validation with markdown output so the result is written to the job + # summary in one pass. --emit-annotations works with any output format, so + # inline PR annotations are still emitted alongside the markdown report. + # We use process substitution to: + # 1. Send all output (including ::error commands) to stdout for GitHub Actions + # 2. Filter out ::error/::warning/::notice lines before writing to the summary + skill-validator check --strict --emit-annotations -o markdown "skills/$skill/" \ + | tee >(grep -v '^::' >> "${GITHUB_STEP_SUMMARY:-/dev/null}") || FAILED=1 +done + +if [ $FAILED -ne 0 ]; then + echo "" + echo "❌ Skill validation failed!" + echo "" + echo "📋 See the Job Summary for detailed validation results:" + echo " https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + echo "" +fi + +exit $FAILED + diff --git a/.github/workflows/validate-skills.yml b/.github/workflows/validate-skills.yml index 4392724..bf8e9b3 100644 --- a/.github/workflows/validate-skills.yml +++ b/.github/workflows/validate-skills.yml @@ -2,12 +2,17 @@ name: Validate Skills on: pull_request: + paths: + - "skills/**" jobs: validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + with: + # Full history is needed so git diff can compare against the base branch + fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v6 @@ -18,5 +23,5 @@ jobs: - name: Install skill-validator run: go install github.com/agent-ecosystem/skill-validator/cmd/skill-validator@latest - - name: Validate all skills - run: bash tools/validate-skills.sh + - name: Validate changed skills + run: bash .github/scripts/validate-skills.sh "${{ github.base_ref }}" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 9d5dac6..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,23 +0,0 @@ -# Contributing - -## Adding a new skill - -To add a new skill, create a new directory in the `skills` directory with the name of the skill. The directory should contain a `SKILL.md` file with the skill's metadata and instructions. You may find the [`skill-creator`](https://github.com/anthropics/skills/tree/main/skills/skill-creator) skill by Anthropic helpful for creating the initial draft. To install in Claude Code, add the `skill-creator` plugin. - -## Testing new skills - -### Structural testing - -Use the `tools/validate-skills.sh` script to test the structural validity of the skill. This script uses the [`skill-validator`](https://github.com/agent-ecosystem/skill-validator) tool to check the skill's metadata and instructions. - -### LLM testing - -Use the `tools/review-skill` skill to have an agent review the skill and interpret the results. On top of the structural validation offered by the `validate-skills.sh` script, it can also perform LLM scoring and provide a summary of the results. - -Exact installation instructions depend on the client, but should be something similar to: - -```bash -mkdir -p ~/.claude/skills && ln -s /tools/review-skill ~/.claude/skills/review-skill -``` - -This creates a symlink to the `review-skill` tool in the `~/.claude/skills` directory so that it can be used in Claude Code. diff --git a/tools/validate-skills.sh b/tools/validate-skills.sh deleted file mode 100755 index 4b28254..0000000 --- a/tools/validate-skills.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# Validates all skill directories. -# -# Exit codes: -# 0 All validated skills passed. -# 1 One or more skills failed validation. - -# -e is intentionally omitted: all error paths are handled explicitly, -# so abort-on-error would conflict with the || FAILED=1 accumulator pattern. -set -uo pipefail - -# Find repository root (script is at tools/validate-skills.sh) -REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" - -# Check if skill-validator is available -if ! command -v skill-validator &> /dev/null; then - echo "❌ skill-validator is not installed." - echo "" - echo "To install it, run:" - echo " brew tap agent-ecosystem/tap" - echo " brew install skill-validator" - echo "--- or ---" - echo " go install github.com/agent-ecosystem/skill-validator/cmd/skill-validator@latest" - echo "" - exit 1 -fi - -FAILED=0 - -# Find and validate all skill directories -for skill_dir in "$REPO_ROOT"/skills/*/; do - # Check if the glob matched anything - [ -d "$skill_dir" ] || continue - - if [ -n "${GITHUB_ACTIONS:-}" ]; then - # In CI: use markdown output with annotations, filter annotations from summary - skill-validator check --strict --emit-annotations -o markdown "$skill_dir" \ - | tee >(grep -v '^::' >> "$GITHUB_STEP_SUMMARY") || FAILED=1 - else - # Local: simple output - skill-validator check --strict "$skill_dir" || FAILED=1 - fi -done - -echo "" -if [ $FAILED -ne 0 ]; then - echo "❌ Skill validation failed!" - if [ -n "${GITHUB_ACTIONS:-}" ]; then - echo "" - echo "📋 See the Job Summary for detailed validation results:" - echo " https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" - fi -else - echo "✅ Skill validation passed!" -fi - -echo "" - -exit $FAILED -