Skip to content

feat(hooks): Add PostToolUse hooks for intelligent logging prompts#4

Merged
albertnahas merged 1 commit intoalbertnahas:mainfrom
songer1993:feat/enhanced-hooks
Jan 9, 2026
Merged

feat(hooks): Add PostToolUse hooks for intelligent logging prompts#4
albertnahas merged 1 commit intoalbertnahas:mainfrom
songer1993:feat/enhanced-hooks

Conversation

@songer1993
Copy link
Contributor

Summary

Add new hooks that provide contextual aissist command suggestions at the right moments:

  • prompt-hints.sh: Enhanced UserPromptSubmit hook with datetime + keyword detection
  • post-edit.sh: PostToolUse hook for Edit/Write tools - reminds to log after file modifications
  • post-bash.sh: PostToolUse hook for Bash - detects git commits, test runs, builds, and deployments

Features

Keyword Detection (prompt-hints.sh)

User Says Suggestion
"how did I", "previously", "last time" /aissist:recall
"my goal", "progress", "deadline" /aissist:chat
numbered items, "todo:", "tasks:" /aissist:todo
"summary", "report", "what have I done" /aissist:report

Post-Tool Reminders

  • After file edits: File modified: auth.ts - consider /aissist:log if this completes a task
  • After git commits: Git commit detected - use /aissist:log to record this work
  • After tests/builds: Tests completed - consider /aissist:log if this concludes a task

Code Quality Improvements

Based on Gemini code review:

  • Added jq dependency checks with graceful fallbacks
  • Used here-strings (<<<) instead of echo for safer variable handling
  • Added word boundaries (\b) to regex patterns to reduce false positives
  • Used grep -i for case-insensitive matching instead of tr

Backward Compatibility

  • add-datetime.sh kept for users who may reference it directly
  • prompt-hints.sh is now the default UserPromptSubmit handler (includes datetime)

Test Plan

  • Verify hooks trigger correctly in new Claude Code sessions
  • Test keyword detection with various prompt patterns
  • Confirm jq fallback works when jq is not installed
  • Test PostToolUse hooks after Edit/Write/Bash operations

🤖 Generated with Claude Code

Add new hooks that provide contextual aissist command suggestions:

- prompt-hints.sh: Enhanced UserPromptSubmit hook with datetime + keyword
  detection. Suggests /aissist:recall, /aissist:chat, /aissist:todo, or
  /aissist:report based on user prompt content.

- post-edit.sh: PostToolUse hook for Edit/Write tools. Reminds to log
  work after file modifications.

- post-bash.sh: PostToolUse hook for Bash tool. Detects git commits,
  test runs, builds, and deployments to suggest logging.

Improvements based on code review:
- Added jq dependency checks with graceful fallbacks
- Used here-strings (<<<) instead of echo for safer variable handling
- Added word boundaries (\b) to regex patterns to reduce false positives
- Used grep -i for case-insensitive matching instead of tr
- Added .tool_input.target fallback for different tool implementations

Updated settings.json with PostToolUse matchers for Edit|Write and Bash.
Updated README with comprehensive hooks documentation.

The add-datetime.sh is kept for backward compatibility but prompt-hints.sh
is now the default UserPromptSubmit handler.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@albertnahas albertnahas self-requested a review January 9, 2026 08:57
@albertnahas albertnahas merged commit 246fbba into albertnahas:main Jan 9, 2026
1 check failed
@songer1993 songer1993 deleted the feat/enhanced-hooks branch January 10, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants