pre_commit_check
Analyze a staged diff and affected file paths to detect anti-patterns, stale memory anchors, and violated conventions. Returns a block recommendation and summary to prevent problematic commits before they are finalized.
Instructions
One-shot 'should I block this commit?' check. Combines three signals, all run internally by this one call — you do not invoke them separately:
anti_patterns_check — known gotchas/attempts that match the diff
mem_for_files — conventions/decisions anchored to touched files
mem_verify — memories whose anchors are stale (knowledge may be wrong)
This is the COMBINED diff-scan layer — sensors, anti-patterns and stale anchors in a single call.
hivelore enforce check is the git-hook gate that runs the same combination at commit time.
USE FROM A GIT HOOK or before finalizing a non-trivial change.
PARAMETERS:
diff — raw unified diff text (e.g. git diff --cached)
paths — affected file paths (project-relative)
block_on — 'any' | 'high-confidence' (default) | 'never'
semantic — use embeddings in anti_patterns_check (default true)
RETURNS: { should_block, summary, warnings, relevant_memories, stale_anchors }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| diff | No | Raw unified diff text to scan. If omitted, only `paths` is used. When called from a pre-commit hook, pipe the output of `git diff --cached`. | |
| paths | No | Project-relative paths affected by the change. At least one of `diff` or `paths` should be provided. | |
| block_on | No | When to set should_block=true: 'any' = any warning blocks; 'high-confidence' = only warnings from authoritative/trusted memories block; 'never' = report only, never block. | high-confidence |
| semantic | No | Enable semantic search in anti_patterns_check (requires embeddings index). | |
| anchored_blocks | No | When true, ALSO block a high-confidence anti-pattern (attempt/gotcha) that is anchored to a touched file AND corroborated by the diff (literal token overlap, or semantic >= 0.45) — not just very strong semantic matches. Powers the 'anchored' enforcement gate. Config/docs-only commits are still downgraded. Default false preserves the soft, semantic-only blocking behavior. |