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
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
# Git commit-msg hook: rejects commit messages that don't follow CONVENTIONS.md.
|
||||
#
|
||||
# Checks:
|
||||
# - first line is `<type>(<scope>): <summary>` with a known type, an optional
|
||||
# known scope, and no period at the end
|
||||
# - no AI attribution lines
|
||||
#
|
||||
# Activate once per clone: git config core.hooksPath .githooks
|
||||
msg_file="$1"
|
||||
first_line=$(grep -v '^#' "$msg_file" | head -n1)
|
||||
|
||||
# Let git's own merge/revert/fixup messages through.
|
||||
[[ "$first_line" =~ ^(Merge|Revert|fixup!|squash!) ]] && exit 0
|
||||
|
||||
types='feature|bug|enhancement|chore|docs'
|
||||
|
||||
scopes='ci|claude|inventory|playbooks|roles|scripts|stacks'
|
||||
|
||||
pattern="^($types)(\(($scopes)\))?: .*[^.]$"
|
||||
if ! [[ "$first_line" =~ $pattern ]]; then
|
||||
echo "commit-msg: '$first_line'" >&2
|
||||
echo " expected '<type>(<scope>): <summary>' with no trailing period (see CONVENTIONS.md)" >&2
|
||||
echo " types: ${types//|/ }" >&2
|
||||
echo " scopes: ${scopes//|/ } (optional)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep -qiE '^(Co-Authored-By:.*(claude|anthropic)|.*Generated with \[?Claude)' "$msg_file"; then
|
||||
echo "commit-msg: no AI attribution lines (see CLAUDE.md)" >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in new issue
Block a user