How `/i-have-adhd` Command Arguments Are Parsed for `on`, `off`, and `stop`

The /i-have-adhd command uses a simple case‑insensitive string matcher that accepts on, off, or stop (alias for off), with no argument triggering a toggle of the current state.

Argument parsing for the /i-have-adhd command follows a deterministic, minimal design implemented in extensions/i-have-adhd.ts. The handler receives raw user input, normalizes it, and matches against exactly three recognized tokens. This article breaks down the parsing logic, shows complete code examples, and explains how the repository handles invalid inputs.


Argument Parsing Logic in extensions/i-have-adhd.ts

The parsing implementation occupies lines 71–90 of extensions/i-have-adhd.ts. The logic executes in strict sequence: normalization first, then empty‑string check, then explicit token matching.

Step 1: Normalize the Input String

All arguments are trimmed of leading/trailing whitespace and forced to lowercase. This eliminates case‑sensitivity issues and accidental spaces.

const argument = args.trim().toLowerCase();

This single line ensures /i-have-adhd ON, /i-have-adhd on , and /i-have-adhd On all resolve identically.

Step 2: Empty Argument Toggles Current State

When the user provides no argument, the command flips the existing enabled state.

if (argument === "") {
  setEnabled(!enabled, ctx);
  return;
}
  • Behavior: ADHD‑friendly output turns on if off, turns off if on.
  • Use case: Quick keyboard shortcut without remembering current state.

Step 3: Explicit on Token

The string "on" unconditionally enables ADHD mode.

if (argument === "on") {
  setEnabled(true, ctx);
  return;
}

This is the deterministic way to ensure rules are active regardless of previous state.

Step 4: off and stop Are Synonyms

Both tokens disable ADHD mode. The "stop" alias accommodates natural language ("stop adhd mode").

if (argument === "off" || argument === "stop") {
  setEnabled(false, ctx);
  return;
}
  • Token equivalence: offstop
  • Implementation: Single conditional with logical OR, no priority between them

Step 5: Invalid Arguments Trigger Usage Warning

Any non‑empty, unrecognized string results in a warning notification.

ctx.ui.notify("Usage: /i-have-adhd [on|off]", "warning");

The warning deliberately excludes stop from the message to keep the interface simple, even though the parser accepts it.


Complete Usage Examples

Toggle Without Argument

/i-have-adhd

Switches state based on current value. Fastest when you want to flip modes without checking status first.

Force Enable

/i-have-adhd on

Guarantees ADHD‑friendly rules are injected into the conversation context.

Force Disable (Two Valid Forms)

/i-have-adhd off
/i-have-adhd stop

Both commands call setEnabled(false, ctx) through the same code path.

Invalid Input Handling

/i-have-adhd enable
/i-have-adhd 0
/i-have-adhd ONN

All trigger: Warning: Usage: /i-have-adhd [on|off]


Supporting Files and Architecture

The repository splits responsibilities across three key files:

File Purpose
extensions/i-have-adhd.ts Command registration, argument parsing, and setEnabled() calls
skills/i-have-adhd/SKILL.md Rule content injected when mode is enabled
extensions/context-compat.ts Context tracking helpers verifying rule persistence

The parsing logic remains isolated in the extension file. No external validation or subcommand routing complicates the flow.


Summary

  • Single source: All parsing lives in extensions/i-have-adhd.ts lines 71–90.
  • Normalization: trim().toLowerCase() ensures case‑insensitive matching.
  • Three valid states: Empty (toggle), "on", and "off"/"stop" (synonyms).
  • Fail‑closed: Invalid arguments surface a clear usage warning rather than silent failure.
  • No dependencies: The parser uses only standard string methods, zero external libraries.

Frequently Asked Questions

Does /i-have-adhd accept boolean values like true or 1?

No. The parser only recognizes the empty string, "on", "off", and "stop". Inputs like true, 1, yes, or 0 all trigger the usage warning. This design avoids ambiguity between string and numeric parsing.

Why does stop work as an alias for off?

The alias accommodates intuitive user language. According to the source code, "stop" was added because users naturally type "stop adhd mode" when wanting to exit the specialized formatting. Both tokens execute identical setEnabled(false, ctx) logic.

What happens if I type multiple arguments like /i-have-adhd on now?

The entire argument string undergoes trim().toLowerCase(), producing "on now". This fails the equality checks against "on", "off", and "stop", resulting in the usage warning. Only exact single‑token matches succeed after normalization.

Where is the enabled state stored after parsing?

The setEnabled() function (called on lines 75, 80, and 85) persists state through the ctx context object. The companion file extensions/context-compat.ts provides utilities for tracking whether ADHD rules remain active across conversation turns.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →