validate-agent.sh: don't abort at the first warning (set -e + ((x++))) and stop false-flagging valid agents - #89404
Open
bcherny wants to merge 1 commit into
Open
validate-agent.sh: don't abort at the first warning (set -e + ((x++))) and stop false-flagging valid agents#89404bcherny wants to merge 1 commit into
bcherny wants to merge 1 commit into
Conversation
…) and stop false-flagging valid agents Two defects made the validator fail on plugin-dev's own agent files (#83803): 1. Under `set -e`, `((warning_count++))` / `((error_count++))` return a nonzero status when the counter was 0, so the script died at the first warning or error instead of finishing the run. Increments now use `count=$((count + 1))`, which always returns 0. 2. Field extractions like `TOOLS=$(... | grep '^tools:' ...)` aborted the script under `set -e` when the field was absent (grep exits 1 on no match), instead of reporting the missing field. They now end in `|| true`. 3. The description check only read the first physical line of the `description:` value, so multi-line descriptions with <example> blocks (as in plugin-dev's own agents) were false-flagged as missing examples. The extraction now captures the full multi-line value. Adds validate-agent.test.sh: plugin-dev's own agents must exit 0, a warning-only file must complete with exit 0, and an invalid file must still exit 1 with all errors reported. No-Verification-Needed: standalone shell script in the public repo; driven end-to-end directly plus new regression harness
bcherny
enabled auto-merge (squash)
August 25, 2026 02:25
This was referenced Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes public issue #83803
The plugin-dev skill's
validate-agent.shfailed on plugin-dev's own agent files. Three root causes, allset -euo pipefailinteractions:Abort at the first warning.
((warning_count++))/((error_count++))evaluate the arithmetic expression, and((expr))returns a nonzero exit status when the expression's value is 0 — so the first increment from 0 killed the script underset -e, mid-run, with exit 1. All increments now usecount=$((count + 1)), which is an assignment and always returns 0.Abort on any absent frontmatter field. Extractions like
TOOLS=$(echo "$FRONTMATTER" | grep '^tools:' | ...)propagate grep's exit 1 (no match) into the assignment, aborting the script instead of reporting the missing field. Each extraction now ends in|| true.False "missing <example> blocks" warning.
DESCRIPTIONwas extracted withgrep '^description:', which only captures the first physical line — but plugin-dev's own agents use multi-line descriptions whose<example>blocks sit on later lines, so valid agents were flagged. The extraction now captures the full multi-line value (fromdescription:up to the next top-level agent key).Verification (all three plugin-dev agents previously died at the first warning with exit 1):
agents/agent-creator.md,agents/plugin-validator.md,agents/skill-reviewer.md→ all checks pass, exit 0New
Fixed validate-agent.sh aborting at the first warning and rejecting valid agent filesvalidate-agent.test.shnext to the script covers all three cases as a regression test.🤖 Generated with Claude Code