@@ -9,6 +9,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
99- ** Format** : ` bun run fmt ` - Formats code using Biome with unsafe fixes
1010- ** Type check** : ` bun run typecheck ` - Runs TypeScript compiler without emitting files
1111- ** Test locally** : ` bun run ./dist/index.js ` - Run the built CLI locally
12+ - ** Test safe mode** : ` bun run ./dist/index.js --safe ` - Run in safe mode (no file modifications)
1213- ** Run tests** : ` bun test ` - Runs all test files (* .spec.ts)
1314- ** Run single test** : ` bun test src/lib/util.spec.ts ` - Run specific test file
1415- ** Test cat** : ` bun test src/lib/cat.spec.ts ` - Run cat vocabulary and emotion detection tests
@@ -56,7 +57,8 @@ The custom InputField component supports comprehensive terminal-style keybinding
5657- ** Cat Behavior** : Cat class provides contextual responses based on detected emotions, with random delay (300-1300ms) for realistic interaction
5758- ** Message Styling** : User messages prefixed with "> " in gray, cat messages prefixed with "⏺ " in cyan
5859- ** Multi-line Support** : Both user and cat messages use indent utility for proper 2+ line formatting
59- - ** Exit Control** : Double Ctrl+C required within 500ms to exit, single Ctrl+C clears input
60+ - ** Exit Control** : Double Ctrl+C required within 3 seconds to exit, single Ctrl+C clears input and shows exit warning
61+ - ** Clean Exit** : Exit warning is hidden before termination using setTimeout to wait for React re-render
6062
6163### Build Process
6264The build process creates a standalone executable CLI tool:
@@ -138,4 +140,24 @@ The cat occasionally "plays" with code files, making random edits and showing di
138140- ** Repository Detection** : Automatically detects git initialization status
139141- ** File Tracking** : Uses ` git ls-files ` for tracked file enumeration
140142- ** Fallback Strategy** : Glob-based file discovery when git is unavailable
141- - ** Text File Filtering** : Consistent file type detection across both git and glob methods
143+ - ** Text File Filtering** : Consistent file type detection across both git and glob methods
144+
145+ ## Safe Mode Implementation
146+
147+ The application supports a ` --safe ` flag that prevents actual file modifications while still showing diffs:
148+
149+ ### CLI Integration
150+ - ** Flag Definition** : ` --safe ` option added to Commander.js configuration
151+ - ** Warning System** : Displays yellow warning when safe mode is disabled at startup
152+ - ** Type Safety** : Uses ` CatConfig ` and ` FileEditorConfig ` types for configuration objects
153+
154+ ### Safe Mode Behavior
155+ - ** File Editor** : Creates temporary files and generates diffs but skips file replacement in safe mode
156+ - ** UI Indicators** : EditAction component shows ` [SAFE MODE - No actual changes] ` indicator
157+ - ** Action System** : ` EditAction ` type includes ` safeMode: boolean ` field for UI state
158+ - ** Configuration Flow** : CLI → App → Cat → FileEditor with proper type safety
159+
160+ ### Implementation Details
161+ - ** Constructor Pattern** : Cat and FileEditor classes use config object parameters instead of boolean flags
162+ - ** State Propagation** : Safe mode state flows through component hierarchy via props
163+ - ** File Cleanup** : Temporary files are properly cleaned up in safe mode using ` unlink() `
0 commit comments