feat: add automated plugin validation scripts#112
feat: add automated plugin validation scripts#112gn00295120 wants to merge 3 commits intoanthropics:mainfrom
Conversation
Adds scripts/validate-plugin.sh and scripts/validate-all.sh to give contributors and CI a fast, zero-dependency way to check plugin health. Closes anthropics#18. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds repository-local validation tooling to standardize and automate checks for plugin manifests/config and markdown metadata, addressing issue #18 and making it easier to catch formatting/structure mistakes early.
Changes:
- Introduces
scripts/validate-plugin.shto validate a single plugin directory (manifest JSON, command/skill frontmatter, optional MCP config, and~~placeholder conventions). - Introduces
scripts/validate-all.shto discover all plugins (by.claude-plugin/plugin.json) and run validation across the repo with an overall summary.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| scripts/validate-plugin.sh | Implements per-plugin validation checks and summarizes pass/fail/warn counts. |
| scripts/validate-all.sh | Discovers plugin directories and runs the per-plugin validator across the repository with a consolidated report. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
scripts/validate-plugin.sh
Outdated
| local file="$1" | ||
| local field="$2" | ||
| # frontmatter is between the first and second '---' lines | ||
| awk '/^---/{c++; if(c==2) exit} c==1 && /^'"$field"'\s*:/' "$file" | grep -q . |
There was a problem hiding this comment.
has_frontmatter_field uses an awk regex with \s* to match whitespace before the colon. \s isn’t portable in many awk implementations (e.g., BSD awk), so this won’t reliably match whitespace and can cause false negatives. Prefer a POSIX character class like [[:space:]]* (or [ \t]*) in the regex.
| awk '/^---/{c++; if(c==2) exit} c==1 && /^'"$field"'\s*:/' "$file" | grep -q . | |
| awk '/^---/{c++; if(c==2) exit} c==1 && /^'"$field"'[[:space:]]*:/' "$file" | grep -q . |
scripts/validate-plugin.sh
Outdated
| pass() { echo -e " ${GREEN}[PASS]${RESET} $*"; } | ||
| fail() { echo -e " ${RED}[FAIL]${RESET} $*"; FAIL_COUNT=$((FAIL_COUNT + 1)); } | ||
| warn() { echo -e " ${YELLOW}[WARN]${RESET} $*"; WARN_COUNT=$((WARN_COUNT + 1)); } | ||
| info() { echo -e " $*"; } |
There was a problem hiding this comment.
These helpers rely on echo -e for escape sequences. echo flag handling is not consistent across environments (even in bash depending on settings), which can make output formatting unreliable. Prefer printf for colored/status output to avoid portability issues.
scripts/validate-all.sh
Outdated
| echo -e "${RED}ERROR:${RESET} validate-plugin.sh not found or not executable at:" >&2 | ||
| echo " $VALIDATE_SCRIPT" >&2 | ||
| exit 1 |
There was a problem hiding this comment.
This script uses echo -e for colored output. echo’s handling of -e and backslash escapes is not fully portable and can behave differently across environments. Prefer printf for escape sequences to make output reliable.
- Replace echo -e with printf for reliable escape sequence handling - Replace \s with [[:space:]] in awk regex for BSD awk compatibility - Use printf %s/%d format specifiers instead of variable interpolation Addresses review feedback on PR anthropics#112.
Summary
scripts/validate-plugin.shto validate a single plugin's structure and contentscripts/validate-all.shto run validation across all plugins in the repositoryWhat It Validates
.claude-plugin/plugin.jsonexists and is valid JSONplugin.jsonhas required fields (name, version, description)commands/*.mdfiles have YAML frontmatter withdescriptionskills/*/SKILL.mdfiles have frontmatter withnameanddescription.mcp.jsonis valid JSON withmcpServerskey~~placeholders have matchingCONNECTORS.mdUsage
Current Results
19 plugins discovered, all pass (5 warnings on
cowork-plugin-managementfor~~placeholders without CONNECTORS.md — expected for a meta-plugin).Motivation
From issue discussion: "It's proven hard to develop these locally. Getting the formatting correct... it's easy to make a mistake but hard to spot." — @Rucknar
Fixes #18