| name | hooks |
| description | This skill should be used when the user asks to "set up auto-update", "install codeindex hooks", "auto-update README_AI.md", "keep docs in sync", or wants Git hooks that automatically refresh codeindex README_AI.md files when code changes are committed. |
| version | 0.1.3 |
codeindex:hooks — Auto-Update Hooks Setup
Set up Git hooks so README_AI.md files automatically refresh when code changes are committed.
Prereq: codeindex CLI must be on PATH. If not, install with pipx install ai-codeindex.
How It Works
Architecture: Thin wrapper shell script → Python logic in the installed codeindex package (auto-upgradeable via pipx upgrade ai-codeindex).
When a developer commits code changes:
- Shell wrapper skips doc-only commits (loop guard), activates venv if present
- Delegates to
codeindex hooks run post-commit (Python entry point)
codeindex affected --json analyzes the change scope
codeindex scan regenerates structural README_AI.md for affected directories
- Updated README_AI.md files are auto-committed
Key: Hook only updates structural content. AI blockquote descriptions
(module purpose) are not regenerated per-commit — run codeindex scan-all --ai
to refresh those.
Upgrade: pipx upgrade ai-codeindex auto-updates hook logic.
No need to reinstall hooks after package upgrade.
Prerequisites Check
which codeindex || echo "Not installed. Run: pipx install ai-codeindex"
git rev-parse --is-inside-work-tree
cat .codeindex.yaml 2>/dev/null || codeindex init --yes
Setup Workflow
Step 1: Check Current Hook Status
codeindex hooks status
Shows which hooks are installed (pre-commit, post-commit, pre-push).
Step 2: Install Post-Commit Hook
codeindex hooks install post-commit
codeindex hooks install --all
If a custom post-commit hook already exists, it's backed up automatically.
Step 3: Configure Hook Behavior
Edit .codeindex.yaml:
hooks:
post_commit:
enabled: true
mode: auto
max_dirs_sync: 2
Modes:
| Mode | Behavior |
|---|
auto | Smart: sync for small changes (≤ max_dirs_sync), async otherwise |
sync | Always wait for update to complete before returning |
async | Always run in background (non-blocking) |
prompt | Show notification but don't auto-update; user runs codeindex affected --update manually |
disabled | Hook installed but inactive |
Step 4: Verify
codeindex hooks status
echo "# test" >> some_file.py
git add some_file.py && git commit -m "test: verify auto-update hook"
git log --oneline -2
Step 5: Generate Initial Index (if not done)
Hook only updates existing README_AI.md files. Generate the initial index first:
codeindex scan-all
git add -A && git commit -m "docs: initial README_AI.md generation"
Uninstalling
codeindex hooks uninstall post-commit
codeindex hooks uninstall --all
Upgrading
Usually not needed — pipx upgrade ai-codeindex updates the Python logic the shell wrapper invokes.
Only if release notes say "reinstall hooks":
codeindex hooks install post-commit --force
Troubleshooting
| Problem | Solution |
|---|
| Hook not triggering | codeindex hooks status — must show "installed" |
| Infinite commit loop | Shouldn't happen (wrapper skips doc-only commits). If it does, codeindex hooks uninstall post-commit |
| Hook too slow | mode: async in .codeindex.yaml |
| Want manual control | mode: prompt — notification only, run codeindex affected --update yourself |
| Virtual env not found | Ensure .venv/ or venv/ exists at project root, or hook will still try codeindex from PATH |
| Old hook style | codeindex hooks install post-commit --force upgrades to thin wrapper |