chore(claude): add repo conventions and agent guardrails
This commit is contained in:
1 parent
b56ea412de
commit
6d404e2b21
9 files changed
+411
No files matched your search
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# Stop hook: makes Claude fix lint errors before it can finish a reply.
|
||||
#
|
||||
# When YAML files have uncommitted changes, run yamllint and ansible-lint from
|
||||
# .venv. On failure, exit 2 sends the errors back to Claude. It never contacts a
|
||||
# host. If .venv doesn't exist it does nothing, and CI still runs both linters.
|
||||
input=$(cat)
|
||||
# Set when Claude is already continuing because of this hook; stopping here
|
||||
# prevents an endless loop if it can't fix the error.
|
||||
[[ "$(jq -r '.stop_hook_active // false' <<<"$input")" == "true" ]] && exit 0
|
||||
cd "$CLAUDE_PROJECT_DIR" || exit 0
|
||||
|
||||
[[ -x .venv/bin/yamllint && -x .venv/bin/ansible-lint ]] || exit 0
|
||||
# -uall lists files inside new folders, not just the folder.
|
||||
git status --porcelain -uall | grep -qE '\.ya?ml$|\.j2$|\.ansible-lint$' || exit 0
|
||||
|
||||
failed=0
|
||||
for check in ".venv/bin/yamllint --strict ." ".venv/bin/ansible-lint"; do
|
||||
if ! out=$($check 2>&1); then
|
||||
echo "'$check' failed, fix before finishing:" >&2
|
||||
tail -n 30 <<<"$out" >&2
|
||||
failed=1
|
||||
fi
|
||||
done
|
||||
[[ $failed -eq 1 ]] && exit 2
|
||||
exit 0
|
||||
Reference in new issue
Block a user