Debug hooks by layers

Hook debugging should distinguish event selection, matcher selection, handler execution, environment, and side effects. Test one layer at a time so a failed formatter is not confused with a matcher that never triggered.

LayerQuestion
EventDid the lifecycle event occur?
MatcherDid the intended path or tool match?
HandlerDid the command receive the expected input?
EnvironmentWere shell, path, and permissions available?
Side effectWhat changed and can it be reversed?

Hook debugging ladder

  1. Record the event in log-only mode.
  2. Use one known-safe path and matcher.
  3. Replace the handler with a harmless report.
  4. Inspect expanded arguments and environment.
  5. Run the real handler on one test file.
  6. Check diff and generated output.
  7. Add blocking only after the earlier steps are stable.
  8. Record a disable path and the next recovery action.

Diagnosis record

Documented diagnosis shape
{"symptom":"hook did not run","event":"afterFileEdit","matcher":"src/**/*.ts","observed":"no report","hypothesis":"matcher syntax differs by version","nextCheck":"inspect current /hooks output","status":"documented example"}

Recovery options

  • Disable the hook for the current session.
  • Return from blocking to log-only.
  • Narrow the matcher.
  • Use a manual command while the integration is investigated.
  • Remove generated side effects before retrying.
  • Record the version-specific behavior and open question.

Stop condition

Canonical lesson source · JavaRush

Open JavaRush material