Shrijith Venkatramana Posted on May 31 Building Truly Cross-Platform Claude Code Hooks with Go, Bash, PowerShell, WSL, and Git-Bash # ai # webdev # programming # productivity Hello, I'm Shrijith Venkatramana. I'm building git-lrc, an AI code reviewer that runs on every commit. Star Us to help devs discover the project. Do give it a try and share your feedback for improving the product. Claude Code hooks are powerful. They let you intercept tool execution, enforce policies, run validations, collect telemetry, or integrate external systems before and after Claude performs actions. Unfortunately, the moment you try to distribute hooks to real developers, you run into a problem: Some developers use Linux Some use macOS Some use Windows PowerShell Some use Git-Bash Some use WSL Some use combinations of all of the above A simple shell script quickly turns into a compatibility nightmare. After experimenting with several approaches, I arrived at a surprisingly effective pattern: Use thin platform-specific wrappers whose only job is downloading and launching a Go binary. Put all real logic inside the Go executable. This gives you the convenience of native hooks while keeping the implementation portable, testable, and maintainable. Let's walk through the architecture. The Cross-Platform Hook Problem Suppose you build a hook that validates commands before Claude executes them. The naive implementation might look like this: #!/usr/bin/env bash python validate.py Enter fullscreen mode Exit fullscreen mode Looks fine until: Python isn't installed The user runs PowerShell The user runs Git-Bash The user runs WSL Path handling differs Quoting rules differ Now you have: validate.sh validate.ps1 validate.py requirements.txt Enter fullscreen mode Exit fullscreen mode And eventually: works-on-my-machine/ Enter fullscreen mode Exit fullscreen mode The problem isn't Claude. The problem is that shells are operating-system specific. The Better Architectur
Back to Home

Building Truly Cross-Platform Claude Code Hooks with Go, Bash, PowerShell, WSL, and Git-Bash
B
Blizine Admin
·1 min read·0 views
📰Dev.to — dev.to
B
Blizine Admin
View Profile Staff Writer