# What Is the Flag-File Pattern for Always-On Mode in i-have-adhd?

> Discover the flag-file pattern for always-on mode in i-have-adhd. Learn how the .i-have-adhd-always hidden file enables automatic ADHD compliance rule injection.

- Repository: [Ayoub Ghriss/i-have-adhd](https://github.com/ayghri/i-have-adhd)
- Tags: deep-dive
- Published: 2026-09-09

---

**The always-on mode in i-have-adhd uses a hidden flag file named `.i-have-adhd-always` located in the Claude configuration directory (`$CLAUDE_CONFIG_DIR` or `$HOME/.claude`) to trigger automatic injection of ADHD compliance rules into every response.**

The i-have-adhd repository provides a Claude plugin that adapts AI interactions for ADHD accessibility. Understanding the flag-file pattern for always-on mode is essential for developers who want the full ruleset prepended to every conversation without manual activation commands.

## How the Flag-File Pattern Works

The implementation relies on a simple filesystem existence check. When the hook executes, it constructs a path to `.i-have-adhd-always`. If that file exists, the hook reads [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md), strips any YAML front-matter, and prints the ruleset with a banner reading "ADHD MODE ACTIVE (always-on). The ruleset below applies to every response." If the file is absent, the hook exits silently with status code 0, leaving normal Claude behavior unchanged.

## Flag File Location and Naming Convention

The flag-file pattern follows strict conventions for filename and directory resolution:

- **Filename**: `.i-have-adhd-always` (a hidden file with no extension)
- **Base Directory**: The directory specified by `$CLAUDE_CONFIG_DIR`, or `$HOME/.claude` if the environment variable is unset

This resolves to the full path pattern:

```

$CLAUDE_CONFIG_DIR/.i-have-adhd-always

# Defaults to ~/.claude/.i-have-adhd-always

```

### Environment Variable Resolution

According to the source code in [`hooks/always-on.sh`](https://github.com/ayghri/i-have-adhd/blob/main/hooks/always-on.sh) (lines 10-11), the implementation checks the `CLAUDE_CONFIG_DIR` environment variable first. If undefined, it falls back to the `.claude` subdirectory within the user's home folder. The PowerShell implementation in `hooks/always-on.ps1` (lines 12-13) follows identical logic using `$env:CLAUDE_CONFIG_DIR` with a fallback to `$HOME\.claude`.

## Enabling Always-On Mode

To activate the flag-file pattern and enable persistent ruleset injection, create the flag file using the appropriate commands for your operating system.

### Bash and POSIX Shells

```bash
mkdir -p "${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
touch "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/.i-have-adhd-always"

```

### Windows PowerShell

```powershell
$claudeDir = $env:CLAUDE_CONFIG_DIR ? $env:CLAUDE_CONFIG_DIR : "$HOME\.claude"
$flagPath = Join-Path $claudeDir ".i-have-adhd-always"
New-Item -ItemType File -Path $flagPath -Force

```

## Disabling Always-On Mode

Removing the flag file immediately disables the always-on behavior without requiring Claude to restart.

**Bash/POSIX removal:**

```bash
rm "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/.i-have-adhd-always"

```

**PowerShell removal:**

```powershell
$claudeDir = $env:CLAUDE_CONFIG_DIR ? $env:CLAUDE_CONFIG_DIR : "$HOME\.claude"
$flagPath = Join-Path $claudeDir ".i-have-adhd-always"
Remove-Item -Path $flagPath -Force

```

## Source Code Implementation

The flag-file pattern is implemented consistently across the shell, PowerShell, and Node.js hook versions.

In [`hooks/always-on.sh`](https://github.com/ayghri/i-have-adhd/blob/main/hooks/always-on.sh), the existence check is implemented as:

```sh
flag_path="$claude_dir/.i-have-adhd-always"
[ -f "$flag_path" ] || exit 0   # Bail out unless the flag file exists

```

In `hooks/always-on.ps1`, the equivalent validation uses:

```powershell
$flagPath = Join-Path $claudeDir ".i-have-adhd-always"
if (-not (Test-Path -LiteralPath $flagPath -PathType Leaf)) { exit 0 }

```

The Node.js implementation in `hooks/always-on.mjs` mirrors this filesystem check pattern. When the flag file exists, all versions proceed to load and inject the content from [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md). The behavior is validated by [`tests/test_always_on_hooks.py`](https://github.com/ayghri/i-have-adhd/blob/main/tests/test_always_on_hooks.py), which confirms the hook correctly handles both presence and absence states of the flag file.

## Summary

- The **flag-file pattern for always-on mode** requires a specific hidden file named `.i-have-adhd-always` in the Claude configuration directory.
- The full path resolves to `$CLAUDE_CONFIG_DIR/.i-have-adhd-always` or defaults to `$HOME/.claude/.i-have-adhd-always` when the environment variable is unset.
- **Creating** the file enables automatic ruleset injection; **deleting** the file disables it immediately.
- The shell script ([`hooks/always-on.sh`](https://github.com/ayghri/i-have-adhd/blob/main/hooks/always-on.sh)), PowerShell script (`hooks/always-on.ps1`), and Node.js script (`hooks/always-on.mjs`) all implement identical flag-file detection logic.

## Frequently Asked Questions

### What is the exact filename for the always-on flag file?

The filename is strictly `.i-have-adhd-always`. It is a hidden dotfile with no extension that must be placed in the Claude configuration directory to activate the always-on hook.

### Where does the always-on hook look for the flag file?

The hook checks for the file in the directory specified by the `CLAUDE_CONFIG_DIR` environment variable. If this variable is not set, the hook defaults to searching the `.claude` folder within the user's home directory, resulting in a standard path of `~/.claude/.i-have-adhd-always` on Unix systems or `$HOME\.claude\.i-have-adhd-always` on Windows.

### How does the hook behave if the flag file is missing?

If the flag file does not exist, the hook exits silently with status code 0, leaving Claude's normal response behavior completely unchanged. No error is raised, and no ruleset is injected into the conversation.

### Can I relocate the flag file using environment variables?

Yes. By setting the `CLAUDE_CONFIG_DIR` environment variable to a custom directory path before launching Claude, you can relocate the entire configuration directory, which consequently moves the expected location of the `.i-have-adhd-always` flag file. The hook constructs the flag file path dynamically at runtime based on this variable.