# TimeSafari Debug Hook Guide **Complete Guide for Team Members** **Date**: 2025-01-27 **Author**: Matthew Raymer **Status**: โœ… **ACTIVE** - Ready for production use ## ๐ŸŽฏ Overview A pre-commit hook that automatically detects and prevents debug code from reaching protected branches (master, main, production, release, stable). This ensures production code remains clean while allowing free development on feature branches. ## ๐Ÿš€ Quick Installation **From within the TimeSafari repository:** ```bash ./scripts/install-debug-hook.sh ``` This automatically installs, updates, and verifies the hook in your current repository. **Note**: Hooks are not automatically installed - you must run this script deliberately to enable debug code checking. ## ๐Ÿ”ง Manual Installation **Copy files manually:** ```bash cp scripts/git-hooks/pre-commit /path/to/your/repo/.git/hooks/ cp scripts/git-hooks/debug-checker.config /path/to/your/repo/.git/hooks/ chmod +x /path/to/your/repo/.git/hooks/pre-commit ``` ## ๐Ÿ“‹ What Gets Installed - **`pre-commit`** - Main hook script (executable) - **`debug-checker.config`** - Configuration file - **`README.md`** - Documentation and troubleshooting **Note**: Hooks are stored in `scripts/git-hooks/` and must be deliberately installed by each developer. They are not automatically active. ## ๐ŸŽฏ How It Works 1. **Deliberate Installation**: Hooks must be explicitly installed by each developer 2. **Branch Detection**: Only runs on protected branches 3. **File Filtering**: Automatically skips tests, scripts, and documentation 4. **Pattern Matching**: Detects debug code using regex patterns 5. **Commit Prevention**: Blocks commits containing debug code ## ๐Ÿ”’ Installation Philosophy **Why deliberate installation?** - **Developer choice**: Each developer decides whether to use the hook - **No forced behavior**: Hooks don't interfere with existing workflows - **Local control**: Hooks are installed locally, not globally - **Easy removal**: Can be uninstalled at any time - **Team flexibility**: Some developers may prefer different tools ## ๐ŸŒฟ Branch Behavior - **Protected branches** (master, main, production, release, stable): Hook runs automatically - **Feature branches**: Hook is skipped, allowing free development with debug code ## ๐Ÿ” Debug Patterns Detected - **Console statements**: `console.log`, `console.debug`, `console.error` - **Template debug**: `Debug:`, `debug:` in Vue templates - **Debug constants**: `DEBUG_`, `debug_` variables - **HTML debug**: `