# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Build Commands ```bash fpm build # Debug build fpm build --flag "-O2" # Release build with optimization fpm build --flag "-g -Wall -Wextra" # Build with debug flags and warnings fpm run # Build and run fpm test # Run test suite ``` **Dependencies**: gfortran 10+ (or ifort), fpm, ncurses library ## Architecture FORTRESS is a CLI file manager written in modern Fortran (2008+) with dual-pane navigation, git integration, and fuzzy search. ### Module Structure ``` app/main.f90 # Main event loop, state management, user input (~1100 LOC) src/ ├── filesystem/fs_ops.f90 # Directory reading, path manipulation, fzf search, file ops ├── ui/display.f90 # Dual-pane rendering (30% parent | 70% current), color output ├── ui/preview.f90 # File preview functionality ├── terminal/term_control.f90 # Raw mode, ANSI codes, terminal size, key reading ├── git/git_ops.f90 # Git status, staging, commits, push/pull, diff display └── version/version.f90 # Version info (auto-generated by stamp-version.sh) ``` ### Key Patterns **State Management**: The main event loop in `main.f90` manages: - Navigation state (`current_dir`, `parent_dir`, `selected`, `scroll_offset`) - Mode flags (`move_mode`, `in_rename_mode`, `in_selection_mode`) - Clipboard (`has_clipboard`, `clipboard_paths[]`, copy vs cut) - Multi-select tracking (`is_selected[]`, `selection_count`) - Favorites stored in `~/.fortress_favorites` **Terminal Control**: - Uses alternate screen buffer (`ESC[?1049h/l`) to prevent scroll artifacts - Raw mode via `stty` for non-blocking, character-by-character input - Terminal size caching (refreshes every 100 calls) **External Commands**: All shell commands use `execute_command_line()` - ensure proper escaping for paths with special characters. **Git Integration**: Uses git CLI directly; status is cached with 500ms TTL. Directories show recursive status indicators. **Shell Integration**: `~/.fortress_cd` file enables cd-on-exit feature; wrapper scripts in `fortress.sh`/`fortress.fish` read this file. ### Constants Defined across modules: `MAX_PATH=512`, `MAX_FILES=500` ### Color Scheme Blue=directories, Green=executables, Grey=dotfiles, Red=cut files/staged, Yellow=warnings/incoming changes