1仕組みと動作原理
環境修復は「すべてを再インストール」ではなく「証拠駆動」:所定の順序でAGENTS.md/CLAUDE.md/ONBOARDING/README/manifest/CIを読み込み、読み取り専用のインベントリスクリプトで実際の技術スタックを特定した上で、最小限の修復を実施。
Use the bundled scripts/check_env.py against the repository root when a Python 3.10+ runner is already available. It detects the declared ecosystem and checks only the relevant toolchain; it does not install dependencies or read secret values.
check_env.pyの検出ロジックは、明示的なロックファイルやマニフェスト(uv.lock、package-lock.json、go.modなど)からパッケージマネージャとランタイムを特定し、読み取り専用コマンドを実行して終了コードとstdout/stderrを保持。
def detect_toolchains(repo: Path) -> list[ToolRequirement]: """Infer package managers and runtimes from explicit manifests/lockfiles."""
「最小限の仕組み」の優先順位付けとhookゲート:日常的な起動同期はAGENTS.md/CLAUDE.mdまたは自然言語指示に委ね、「初回プロンプト前に実行必須」かつホストが検証済みの場合のみSessionStartフックを登録し、必ず事前にdry-runプレビューを実行。
Prefer, in order: direct Agent instruction → project instruction → explicit command → lifecycle hook. A hook is not a more professional version of a sentence.
init_session_start_hook.pyは管理型かつ冪等なhookインストーラー:[auto-repo-setup]タグ付きのSessionStartエントリ1件のみを追加(matcher startup + echoガイダンス)、guideパスの検証、無関係な設定の保持、アトミック書き込み、--removeに対応。
The bundled initializer is Claude Code-specific and installs only a lightweight startup context nudge. It preserves unrelated settings, adds matcher startup, validates the guide path, writes atomically, and is idempotent.
Gitワークフローは自動処理ではなく「ルールゲート+状態説明」:クリーンな状態でのみff-only pullを実行。ローカル変更や履歴の分岐がある場合はstash/merge/rebase/forceの自動実行を禁止し、状態説明を実施。
If the working tree is clean, run git pull --ff-only.
履歴内の機密情報クリーンアップは読み取り専用の候補スキャンのみとし、修復作業は人間に委任:sanitize_history.shは「補助的なチェックのみ」と規定され、SKILL.mdはスキャン結果を候補として扱い、未承認での履歴書き換えコマンド実行を厳禁。
# 注意:此脚本只辅助检查,最终修复(orphan branch / BFG)需要人工确认后执行。
2コア機能
3外部依存関係
| Kind | Dependency / Endpoint |
|---|---|
| cli | git |
| cli | python3 / uv |
| cli | sh/bash |
4推奨統制措置と判定根拠
- scripts/: ローカルスクリプトまたはコマンドの実行: auto-repo-setup/scripts/check_env.py
- 本地工作目录: ファイル読み書きおよび成果物出力: ユーザー確認後にリポジトリ内の .claude/settings.json に書き込み(管理対象 SessionStart フック、init_session_start_hook.py 経由)
5二重目の独立検証
- [ok] check_env.py 只读且不碰 secret — docstring 含『reads secret values』否定句 + 代码仅 git rev-parse/which/shutil.which 探测 + token 扫描零命中。
- [ok] init_session_start_hook.py 行为与 SKILL.md 描述一致(幂等/保留无关设置/原子写) — 脚本 load_settings 校验 JSON 结构并保留 hooks 其余键;update_settings/atomic_write 存在;SKILL.md 原文含『preserves unrelated settings … writes atomically, and is idempotent』同义描述。
- [ok] sanitize_history.sh 永不改写历史 — 脚本头注释『此脚本只辅助检查,最终修复(orphan branch / BFG)需要人工确认后执行』;修复建议仅 echo 输出。
- [ok] Git 门禁(ff-only/不自动 stash/显式批准)有源码依据 — SKILL.md Workflow B 逐条原文存在;Operating principle 4『Never auto-stash, merge, rebase, force, discard, or overwrite local changes…』存在。
- [ok] 无网络外发声明 — scripts/ 三文件 token 扫描仅命中 BFG 文档 URL(输出文案),无任何 fetch/request/curl 调用点。
- [ok] 外部依赖清单(git/python/uv/sh)真实存在 — git:check_env run_cmd 数组含 git;python/uv:SKILL.md 命令与脚本 shebang;sh:sanitize_history.sh shebang。
- [ok] 功能声明 vs 夸大检查 — description 承诺的『Diagnose, repair, and standardize repository setup and safe Git workflows』全部由路由表+脚本+门禁兑现;反例扫描未见越界承诺(无自动破坏性操作、无网络工具)。
- [ok] 元数据(license/stars/commit) — 仓库根 LICENSE 为 MIT (c) 2025 daymade;GitHub API stars=1385、pushed_at=2026-09-09T12:33:29Z;本地 HEAD==pin d5c4678cb5d4fd6acc9c922690df035dbd33d247。
6結論
f95bf84548251fa7…