feat(claude): improve ai workflow
This commit is contained in:
parent
e84a22dbcb
commit
902f0f3ad6
11 changed files with 196 additions and 33 deletions
25
config/claude/hooks/guard.sh
Executable file
25
config/claude/hooks/guard.sh
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
INPUT=$(cat)
|
||||
CMD=$(printf '%s' "$INPUT" | jq -r '.tool_input.command // empty')
|
||||
|
||||
if printf '%s' "$CMD" | grep -qE '\bgh\b.*\s(-R|--repo)\b'; then
|
||||
echo "Blocked: do not target other repos with -R/--repo. Run gh commands against the current repo only." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if printf '%s' "$CMD" | grep -qE '\bgh\s+issue\s+create\b'; then
|
||||
echo "Blocked: gh issue create must be run manually or explicitly approved." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if printf '%s' "$CMD" | grep -qE '\bgit\s+push\b'; then
|
||||
BRANCH=$(git branch --show-current 2>/dev/null || true)
|
||||
if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then
|
||||
echo "Blocked: never push directly to $BRANCH. Use a feature branch." >&2
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue