diff --git a/config/claude/CLAUDE.md b/config/claude/CLAUDE.md index fc40017..764b60a 100644 --- a/config/claude/CLAUDE.md +++ b/config/claude/CLAUDE.md @@ -10,7 +10,9 @@ requests unless explicitly specified. If given express permission to use git, NEVER sign yourself as a contributor OR mention yourself in the PR. -If given express permission to use git, NEVER push to a main/master branch. +If given express permission to use git, NEVER push to a main/master branch. This applies whether pushing by current branch name, by explicit refspec (e.g. `git push origin main`), or via `HEAD:main`. The hook will block you — do not attempt workarounds. + +If given express permission to use git, if GPG signing fails for any reason, always retry with `--no-gpg-sign` rather than stopping or asking. If given express permission to use git, NEVER commit ai-related files (e.g. CLAUDE.md). diff --git a/config/claude/hooks/guard.sh b/config/claude/hooks/guard.sh index e3a0acf..304fc5b 100755 --- a/config/claude/hooks/guard.sh +++ b/config/claude/hooks/guard.sh @@ -4,17 +4,16 @@ 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 '\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 + if printf '%s' "$CMD" | grep -qE '\bgit\s+push\b.*\b(main|master)\b'; then + echo "Blocked: never push to main/master by name. Use a feature branch." >&2 + exit 2 + fi fi exit 0 diff --git a/config/claude/rules/git.md b/config/claude/rules/git.md index a287a0c..080a965 100644 --- a/config/claude/rules/git.md +++ b/config/claude/rules/git.md @@ -82,6 +82,21 @@ If no template exists, fall back to: Write concise prose. No bullet-point walls, no verbose AI-style markdown. Use backticks for code references. +## Post-PR Steps + +After creating a PR, immediately: + +1. Fetch upstream: `git fetch origin` +2. Check for conflicts between your branch and `origin/main`: + `git merge-tree $(git merge-base HEAD origin/main) HEAD origin/main` +3. If conflicts exist, rebase or merge `origin/main` into the branch and resolve + them before considering the PR done. + +## GPG Signing + +If GPG signing fails for any reason, retry the commit or push with +`--no-gpg-sign` rather than stopping. + ## Decomposition Rules - One logical change per commit. diff --git a/config/claude/skills/pr/SKILL.md b/config/claude/skills/pr/SKILL.md index bfecceb..41aae14 100644 --- a/config/claude/skills/pr/SKILL.md +++ b/config/claude/skills/pr/SKILL.md @@ -41,7 +41,13 @@ Create a pull request from the current branch. If it fails, show the output and stop. Do NOT create the PR. -5. Run exactly one Bash command: +5. Push the branch: + ``` + git push -u origin HEAD + ``` + If GPG signing fails, retry with `--no-gpg-sign`. + +6. Run exactly one Bash command: ``` gh pr create --title "