$ show BotchetDig/workout-gate
Workout Gate is a CLI tool that gates AI coding prompts (Claude Code and Codex) behind a physical exercise challenge. It installs a UserPromptSubmit hook that counts prompts and, when a challenge is due, blocks the prompt and opens a webcam window to count push-ups or squats via MediaPipe Pose. Each rep is persisted to disk immediately, so progress is saved if the window is closed. The system tracks debt (owed reps), stats, and streaks, and provides a CLI and web dashboard for configuration. The architecture is modular, with clear separation between the hook, challenge logic, pose detection, state persistence, and user interfaces. Key strengths include robust cross-process locking for shared state, a reusable hysteresis counter for rep counting, and thoughtful escape hatches to prevent lockout.
The LLM identified 2 files worth highlighting for reuse:
Implements a cross-process exclusive lock using fcntl.flock with a fallback for Windows, and a mutate_state function for locked read-modify-write of JSON state files. This pattern prevents lost updates when multiple processes (e.g., Claude Code and Codex sessions) concurrently access shared state. It is isolated, depends only on standard libraries and a data directory helper, and demonstrates non-obvious skill in handling stale PID cleanup and atomic writes via temp files. Another engineer could extract this locking mechanism into a reusable utility for any application requiring safe concurrent file access.
Contains the RepCounter and ExerciseCounter classes that implement a hysteresis state machine for counting repetitions from pose landmarks. RepCounter uses smoothing and dropout handling to count down→up transitions reliably, while ExerciseCounter adds side selection and posture guards. This logic is unit-testable without a webcam, depends only on standard libraries and the pose data structure, and is completely isolated from UI and storage concerns. It exemplifies a reusable pattern for any fitness or motion-tracking application that needs to count reps from pose estimation, with minimal coupling to the rest of the system.