grafana-datasource/.config/AGENTS/skills/validate-plugin.md
Always use the bash commands below directly.
/validate-plugin
Run this from the root of your plugin directory.
Check if npx or docker is available. npx is preferred, docker is the fallback:
RUN_ENGINE=$(command -v npx >/dev/null 2>&1 && echo "npx" || (command -v docker >/dev/null 2>&1 && echo "docker" || echo "none"))
If RUN_ENGINE is none, stop immediately and tell the user: "Neither npx nor docker is installed. Please install Node.js (for npx) or Docker to run the plugin validator."
Extract the plugin ID from src/plugin.json (or plugin.json). Sanitize PLUGIN_ID to only allow characters valid in a Grafana plugin ID:
PLUGIN_ID=$(grep '"id"' < src/plugin.json | sed -E 's/.*"id" *: *"(.*)".*/\1/' | tr -cd 'a-zA-Z0-9._-')
Run the build-plugin skill to build the plugin (frontend and backend if applicable).
Build the plugin zip archive for validation with a timestamp:
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
ZIP_NAME="${PLUGIN_ID}-${TIMESTAMP}.zip"
cp -r dist "${PLUGIN_ID}"
zip -qr "${ZIP_NAME}" "${PLUGIN_ID}"
rm -rf "${PLUGIN_ID}"
Run the validator with JSON output using $RUN_ENGINE from step 1 and $ZIP_NAME from step 4:
If $RUN_ENGINE is npx:
npx --cache .cache/npm -y @grafana/plugin-validator@latest -jsonOutput $ZIP_NAME
If $RUN_ENGINE is docker:
docker run --pull=always \
-v "${PWD}/${ZIP_NAME}:/archive.zip:ro" \
grafana/plugin-validator-cli -jsonOutput /archive.zip
Read and interpret the JSON output. Summarize:
Inform the user that a zip file was created (include the filename) and suggest they remove it manually when done. Do NOT run rm to delete the zip — this tool does not have permission to remove files.