# How the Always-On Flag Works for i‑have‑adhd in Claude Code and Codex

> Understand how the always on flag in i-have-adhd works for Claude Code and Codex. Learn about persistent ADHD friendly formatting with sentinel files and SessionStart hooks.

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

---

**The always‑on flag enables persistent ADHD‑friendly formatting by creating a sentinel file that triggers a SessionStart hook to inject the ruleset into every Claude Code and Codex session.**

The *i‑have‑adhd* plugin modifies AI assistant responses to follow ADHD‑friendly formatting conventions. By creating a specific flag file, users ensure the plugin automatically activates at the start of every session without manual intervention.

## SessionStart Hook Registration

The plugin registers its automation through a JSON hook definition that both Claude Code and Codex execute at session initialization.

In [`hooks/hooks.json`](https://github.com/ayghri/i-have-adhd/blob/main/hooks/hooks.json), the plugin declares a **SessionStart** hook that runs a Node.js command importing `hooks/always‑on.mjs`:

```json
{
  "hooks": {
    "SessionStart": {
      "command": "node hooks/always-on.mjs"
    }
  }
}

```

This registration is runtime‑agnostic. Both Claude Code (via `.claude‑plugin/plugin.json`) and Codex (via `.codex‑plugin/plugin.json`) load the same hook configuration at startup, ensuring identical behavior across platforms.

## Flag Detection Logic

The core mechanism resides in `hooks/always‑on.mjs`, which checks for the existence of a sentinel file before proceeding.

The code constructs the flag path using the `CLAUDE_CONFIG_DIR` environment variable, defaulting to `~/.claude`:

```javascript
const claudeDir = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), ".claude");
const flagPath = path.join(claudeDir, ".i-have-adhd-always");
if (!fs.existsSync(flagPath)) process.exit(0);   // ← flag absent → do nothing

```

**Lines 15‑20** of `hooks/always‑on.mjs` serve as the sole gate: if `.i‑have‑adhd‑always` does not exist, the hook exits silently without modifying the session. This check prevents unnecessary processing when the feature is disabled.

## Rule Injection Process

When the flag file is present, the hook reads the ADHD ruleset from `skills/i‑have‑adhd/SKILL.md`, strips any YAML front‑matter, and writes the content to **stdout** with an instructional banner:

```javascript
process.stdout.write(
  "ADHD MODE ACTIVE (always‑on). The ruleset below applies to every response. " +
  '"stop adhd mode" turns it off for this session; ' +
  `delete ${flagPath} to turn always‑on off for good.\n\n${body}\n`,
);

```

This output becomes part of the system prompt, ensuring every response follows the ADHD‑friendly formatting rules defined in the skill file.

## Enabling and Disabling the Always-On Flag

The flag file provides a simple opt‑in mechanism that persists across sessions.

**Enable always‑on mode** by creating the flag file:

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

```

**Disable for the current session** by sending the command recognized in the banner:

```

stop adhd mode

```

**Disable permanently** by removing the flag file:

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

```

## Runtime-Agnostic Architecture

The same [`hooks/hooks.json`](https://github.com/ayghri/i-have-adhd/blob/main/hooks/hooks.json) configuration powers both Claude Code and Codex. The plugin manifests (`.claude‑plugin/plugin.json` and `.codex‑plugin/plugin.json`) expose the plugin to their respective runtimes without duplicating hook logic, allowing the always‑on flag mechanism to function identically across both platforms.

## Summary

- The **always‑on flag** is a sentinel file at `~/.claude/.i‑have‑adhd‑always` (or `$CLAUDE_CONFIG_DIR/.i‑have‑adhd‑always`).
- `hooks/always‑on.mjs` checks for this file during the **SessionStart** hook; if absent, the hook exits immediately.
- When present, the hook injects content from `skills/i‑have‑adhd/SKILL.md` into the system prompt with an activation banner.
- The mechanism works identically for **Claude Code** and **Codex** through shared hook definitions.
- Users can toggle the feature via filesystem commands or disable it temporarily with the "stop adhd mode" phrase.

## Frequently Asked Questions

### How do I know if the always‑on flag is working?

If the flag file exists at `~/.claude/.i‑have‑adhd‑always`, you will see the "ADHD MODE ACTIVE" banner at the start of your Claude Code or Codex session, followed by the ruleset. If you do not see this banner, verify the file exists and that `CLAUDE_CONFIG_DIR` is set correctly if using a custom configuration directory.

### Does the always‑on flag work differently in Claude Code versus Codex?

No. Both platforms use the same [`hooks/hooks.json`](https://github.com/ayghri/i-have-adhd/blob/main/hooks/hooks.json) configuration and `hooks/always‑on.mjs` script. The `.claude‑plugin/plugin.json` and `.codex‑plugin/plugin.json` manifests simply register the plugin with their respective runtimes, which then execute the shared SessionStart hook identically.

### Can I temporarily disable the ADHD ruleset without deleting the flag file?

Yes. The banner injected by the hook includes the instruction to say "stop adhd mode" to disable the ruleset for the current session only. This allows you to toggle formatting on demand while keeping the always‑on flag file in place for future sessions.

### What file contains the actual ADHD formatting rules?

The ruleset is stored in `skills/i‑have‑adhd/SKILL.md`. The `hooks/always‑on.mjs` script reads this file, removes any YAML front‑matter, and injects the remaining content into the system prompt whenever the always‑on flag is detected.