Wire ito validate repo into the pre-commit hook (when missing).
The Ito CLI exposes a config-aware repository validation engine (ito validate repo). Wiring it into the project's pre-commit hook catches common drift (missing gitignore entries, staged commits in the wrong worktree, broken coordination symlinks) before the commit lands.
Detect the pre-commit framework first (read-only — never write). Probe in this order; first match wins:
| System | Marker(s) |
|---|
Prek | .pre-commit-config.yaml AND any of: prek on PATH, mise.toml mentioning prek, or .pre-commit-config.yaml containing a prek: toolchain hint. |
PreCommit | .pre-commit-config.yaml (without prek markers). |
Husky | .husky/ directory OR package.json with a husky key. |
Lefthook | lefthook.yml, lefthook.yaml, .lefthook.yml, or .lefthook.yaml at repo root. |
None | none of the above. |
The Ito CLI exposes the same logic for inspection: ito validate repo --list-rules --json reports the active rule set, and the ito init advisory uses detect_pre_commit_system from ito-core::validate_repo.
Skip the hook setup when:
- the engine reports zero active rules (
ito validate repo --list-rules --json | jq '.rules[] | select(.active)' returns empty); OR
- the framework's config already wires
ito-validate-repo (search for the literal ito-validate-repo or ito validate repo in the framework's config file).
Otherwise, propose the appropriate edit per detected system (see "Per-system edits" below). Always show the proposed diff and require explicit user approval unless --yes was passed; never auto-apply.
Per-system edits
-
Prek / PreCommit (.pre-commit-config.yaml): add a local repo with a pre-commit-stage hook:
- repo: local
hooks:
- id: ito-validate-repo
name: ito validate repo (staged)
entry: ito validate repo --staged --strict
language: system
pass_filenames: false
stages: [pre-commit]
-
Husky (.husky/pre-commit): create or extend the script:
#!/usr/bin/env bash
set -e
ito validate repo --staged --strict
Then ensure the file is executable (chmod +x .husky/pre-commit).
-
Lefthook (lefthook.yml or the project's existing lefthook config): add to the pre-commit block:
pre-commit:
commands:
ito-validate-repo:
run: ito validate repo --staged --strict
-
None: tell the user no pre-commit framework is in use and STOP — do not install one. Suggest they run prek install -t pre-commit (or equivalent) first, then re-run this skill.
Verification
After applying the edit:
- Run
ito validate repo --staged --strict from the project root and confirm exit 0 (or report the issues to the user). This proves the binary is on PATH and the engine accepts the project config.
- For
Prek/PreCommit, also run prek run --all-files --hook-stage pre-commit ito-validate-repo (or the equivalent pre-commit run).
- Stage a fixture file under a coordination directory (e.g.
git add .ito/changes/...) and confirm ito validate repo --staged --strict exits non-zero, then unstage.