### Install rins_hooks Interactively Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Initiates an interactive installation process for rins_hooks, guiding the user through the setup. ```bash rins_hooks install --interactive ``` -------------------------------- ### Project rins_hooks Installation Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Installs hooks specifically for the current project using the --project flag. ```bash rins_hooks install auto-commit --project ``` -------------------------------- ### Creating Custom Hooks with Rins Hooks Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Demonstrates how to create custom hooks by extending the `HookBase` class in JavaScript. Includes constructor and execute method examples. ```javascript const HookBase = require('rins_hooks/src/hook-base'); class MyCustomHook extends HookBase { constructor(config = {}) { super('my-custom-hook', config); } async execute(input) { // Your hook logic here return this.success({ message: 'Hook executed successfully' }); } } ``` -------------------------------- ### Global rins_hooks Installation Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Installs hooks globally for all Claude Code projects using the --user flag. ```bash rins_hooks install auto-commit --user ``` -------------------------------- ### Install rins_hooks Globally Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Installs the rins_hooks package globally using npm, making its commands available system-wide. ```bash npm install -g rins_hooks ``` -------------------------------- ### rins_hooks CLI Commands Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Provides a comprehensive overview of the rins_hooks command-line interface for managing hooks, including installation, management, and uninstallation. ```APIDOC rins_hooks: install [--interactive | --all | --dry-run | ...]: Installs hooks. Use --interactive for guided setup, --all for all hooks, or specify individual hooks. --dry-run previews changes. list: Lists all available hooks. status: Shows the installation status of configured hooks. config [--show | --validate]: Manages configuration. --show displays current settings, --validate checks configuration integrity. doctor: Runs diagnostics to check the setup and identify potential issues. uninstall [ ... | --all]: Uninstalls specified hooks or all hooks if --all is used. ``` -------------------------------- ### Local rins_hooks Installation Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Installs hooks locally without committing them to version control using the --local flag. ```bash rins_hooks install auto-commit --local ``` -------------------------------- ### Install Specific rins_hooks Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Installs specified hooks, such as 'auto-commit' and 'code-formatter', for the current project or globally. ```bash rins_hooks install auto-commit code-formatter notification ``` -------------------------------- ### Rins Hooks CLI Troubleshooting Commands Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Provides essential bash commands for troubleshooting Rins Hooks, including checking installation status, validating configurations, and running diagnostics. ```bash rins_hooks status rins_hooks config --validate rins_hooks doctor ``` -------------------------------- ### rins_hooks Diagnostics Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Executes the 'rins_hooks doctor' command to perform diagnostics on the current setup, checking Node.js compatibility, Claude Code installation, Git status, and configuration validity. ```bash rins_hooks doctor ``` -------------------------------- ### BatchTool Decomposition Example Source: https://github.com/rinadelph/rins_hooks/blob/main/CLAUDE_CODE_TOOL_ANALYSIS.md Illustrates how Claude Code's BatchTool decomposes batch operations into individual tool calls, affecting hook triggers. A 'Read + Edit' sequence results in only the 'Edit' operation triggering a hook. ```text User Request: "Read file X and edit it" ↓ Claude Code BatchTool decomposes to: 1. Read(file_X) → No hook (doesn't match pattern) 2. Edit(file_X) → Hook triggered ``` -------------------------------- ### Adding Custom Formatters to Code Formatter Hook Source: https://github.com/rinadelph/rins_hooks/blob/main/docs/HOOKS.md Example of how to add custom formatters for new file types or languages to the Code Formatter hook configuration. ```json { "formatters": { ".vue": "prettier --parser vue --write", ".php": "php-cs-fixer fix", ".rb": "rubocop -A" } } ``` -------------------------------- ### Rins Hooks API Reference Source: https://github.com/rinadelph/rins_hooks/blob/main/tool-test-files/batch-a.txt API documentation for the Rins Hooks library, covering core functionalities like hook registration, event listening, and hook execution. ```APIDOC register_hook(event_name: str, handler: callable, priority: int = 100) Registers a handler function for a specific event. Parameters: event_name: The name of the event to hook into. handler: The function to be called when the event is triggered. priority: The execution order of the hook (lower numbers execute first). addEventListener(event_name: str, handler: callable) Adds an event listener for a given event name. Parameters: event_name: The name of the event to listen for. handler: The function to execute when the event occurs. run_hook(event_name: str, *args, **kwargs) Executes all registered hooks for a given event name. Parameters: event_name: The name of the event to run. *args: Positional arguments to pass to the hook handlers. **kwargs: Keyword arguments to pass to the hook handlers. Returns: A list of results from the executed hook handlers. ``` -------------------------------- ### Rins Hooks Configuration Source: https://github.com/rinadelph/rins_hooks/blob/main/docs/HOOKS.md Defines settings for desktop notifications, integration webhooks, and custom command callbacks. ```json { "desktopNotifications": true, "soundEnabled": false, "iconPath": "", "notificationTypes": { "task_completed": { "enabled": true, "title": "Claude Code Task Completed", "message": "Task has been completed successfully" }, "permission_required": { "enabled": true, "title": "Claude Code Permission Required", "message": "Claude Code is waiting for your permission" }, "error": { "enabled": true, "title": "Claude Code Error", "message": "An error occurred during task execution" }, "idle": { "enabled": false, "title": "Claude Code Idle", "message": "Claude Code is waiting for input" } }, "integrations": { "slack": { "enabled": false, "webhook": "https://hooks.slack.com/services/", "channel": "#general" }, "discord": { "enabled": false, "webhook": "https://discord.com/api/webhooks/" }, "teams": { "enabled": false, "webhook": "https://outlook.office.com/webhook/" } }, "customCommands": { "onTaskCompleted": "", "onError": "echo 'Error occurred' >> /tmp/claude-errors.log", "onIdle": "" } } ``` -------------------------------- ### Registering a Hook Source: https://github.com/rinadelph/rins_hooks/blob/main/tool-test-files/batch-c.txt Demonstrates how to register a new hook with the Rins Hooks system. This involves defining the hook's name, type, and the function to be executed when the hook is triggered. ```python from rins_hooks.hooks import Hooks hooks = Hooks() def my_hook_function(data): print(f"Hook executed with data: {data}") hooks.register_hook('my_event', my_hook_function, hook_type='event') ``` -------------------------------- ### Custom Command Template Variables Source: https://github.com/rinadelph/rins_hooks/blob/main/docs/HOOKS.md Illustrates how to use template variables within custom commands for dynamic execution. ```json { "customCommands": { "onTaskCompleted": "echo '{{title}}: {{message}}' | mail -s 'Claude Code Update' user@example.com", "onError": "logger -t claude-code 'Error: {{message}}'", "onIdle": "osascript -e 'display notification \"{{message}}\" with title \"{{title}}\" '" } } ``` -------------------------------- ### Custom Hook Configuration File (JSON) Source: https://github.com/rinadelph/rins_hooks/blob/main/docs/HOOKS.md Metadata and configuration for a custom hook, including name, version, requirements, and platform compatibility. ```json { "name": "my-custom-hook", "description": "Description of what your hook does", "version": "1.0.0", "tags": ["custom", "example"], "requirements": ["git", "node"], "platforms": ["linux", "darwin", "win32"], "matcher": "Edit|Write|MultiEdit", "timeout": 60, "defaultConfig": { "enabled": true, "customOption": "default-value" } } ``` -------------------------------- ### JavaScript Event Listener Source: https://github.com/rinadelph/rins_hooks/blob/main/tool-test-files/batch-a.txt Shows how to set up an event listener in JavaScript to react to specific events. This is useful for frontend interactions or Node.js event-driven architectures. ```javascript import { addEventListener } from 'rins_hooks/event'; function handleEvent(payload) { console.log('Received event:', payload); } addEventListener('user_login', handleEvent); ``` -------------------------------- ### Custom Hook Implementation (JavaScript) Source: https://github.com/rinadelph/rins_hooks/blob/main/docs/HOOKS.md A template for creating a custom hook by extending the HookBase class, including execution logic and configuration. ```javascript const HookBase = require('rins_hooks/src/hook-base'); class MyCustomHook extends HookBase { constructor(config = {}) { super('my-custom-hook', config); } getDefaultConfig() { return { enabled: true, matcher: "Edit|Write|MultiEdit", timeout: 60, description: "My custom hook description", // Add your custom config options here }; } async execute(input) { try { const { tool_name, tool_input, session_id } = input; // Your hook logic here console.log(`Processing ${tool_name} tool with input:`, tool_input); // Return success return this.success({ message: 'Hook executed successfully', data: { /* any additional data */ } }); } catch (error) { return this.error(`Hook failed: ${error.message}`); } } // Optional: Add validation logic async validate() { // Add custom validation return super.validate(); } } // Enable direct execution if (require.main === module) { (async () => { try { const input = await HookBase.parseInput(); const hook = new MyCustomHook(); const result = await hook.execute(input); HookBase.outputResult(result); } catch (error) { console.error(`Hook error: ${error.message}`); process.exit(1); } })(); } module.exports = MyCustomHook; ``` -------------------------------- ### Defining a Hook Type Source: https://github.com/rinadelph/rins_hooks/blob/main/tool-test-files/batch-c.txt Illustrates how to define a new type of hook. This allows for categorization and specific handling of different hook behaviors within the system. ```python from rins_hooks.hooks import Hooks hooks = Hooks() hooks.register_hook_type('validation', description='For data validation checks') def validation_hook(data): if 'required_field' not in data: raise ValueError('Missing required field') return True hooks.register_hook('validate_data', validation_hook, hook_type='validation') ``` -------------------------------- ### Notification Hook Configuration Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Sets up the Notification hook, enabling desktop notifications and configuring integrations for services like Slack and Discord. ```json { "desktopNotifications": true, "integrations": { "slack": { "enabled": true, "webhook": "https://hooks.slack.com/...", "channel": "#dev" }, "discord": { "enabled": true, "webhook": "https://discord.com/api/webhooks/..." } } } ``` -------------------------------- ### Internal Command vs. Tool Triggering Source: https://github.com/rinadelph/rins_hooks/blob/main/CLAUDE_CODE_TOOL_ANALYSIS.md Explains why internal Claude Code commands like `/compact` do not trigger hooks, contrasting them with memory management tools that are implemented as proper tools and thus would trigger hooks. ```text Finding: The `/compact` command likely does NOT trigger hooks because: 1. It's an internal Claude Code command, not a tool call 2. Internal commands bypass the tool invocation system 3. Only actual tool calls (Write, Edit, Bash, etc.) trigger hook events Testing Strategy for Internal Commands: - Internal commands like `/compact` don't go through the tool system - Memory management tools (like in the Anthropic notebook) that ARE implemented as proper tools WILL trigger hooks - The distinction is: built-in commands vs. tool implementations ``` -------------------------------- ### Claude Code Core Tools Source: https://github.com/rinadelph/rins_hooks/blob/main/CLAUDE_CODE_TOOL_ANALYSIS.md Lists the core tools identified within Claude Code based on blog analysis, including dispatch_agent, Bash, BatchTool, GlobTool, View, Edit, Write, and MultiEdit. ```text - dispatch_agent: Launches sub-agents with additional tools - Bash: Executes commands with security checks - BatchTool: Runs multiple tool invocations in parallel - GlobTool: Matches file patterns - View: Reads local filesystem files - Edit: Modifies existing files - Write: Creates new files - MultiEdit: Makes multiple edits to one file ``` -------------------------------- ### Code Formatter Hook Configuration Source: https://github.com/rinadelph/rins_hooks/blob/main/docs/HOOKS.md Configuration for the Code Formatter hook, defining formatters for various languages, exclude patterns, and options for using project configurations and error handling. ```json { "formatters": { ".js": "prettier --write", ".jsx": "prettier --write", ".ts": "prettier --write", ".tsx": "prettier --write", ".json": "prettier --write", ".css": "prettier --write", ".scss": "prettier --write", ".html": "prettier --write", ".md": "prettier --write", ".py": "black", ".go": "gofmt -w", ".rs": "rustfmt", ".java": "google-java-format --replace", ".c": "clang-format -i", ".cpp": "clang-format -i", ".h": "clang-format -i" }, "excludePatterns": [ "node_modules/**", ".git/**", "dist/**", "build/**", "*.min.js", "*.min.css" ], "useProjectConfig": true, "failOnError": false, "showOutput": false } ``` -------------------------------- ### Rins Hooks Available Input Data Structure Source: https://github.com/rinadelph/rins_hooks/blob/main/docs/HOOKS.md Illustrates the structure of the input object provided to Rins Hooks. This object contains contextual information such as session ID, transcript path, the tool being executed, and tool-specific input or response data. ```javascript { session_id: string, // Claude Code session ID transcript_path: string, // Path to conversation transcript tool_name: string, // Name of the tool being executed tool_input: { file_path: string, // For file operations content: string, // For Write operations old_string: string, // For Edit operations new_string: string, // For Edit operations // ... other tool-specific fields }, tool_response: { success: boolean, // ... tool-specific response data } // Available in PostToolUse hooks } ``` -------------------------------- ### Triggering a Hook Source: https://github.com/rinadelph/rins_hooks/blob/main/tool-test-files/batch-c.txt Shows how to trigger a registered hook, passing data to the associated hook function. This is used to initiate the execution of custom logic based on specific events or actions. ```python from rins_hooks.hooks import Hooks hooks = Hooks() # Assuming 'my_event' hook is already registered hooks.trigger_hook('my_event', data={'key': 'value'}) ``` -------------------------------- ### Auto-Commit Hook Configuration Source: https://github.com/rinadelph/rins_hooks/blob/main/docs/HOOKS.md Configuration for the Auto-Commit hook, specifying commit message templates, files to exclude, branch restrictions, and handling of empty commits. ```json { "commitMessageTemplate": "Auto-commit: {{toolName}} modified {{fileName}}\n\n- File: {{filePath}}\n- Tool: {{toolName}}\n- Session: {{sessionId}}\n\nšŸ¤– Generated with Claude Code via rins_hooks\nCo-Authored-By: Claude ", "excludePatterns": [ "*.log", "*.tmp", "*.temp", ".env*", "*.key", "*.pem", "node_modules/**", ".git/**", "*.pyc", "__pycache__/**" ], "skipEmptyCommits": true, "addAllFiles": false, "branchRestrictions": ["main", "master"], "maxCommitMessageLength": 500 } ``` -------------------------------- ### Python Hook Registration Source: https://github.com/rinadelph/rins_hooks/blob/main/tool-test-files/batch-a.txt Demonstrates how to register a Python function as a hook. This involves defining the hook function and then registering it with the hook manager. ```python from rins_hooks.hooks import register_hook def my_hook_function(data): print(f"Processing data: {data}") return data register_hook('my_event', my_hook_function) ``` -------------------------------- ### Git Commit Evidence for Hook Execution Source: https://github.com/rinadelph/rins_hooks/blob/main/CLAUDE_CODE_TOOL_ANALYSIS.md Provides evidence from auto-generated git commits showing the pattern of hook executions for different tool operations, such as multiple separate commits for multiple Write operations. ```bash f72b20e Auto-commit: MultiEdit modified test-edit.js # 1 commit for MultiEdit d5ee73e Auto-commit: Write modified batch-c.txt # 3 separate commits 9ed638f Auto-commit: Write modified batch-b.txt # for 3 Write operations 499466f Auto-commit: Write modified batch-a.txt # in one message a2ac919 Auto-commit: Edit modified test-multiedit.json # Edit after Read 29971a7 Auto-commit: Edit modified test-edit.js # Single Edit b073ab1 Auto-commit: Write modified single-write-test.txt # Single Write ``` -------------------------------- ### Rins Hooks Return Methods Source: https://github.com/rinadelph/rins_hooks/blob/main/docs/HOOKS.md Defines the methods available within a Rins Hook to signal the outcome of its execution. These methods allow for returning data on success, reporting errors with messages, or blocking/approving tool execution. ```javascript this.success(data) // Successful execution this.error(message, data) // Error occurred this.block(reason) // Block tool execution with reason this.approve(reason) // Approve tool execution (bypass permissions) ``` -------------------------------- ### Code Formatter Hook Configuration Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Configures the Code Formatter hook, specifying formatters for different file extensions and defining exclusion patterns. ```json { "formatters": { ".js": "prettier --write", ".py": "black", ".go": "gofmt -w", ".rs": "rustfmt" }, "excludePatterns": ["node_modules/**", "dist/**"], "failOnError": false } ``` -------------------------------- ### Claude Code Tool Hook Trigger Patterns Source: https://github.com/rinadelph/rins_hooks/blob/main/CLAUDE_CODE_TOOL_ANALYSIS.md Identifies which Claude Code tools trigger PostToolUse hooks based on analysis. Tools like Write, Edit, and MultiEdit trigger hooks, while Bash, Read, Glob, and LS do not with the current matcher. ```text āœ… Tools That Trigger PostToolUse Hooks - Write: Each file write operation triggers hooks separately - Edit: Single edits trigger one hook execution - MultiEdit: Multiple edits in one operation trigger ONE hook execution āŒ Tools That Do NOT Trigger Hooks (with Edit|Write|MultiEdit matcher) - Bash: Command execution does not match our hook pattern - Read: File reading operations don't trigger PostToolUse - Glob: File pattern matching operations - LS: Directory listing operations ``` -------------------------------- ### Auto-Commit Hook Configuration Source: https://github.com/rinadelph/rins_hooks/blob/main/README.md Defines the configuration for the Auto-Commit hook, including commit message templates, exclusion patterns, and branch restrictions. ```json { "commitMessageTemplate": "Auto-commit: {{toolName}} modified {{fileName}}\n\n- File: {{filePath}}\n- Tool: {{toolName}}\n- Session: {{sessionId}}\n\nšŸ¤– Generated with Claude Code via rins_hooks\nCo-Authored-By: Claude ", "excludePatterns": [ "*.log", "*.tmp", ".env*", "*.key", "node_modules/**", ".git/**" ], "skipEmptyCommits": true, "branchRestrictions": ["main", "master"], "maxCommitMessageLength": 500 } ``` -------------------------------- ### Notification Hook Event Types Source: https://github.com/rinadelph/rins_hooks/blob/main/docs/HOOKS.md Defines the event types that trigger notifications in the Notification hook, including their default titles and when they are triggered. ```APIDOC Notification Hook Event Types: Event Type: `task_completed` - Default Title: "Claude Code Task Completed" - When Triggered: Task finishes successfully Event Type: `permission_required` - Default Title: "Claude Code Permission Required" - When Triggered: Waiting for user permission Event Type: `error` - Default Title: "Claude Code Error" - When Triggered: Error occurs during execution Event Type: `idle` - Default Title: "Claude Code Idle" - When Triggered: Waiting for user input ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.