# Is always-on.mjs Compatible with Windows, macOS, and Linux for i-have-adhd?

> Confirm always-on.mjs compatibility across Windows macOS and Linux for i-have-adhd. This Node.js hook runs cross-platform with no shell dependencies.

- Repository: [Ayoub Ghriss/i-have-adhd](https://github.com/ayghri/i-have-adhd)
- Tags: compatibility-guide
- Published: 2026-08-08

---

**Yes, always-on.mjs is fully compatible with Windows, macOS, and Linux.** The hook runs under Node.js and uses only cross-platform core modules, eliminating dependencies on POSIX shells or PowerShell.

The `always-on.mjs` script in the `ayghri/i-have-adhd` repository provides a universal solution for automatically injecting ADHD-focused rulesets into Claude Code sessions. Unlike platform-specific shell scripts, this Node.js module ensures consistent behavior across all major operating systems without requiring environment-specific configurations or interpreter availability.

## Cross-Platform Architecture of always-on.mjs

The `always-on.mjs` file in `hooks/always-on.mjs` is explicitly designed as an OS-agnostic Node.js hook. According to the comment block at lines 5-8 of the source file, the script "Runs under Node so it works on macOS, Linux, and Windows without depending on a POSIX shell (`sh`) … Native sh and PowerShell implementations remain available as fallbacks."

### Core Node.js Module Dependencies

The script imports only standard Node.js libraries that are available on every platform:

- `fs` for filesystem operations
- `os` for operating system utilities  
- `path` for cross-platform path handling
- `url` for URL resolution

These modules provide consistent APIs across Windows, macOS, and Linux, ensuring that file paths, environment variables, and system calls behave identically regardless of the host operating system.

### Platform-Agnostic APIs

Instead of shell commands, `always-on.mjs` relies on Node.js built-ins for system interaction:

- **`process.env`** to access environment variables
- **`os.homedir()`** to locate the user's home directory
- **`path.join()`** to construct file paths using the correct separator for the current OS

This approach eliminates path separator issues (backslashes vs. forward slashes) and avoids shell-specific syntax that would break across platforms.

## Exec-Form Hook Configuration

The hook is registered via [`hooks/hooks.json`](https://github.com/ayghri/i-have-adhd/blob/main/hooks/hooks.json) using exec-form invocation, which passes the script path directly to the Node.js executable. This method bypasses shell parsing entirely, ensuring that Claude Code executes the script consistently on Windows, macOS, and Linux without requiring `sh` or PowerShell to be present.

## Fallback Scripts for Restricted Environments

While `always-on.mjs` covers all three major platforms, the repository includes fallback implementations for environments where Node.js might be unavailable:

- **[`hooks/always-on.sh`](https://github.com/ayghri/i-have-adhd/blob/main/hooks/always-on.sh)**: POSIX-shell implementation for Linux and macOS systems
- **`hooks/always-on.ps1`**: PowerShell implementation for Windows systems

These alternatives ensure the i-have-adhd skill remains functional even in minimal containerized or restricted environments lacking Node.js.

## Enabling Always-On Mode

To activate the cross-platform hook, create the opt-in flag file in your home directory:

```bash
mkdir -p ~/.claude && touch ~/.claude/.i-have-adhd-always

```

When Claude Code starts a session, `always-on.mjs` automatically detects this file and injects the ADHD ruleset. The script outputs confirmation:

```text
ADHD MODE ACTIVE (always-on). The ruleset below applies to every response. "stop adhd mode" turns it off for this session; delete /home/username/.claude/.i-have-adhd-always to turn always-on off for good.

<contents of SKILL.md>

```

### Disabling Always-On Mode

To temporarily disable for the current session, type:

```text
stop adhd mode

```

To permanently remove the always-on functionality:

```bash
rm ~/.claude/.i-have-adhd-always

```

## Summary

- **always-on.mjs is fully compatible with Windows, macOS, and Linux** through its Node.js foundation.
- The script uses only cross-platform core modules (`fs`, `os`, `path`, `url`) available in every Node.js installation.
- **Exec-form invocation** in [`hooks/hooks.json`](https://github.com/ayghri/i-have-adhd/blob/main/hooks/hooks.json) ensures direct Node.js execution without shell dependencies.
- Platform-specific fallbacks ([`always-on.sh`](https://github.com/ayghri/i-have-adhd/blob/main/always-on.sh) and `always-on.ps1`) exist for environments without Node.js.
- The hook checks for `~/.claude/.i-have-adhd-always` to determine activation state across all operating systems.

## Frequently Asked Questions

### Does always-on.mjs require bash or PowerShell to run?

No. The script runs directly under Node.js without invoking a shell interpreter. This design choice explicitly removes dependencies on POSIX shells (`sh`) or PowerShell, making it truly cross-platform according to the source code comments in `hooks/always-on.mjs`.

### What happens if Node.js is not installed?

If Node.js is unavailable, the hook system falls back to platform-specific scripts. On Linux and macOS, Claude Code uses [`hooks/always-on.sh`](https://github.com/ayghri/i-have-adhd/blob/main/hooks/always-on.sh); on Windows, it uses `hooks/always-on.ps1`. These ensure the i-have-adhd skill remains functional even without Node.js.

### How does always-on.mjs handle file paths on Windows?

The script uses Node.js's `path.join()` method to construct file paths, which automatically uses the correct directory separator for the current operating system (backslashes on Windows, forward slashes on macOS/Linux). Combined with `os.homedir()`, it reliably locates `~/.claude/.i-have-adhd-always` regardless of platform.

### Is there a performance difference between always-on.mjs and the shell alternatives?

No meaningful performance difference exists for this use case. The Node.js script executes in milliseconds during Claude Code's session initialization, and the exec-form invocation ensures minimal overhead compared to shell script execution.