diff --git a/content-guards/scripts/validate-markdown.sh b/content-guards/scripts/validate-markdown.sh index f260bcf..f4f2faf 100755 --- a/content-guards/scripts/validate-markdown.sh +++ b/content-guards/scripts/validate-markdown.sh @@ -153,7 +153,20 @@ EOF fi } 2>&1 ); then errors+=("markdownlint-cli2 failed:") - errors+=("$markdownlint_output") + # Cap validator output so a noisy run can't flood Claude's context window. + # Single awk pass counts, caps, and formats the overflow footer. + max_lines=20 + if [[ -n "$markdownlint_output" ]]; then + capped=$(awk -v max="$max_lines" ' + NR <= max { print } + END { + if (NR > max) { + print "…and " (NR - max) " more line(s) (capped at " max "; rerun markdownlint-cli2 manually for the full report)" + } + } + ' <<<"$markdownlint_output") + errors+=("$capped") + fi fi fi