Skip to content

feat: add automated plugin validation scripts#112

Open
gn00295120 wants to merge 3 commits intoanthropics:mainfrom
gn00295120:feat/plugin-validation-scripts
Open

feat: add automated plugin validation scripts#112
gn00295120 wants to merge 3 commits intoanthropics:mainfrom
gn00295120:feat/plugin-validation-scripts

Conversation

@gn00295120
Copy link

@gn00295120 gn00295120 commented Mar 12, 2026

Summary

  • Adds scripts/validate-plugin.sh to validate a single plugin's structure and content
  • Adds scripts/validate-all.sh to run validation across all plugins in the repository
  • Zero external dependencies — only bash + python3 (for JSON parsing)

What It Validates

Check Level
.claude-plugin/plugin.json exists and is valid JSON FAIL
plugin.json has required fields (name, version, description) FAIL
commands/*.md files have YAML frontmatter with description FAIL
skills/*/SKILL.md files have frontmatter with name and description FAIL
.mcp.json is valid JSON with mcpServers key WARN
~~ placeholders have matching CONNECTORS.md WARN

Usage

# Validate a single plugin
./scripts/validate-plugin.sh sales/

# Validate all plugins
./scripts/validate-all.sh

Current Results

19 plugins discovered, all pass (5 warnings on cowork-plugin-management for ~~ 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

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>
Copilot AI review requested due to automatic review settings March 12, 2026 03:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.sh to validate a single plugin directory (manifest JSON, command/skill frontmatter, optional MCP config, and ~~ placeholder conventions).
  • Introduces scripts/validate-all.sh to 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.

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 .
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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 .

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in fc46bb7 — changed to [[:space:]]*.

Comment on lines +23 to +26
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 " $*"; }
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in fc46bb7 — replaced echo -e with printf.

Comment on lines +33 to +35
echo -e "${RED}ERROR:${RESET} validate-plugin.sh not found or not executable at:" >&2
echo " $VALIDATE_SCRIPT" >&2
exit 1
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in fc46bb7 — replaced echo -e with printf.

- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create automated validation scripts for plugin structure and MCP configuration

2 participants