Skip to content

fix(plugin-dev): read full multi-line description in validate-agent.sh#76985

Open
AliAltivate wants to merge 1 commit into
anthropics:mainfrom
AliAltivate:fix/validate-agent-multiline-description
Open

fix(plugin-dev): read full multi-line description in validate-agent.sh#76985
AliAltivate wants to merge 1 commit into
anthropics:mainfrom
AliAltivate:fix/validate-agent-multiline-description

Conversation

@AliAltivate

Copy link
Copy Markdown

What

plugins/plugin-dev/skills/agent-development/scripts/validate-agent.sh extracts the agent's description frontmatter with:

DESCRIPTION=$(echo "$FRONTMATTER" | grep '^description:' | sed 's/description: *//')

grep is line-oriented, so this keeps only the first physical line of a multi-line YAML description and drops the continuation lines — which is exactly where the <example> blocks live. Two checks then misfire:

  • desc_length is computed on the truncated first line.
  • the <example> check (grep -q '<example>') always fails.

So every agent with a multi-line description gets a bogus ⚠️ description should include <example> blocks for triggering — including the repo's own plugin-dev agents (agent-creator, plugin-validator, skill-reviewer).

Why it's more than cosmetic (Linux)

On Linux with bash ≥ 4.1, under the script's set -euo pipefail, the ((warning_count++)) that the false warning triggers evaluates to 0 on the first increment, returns exit status 1, and aborts the script. Running the shipped validator on the repo's own agent-creator.md in bash:5.2:

before — dies right after the false warning, no summary, exit 1:

✅ description: 244 characters
⚠️  description should include <example> blocks for triggering
# (script aborts here; exit code 1)

after — runs to completion, exit 0:

✅ All checks passed!

(On macOS bash 3.2 the script doesn't errexit on (( )), so there the same bug surfaces as just the false warning.)

The fix

Extract the full description block — from the description: line up to the next known frontmatter key — so the length and <example> checks run on the complete value:

DESCRIPTION=$(echo "$FRONTMATTER" | awk '
  /^description:/ { found = 1; sub(/^description: */, ""); print; next }
  found && /^(name|model|color|tools):/ { found = 0 }
  found { print }
')

It stops only at name/model/color/tools, not at generic word: lines, because <example> blocks contain column-0 Context: / user: / assistant: lines that a naive next-key match would trip on.

Verification

Before/after on all 15 plugins/**/agents/*.md:

  • 3 false warnings removed (agent-creator, plugin-validator, skill-reviewer)
  • code-simplifier — reported character count corrected (no warning or exit-code change)
  • 11 files produce byte-identical output; no exit-code changes anywhere
  • bash -n clean; the awk program works on BSD awk (macOS) and busybox awk (Alpine)

Out of scope (noted, not fixed here)

The same script has a separate, pre-existing fragility: under set -euo pipefail, grep '^field:' for a missing field and ((count++)) from 0 can each abort the script independently of this bug. Fixing that touches ~12 sites and is a larger change, so I've kept this PR focused. Happy to follow up if that would be useful.

🤖 Generated with Claude Code

validate-agent.sh extracted the description with `grep '^description:'`,
which captures only the first physical line of a multi-line YAML
description and drops the continuation lines where the <example> blocks
live. As a result desc_length was computed on the truncated line and the
<example> check always failed, so every agent with a multi-line
description (agent-creator, plugin-validator, skill-reviewer) got a false
"should include <example> blocks" warning.

On Linux (bash >= 4.1) this was worse than cosmetic: under
`set -euo pipefail`, the `((warning_count++))` triggered by the false
warning returns exit 1 and aborts the script, so the validator exited 1
with no summary when run on the repo's own agents.

Extract the full description block (from `description:` up to the next
known frontmatter key) via awk so the length and <example> checks run on
the complete value. It stops only at name/model/color/tools, not at
generic `word:` lines, because <example> blocks contain
Context:/user:/assistant: lines.

Verified on all 15 plugins/**/agents/*.md: 3 false warnings removed, 11
files byte-identical, no exit-code changes; on Linux (bash 5.2) the
validator now completes (exit 0) instead of aborting.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant