johnandersen777.bsky.social/knotless
git that lives in your Atmosphere account
Forked from chadtmiller.com/knotless
0
0
#!/usr/bin/env bash
# The docs checked against the code: one Claude Code session per page,
# three at a time, each given harness/docs-audit.md for its page and
# allowed only to read. The docs-audit workflow runs it when asked.
#
# bash harness/docs-audit.sh design/storage.md reference/cli.md ...
#
# Pages are paths under docs/. Each report goes to
# target/docs-audit/<page>.md, and all of them to stdout at the end.
# AUDIT_MODEL picks the model. Fails if any page could not be audited.
set -uo pipefail
cd "$(dirname "$0")/.."
out=target/docs-audit
rm -rf $out && mkdir -p $out
audit() {
local page=$1 name
name=$(echo "$page" | tr / -)
if [ ! -f "docs/$page" ]; then
echo "## docs/$page: no such page" > "$out/$name.md"
return 1
fi
local args=(-p --output-format text --no-session-persistence --tools Read,Grep,Glob)
[ -z "${AUDIT_MODEL:-}" ] || args+=(--model "$AUDIT_MODEL")
# Twenty minutes each, where there is a timeout to hold it to: macOS has
# none, unless coreutils' gtimeout.
local limit=()
limit=($(command -v timeout || command -v gtimeout)) && limit+=(1200)
if ! sed "s|{page}|docs/$page|g" harness/docs-audit.md \
| ${limit[@]+"${limit[@]}"} claude "${args[@]}" > "$out/$name.md" 2> "$out/$name.err"; then
echo "## docs/$page: the session failed" >> "$out/$name.md"
tail -5 "$out/$name.err" >> "$out/$name.md"
return 1
fi
}
export -f audit
export out
status=0
printf '%s\n' "$@" | xargs -P 3 -I{} bash -c 'audit "$1"' _ {} || status=1
cat $out/*.md
exit $status