Skip to content

martin1847/evolab / skills/repo-governance-bootstrap

repo-governance-bootstrap

Verified

一次性初始化 AI 协作项目的轻量工程治理骨架。新仓库 / 文档治理初始化时调用(也是 cto-orchestration 接入新项目的第一步)。One-shot governance bootstrap for a new repo.

references/pre-push.template

View on GitHub
#!/usr/bin/env bash
# pre-push — diff-scoped 评审蒸馏门禁(骨架模板,bootstrap 步骤 11 用)。
# 铁律:每一关必须指到一次真实事故 / 评审 finding(清单见 docs/PR_SELF_CHECK.md);禁理论关卡。
# 下沉判据:可机械判定 · 纯 git+grep 毫秒级 · diff-scoped(构建级检查归 engineering-gate / CI)。
# 供给与演化规范:agent-backend-standard/references/selfcheck-gates.md(附录 F)。
#
# Install (once): git config core.hooksPath .githooks
# 基线分支可配:git config hooks.baseline origin/<trunk>(默认 origin/main)
# CI / 本地复跑:pre-push --range origin/main..HEAD
#   (hook 可被 --no-verify 绕过,CI 复跑同一脚本才是硬门。)
set -u

ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" || exit 0
cd "$ROOT" || exit 1
BASELINE="$(git config --get hooks.baseline 2>/dev/null || echo origin/main)"
FAIL=0

# all-zero OID = delete / no remote ref (works for SHA-1 and SHA-256 repos)
is_zero_oid() { case "$1" in *[!0]*) return 1 ;; *) return 0 ;; esac; }

# ---- 关卡函数区 ----
# 每关一个函数;头部注释必须写明:源 finding(PR#/事故一句话)+ 负探针配方(怎么让它红)。
# 示例形状(真 finding 蒸馏后替换,勿保留示例上线):
# check_example() {
#   local range="$1" remote_ref="$2"
#   if git diff --name-only "$range" -- 'some/path/*' | grep -q .; then
#     printf 'pre-push: BLOCKED — <为什么 + 怎么修>\n' >&2
#     FAIL=1
#   fi
# }
# (关卡里别 2>/dev/null 吞 git stderr——driver 已保证 range 可解析,吞掉会让真错误静默放行。)

check_range() {
  local range="$1" remote_ref="${2:-}"
  # 在此逐关调用:
  # check_example "$range" "$remote_ref"
  :
}

# ---- driver:hook 模式(stdin ranges)或 --range 模式(CI / 本地复跑)----
# fail-closed:range 解析不了 = 门没跑,必须非零退出并说清修法——静默 continue 会让
# 整套关卡被无声跳过(冷评审 2026-07-26 实抓:无 baseline 的新分支 push 全程 rc=0)。
range_ok() { git rev-list "$1" >/dev/null 2>&1; }
baseline_range() { # $1 local_sha -> stdout base..sha;解析失败即 fail
  local base
  base=$(git merge-base "$BASELINE" "$1" 2>/dev/null) || {
    echo "pre-push: cannot resolve baseline '$BASELINE' — set it: git config hooks.baseline origin/<trunk>" >&2
    return 1
  }
  echo "$base..$1"
}

if [ "${1:-}" = "--range" ]; then
  # 只收显式 <base>..<head>:单 rev / --all 也能被 rev-list 接受,但 git diff 语义完全不同
  # ——CI 误传单 commit 时关卡会对着干净工作树扫、静默放行(冷评审 R2 实抓)。
  [ $# -eq 2 ] || { echo "usage: pre-push --range <base>..<head>" >&2; exit 2; }
  case "$2" in
    -*) echo "pre-push: bad --range value '$2'" >&2; exit 2 ;;
    *..*) ;;
    *) echo "pre-push: --range needs an explicit <base>..<head> range, got '$2'" >&2; exit 2 ;;
  esac
  range_ok "$2" || { echo "pre-push: unresolvable range '$2'" >&2; exit 2; }
  check_range "$2" ""
else
  while read -r _local_ref local_sha remote_ref remote_sha; do
    is_zero_oid "$local_sha" && continue   # ref delete: nothing to scan
    if is_zero_oid "$remote_sha" || ! range_ok "$remote_sha..$local_sha"; then
      # new branch, or remote OID not in local odb (e.g. shallow) -> fall back to baseline
      range=$(baseline_range "$local_sha") || { FAIL=1; continue; }
      check_range "$range" "$remote_ref"
    else
      check_range "$remote_sha..$local_sha" "$remote_ref"
    fi
  done
fi

exit "$FAIL"
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall