How to Configure Auto-Updates to Trigger on Git Commits in Understand-Anything
Enable the --auto-update flag in the Understand-Anything CLI to write {"autoUpdate": true} to .understand-anything/config.json, which activates a post-commit Git hook that incrementally patches the knowledge graph after every commit.
Understand-Anything can synchronize its knowledge graph with your source tree automatically using a local post-commit Git hook. When configured according to the source code in Lum1104/Understand-Anything, the system detects structural changes after each commit and updates the stored graph without requiring manual re-runs of the analysis command.
Enable Auto-Updates via the CLI Flag
To activate automatic updates, run the CLI with the --auto-update flag. This command writes the configuration value {"autoUpdate": true} to .understand-anything/config.json in your project root.
The flag definition and configuration logic reside in understand-anything-plugin/skills/understand/SKILL.md. When executed, the CLI ensures the .understand-anything directory exists and updates the JSON configuration file to enable the feature.
# Enable auto-update mode
/understand --auto-update
# Verify the configuration was written
cat .understand-anything/config.json
# Output: { "autoUpdate": true }
How the Post-Commit Hook Works
Once enabled, the repository installer (install.sh on Unix or install.ps1 on Windows) creates a standard Git hook at .git/hooks/post-commit. This hook executes automatically after every git commit, git merge, or similar operation that creates a commit.
The hook reads its instructions from understand-anything-plugin/hooks/hooks.json, which defines the detection logic:
- Detects the commit event triggered by Git.
- Validates configuration by checking that
.understand-anything/config.jsoncontains"autoUpdate": true. - Verifies baselines ensuring that
.understand-anything/meta.jsonandknowledge-graph.jsonexist from a previous analysis run. - Triggers the update by emitting a message that instructs Claude Code (or the host IDE) to execute the instructions in
hooks/auto-update-prompt.md.
Because the hook runs purely on the local machine, it performs these checks without consuming LLM tokens or making external API calls for cosmetic changes.
The Incremental Update Process
The file understand-anything-plugin/hooks/auto-update-prompt.md contains the internal prompt that executes the incremental update. This process performs several deterministic steps:
- Zero-token fingerprint check: Compares file hashes to identify structural changes versus cosmetic edits.
- Source file filtering: Identifies only the files modified in the current commit.
- Ignore rules application: Respects patterns defined in
.understandignoreto exclude irrelevant files. - Graph patching: Runs incremental scripts to update
knowledge-graph.jsonwith new relationships and entities.
If the fingerprint check determines that no structural changes occurred, the system updates only .understand-anything/meta.json with the new commit hash and skips the full re-analysis.
# Example workflow after enabling auto-update
git add src/components/NewFeature.ts
git commit -m "Add authentication helper"
# Console output from the hook:
# [understand-anything] Commit detected with auto-update enabled.
# (The knowledge graph is now patched in the background)
Disable Auto-Updates
To stop automatic updates, use the --no-auto-update flag. This writes {"autoUpdate": false} to the configuration file and prevents the post-commit hook from executing the update logic.
# Disable auto-update mode
/understand --no-auto-update
Prerequisites and Initial Setup
Before the post-commit hook can function, you must complete an initial run of the /understand command. This first run creates the required baseline files:
.understand-anything/meta.json– Stores commit hashes and metadata.knowledge-graph.json– The initial serialized knowledge graph.
Without these files present, the hook logic in hooks/hooks.json will skip the update process because it cannot verify the existence of the baseline graph data.
Summary
- Enable auto-updates by running
/understand --auto-update, which sets"autoUpdate": truein.understand-anything/config.json. - Mechanism relies on a post-commit Git hook installed at
.git/hooks/post-committhat referencesunderstand-anything-plugin/hooks/hooks.json. - Process uses
auto-update-prompt.mdto perform zero-token fingerprint checks and incremental graph patching. - Performance is optimized by updating only
meta.jsonwhen no structural changes are detected. - Disable by running
/understand --no-auto-updateto set the configuration flag tofalse.
Frequently Asked Questions
Where is the auto-update configuration stored?
The configuration is stored in .understand-anything/config.json at your project root. When you run /understand --auto-update, the CLI writes {"autoUpdate": true} to this file, which the post-commit hook checks before triggering any updates.
Does the hook send data to external LLM APIs on every commit?
No. The post-commit hook runs entirely on your local machine and performs deterministic checks (such as fingerprint hashing) before deciding whether to invoke the update process. It only emits a message to trigger the prompt logic in auto-update-prompt.md when structural changes are detected, avoiding unnecessary token consumption for cosmetic changes like comment edits or whitespace adjustments.
What happens if I commit without running /understand first?
The hook checks for the existence of .understand-anything/meta.json and knowledge-graph.json before executing the update logic. If these baseline files are missing (which are created during the first /understand run), the hook will skip the auto-update process silently. You must complete the initial analysis to establish the baseline graph before auto-updates can function.
How do I temporarily skip the auto-update for a specific commit?
There is no built-in "skip" flag for individual commits in the current implementation. To prevent the hook from running on a specific commit, you must temporarily disable auto-updates using /understand --no-auto-update before committing, then re-enable it afterward with /understand --auto-update. Alternatively, you can manually remove or rename the .git/hooks/post-commit file temporarily, though this is not recommended as it disables the hook entirely until reinstalled.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →