A

Automated Change Inspector

Comprehensive hook designed for track, file, changes, simple. Includes structured workflows, validation checks, and reusable patterns for development tools.

HookClipticsdevelopment toolsv1.0.0MIT
0 views0 copies

Automated Change Inspector

Inspects and analyzes code changes after every edit operation, providing real-time feedback on code quality, complexity, and potential issues.

When to Use This Hook

Attach this hook when you need to:

  • Get immediate feedback on code quality after every file modification including complexity analysis, pattern violations, and potential bugs
  • Track cumulative code changes within a session to understand the scope and impact of modifications before committing
  • Enforce coding standards automatically by inspecting each edit against configurable rules without waiting for a separate linting step

Consider alternatives when:

  • Your IDE already provides real-time code analysis through language servers and inline diagnostics that cover the same concerns
  • You are making rapid iterative changes where per-edit inspection creates too much overhead and you prefer batch analysis

Quick Start

Configuration

name: automated-change-inspector type: hook trigger: PostToolUse category: development-tools

Example Trigger

# Claude edits src/utils/parser.ts # Hook fires after Edit completes: # Change Inspector: Analyzing modification...

Example Output

Change Inspector: Analysis of src/utils/parser.ts
Lines Changed: 14 (added: 8, modified: 4, removed: 2)
Complexity Delta: +2 (new cyclomatic complexity: 12)
Pattern Check:
  - console.log detected (consider removing for production)
  - Magic number 86400 on line 23 (extract to named constant)
  - Function parseInput now exceeds 30 lines (consider splitting)
Type Safety: All types resolved
Import Analysis: 1 new import added (lodash/merge)
Session Total: 47 lines changed across 6 files
Status: PASS with 3 suggestions

Core Concepts

Change Inspection Overview

AspectDetails
Trigger PointPostToolUse on Edit, MultiEdit, and Write tool operations
Analysis ScopeChanged lines only, with context from surrounding code
Complexity TrackingCyclomatic complexity delta calculated per function
Pattern LibraryConfigurable set of anti-patterns and code smell detectors
Session AccumulatorTracks cumulative changes across the entire session
Severity LevelsInfo, suggestion, warning, and error for graduated feedback

Inspection Workflow

PostToolUse (Edit/MultiEdit/Write)
    |
    v
[Identify changed file and lines]
    |
    v
[Parse changed code region]
    |
    +--- [Complexity analysis] --+
    |                            |
    +--- [Pattern matching] -----+
    |                            |
    +--- [Import analysis] ------+
    |                            |
    +--- [Type safety check] ----+
    |                            |
    v                            v
[Aggregate results] <-----------+
    |
    v
[Update session change accumulator]
    |
    v
[Output formatted report]

Configuration

ParameterTypeDefaultDescription
matcherstringEdit|MultiEdit|WriteTool types that trigger the change inspector
complexity_thresholdinteger15Cyclomatic complexity score that triggers a warning for a function
max_function_linesinteger30Maximum function length in lines before suggesting decomposition
pattern_filestring.claude/inspection-patterns.jsonPath to the configurable anti-pattern definition file
severity_filterstringsuggestionMinimum severity level to display: info, suggestion, warning, or error

Best Practices

  1. Start with suggestion severity and tighten gradually - Begin with the inspector showing all suggestions and gradually raise the severity_filter to warning as your team becomes familiar with the feedback. This prevents information overload during the adoption period.

  2. Customize patterns for your project conventions - The default pattern library covers common anti-patterns, but every project has specific conventions. Add patterns for your framework-specific rules, naming conventions, and architecture boundaries to make the inspector truly useful.

  3. Use the session accumulator for commit preparation - Before committing, review the session total to understand the full scope of changes. This summary helps write accurate commit messages and identify if the changes should be split into multiple focused commits.

  4. Track complexity trends across sessions - Export complexity data from the inspector to track how functions evolve over time. Functions that consistently increase in complexity are candidates for refactoring before they become maintenance burdens.

  5. Integrate with team code review standards - Align the inspector's pattern library with your team's code review checklist. This catches common review feedback automatically, allowing human reviewers to focus on architectural and design concerns.

Common Issues

  1. Inspector reports false positives on generated code - Auto-generated files like API clients or schema types may trigger pattern violations that are not meaningful. Add file path exclusion patterns to skip inspection on generated directories like src/generated/ or __generated__/.

  2. Complexity analysis does not understand framework patterns - React components, Redux reducers, and other framework patterns may have high cyclomatic complexity by nature. Configure framework-specific complexity thresholds or exclude known patterns from complexity scoring.

  3. Session accumulator resets unexpectedly - The accumulator state is stored in memory and resets when the hook process restarts. If you notice the session total resetting, it may indicate the hook is being re-initialized. Persist accumulator state to a temp file for durability across hook restarts.

Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates