# How to Invoke 'i-have-adhd' Explicitly in Codex: Command Syntax and API Examples

> Learn how to explicitly invoke i-have-adhd in Codex using command syntax and API examples. Master the /i-have-adhd and /skill:i-have-adhd commands for efficient control.

- Repository: [Ayoub Ghriss/i-have-adhd](https://github.com/ayghri/i-have-adhd)
- Tags: how-to-guide
- Published: 2026-09-02

---

**To invoke 'i-have-adhd' explicitly in Codex, type `/i-have-adhd` in the chat interface, optionally followed by `on` or `off` to force a specific state, or use the `/skill:i-have-adhd` alias for one-shot activation.**

The **i-have-adhd** plugin by ayghri extends Codex (and Claude Code) with ADHD-friendly output formatting. This article breaks down exactly how the command registration works, the available invocation syntaxes, and how to trigger it programmatically using the Codex API.

## Command Registration in the Extension Source

The plugin registers its command in [[`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts)](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts). The `pi.registerCommand()` call exposes the functionality to Codex's command system:

```typescript
pi.registerCommand("i-have-adhd", {
  description: "Toggle ADHD-friendly output for this session",
  handler: async (args, ctx) => { … }
});

```

The command name `"i-have-adhd"` becomes the **slash command** identifier. The handler receives optional arguments and session context, then updates state via internal `setEnabled` logic.

The plugin manifest at [[`.codex-plugin/plugin.json`](https://github.com/ayghri/i-have-adhd/blob/main/.codex-plugin/plugin.json)](https://github.com/ayghri/i-have-adhd/blob/main/.codex-plugin/plugin.json) completes the registration, making the command discoverable by Codex's runtime.

## Explicit Invocation Syntax

Codex users have three ways to invoke the command explicitly from the chat interface:

- **`/i-have-adhd`** — Toggles the current state (on becomes off, off becomes on)
- **`/i-have-adhd on`** — Forces ADHD-friendly mode enabled
- **`/i-have-adhd off`** — Forces ADHD-friendly mode disabled

Each variant triggers the same handler with different `args` values. The empty string (toggle), `"on"`, or `"off"` determine the state transition logic.

### Alternative: Skill Shortcut Syntax

For one-shot activation without toggling behavior:

```

/skill:i-have-adhd

```

This alias always enables the mode regardless of current state. It injects the rules from [[`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md)](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md) immediately.

## Programmatic API Invocation

Beyond slash commands, you can invoke 'i-have-adhd' explicitly through the Codex JavaScript API:

```javascript
// Enable ADHD-friendly mode via API
await codex.runCommand("i-have-adhd", { args: "on" });

```

```javascript
// Disable the mode
await codex.runCommand("i-have-adhd", { args: "off" });

```

```javascript
// Toggle current state
await codex.runCommand("i-have-adhd", { args: "" });

```

The `args` parameter maps directly to the slash command arguments. The command name string `"i-have-adhd"` must match exactly—this is the same identifier registered in the extension source.

## What Happens When You Invoke the Command

When executed, the handler performs three operations:

1. **Parses the argument** — Empty string triggers toggle logic; `"on"`/`"off"` set explicit state
2. **Updates session state** — Calls `setEnabled(true|false)` and persists to session storage
3. **Injects or withdraws rules** — Adds the 10 ADHD-friendly formatting rules from [`SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/SKILL.md) when enabled, or removes them when disabled

The internal message flow looks like this:

```typescript
// Example: user types "/i-have-adhd on"
await pi.sendMessage({ content: "/i-have-adhd on" }, { triggerTurn: true });
// → Extension sets `enabled = true`, stores state, and injects the ruleset.

// Example: toggling off
await pi.sendMessage({ content: "/i-have-adhd off" }, { triggerTurn: true });
// → Extension sets `enabled = false` and injects the disabled notice.

```

The `{ triggerTurn: true }` option ensures Codex processes the state change immediately in the conversation flow.

## Key Files Controlling Command Behavior

| File | Purpose |
|------|---------|
| [[`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts)](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts) | Command registration and toggle handler implementation |
| [[`.codex-plugin/plugin.json`](https://github.com/ayghri/i-have-adhd/blob/main/.codex-plugin/plugin.json)](https://github.com/ayghri/i-have-adhd/blob/main/.codex-plugin/plugin.json) | Plugin manifest exposing the command to Codex |
| [[`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md)](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md) | 10 ADHD-friendly formatting rules injected when enabled |
| [[`hooks/hooks.json`](https://github.com/ayghri/i-have-adhd/blob/main/hooks/hooks.json)](https://github.com/ayghri/i-have-adhd/blob/main/hooks/hooks.json) | Lifecycle hook points for session integration |

## Summary

- **Slash command**: `/i-have-adhd [on|off]` is the primary explicit invocation method
- **Skill alias**: `/skill:i-have-adhd` enables mode unconditionally
- **API method**: `codex.runCommand("i-have-adhd", { args: "on|off" })` for programmatic control
- **State management**: Handler in [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts) toggles `enabled` flag and manages [`SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/SKILL.md) injection
- **Plugin registration**: Declared in [`.codex-plugin/plugin.json`](https://github.com/ayghri/i-have-adhd/blob/main/.codex-plugin/plugin.json) for Codex runtime discovery

## Frequently Asked Questions

### What is the exact command name to use in Codex?

The exact command name is **`i-have-adhd`** (with hyphens). This string is passed to `pi.registerCommand()` in [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts) and must match precisely when using the API form `codex.runCommand("i-have-adhd", ...)`.

### Can I use 'i-have-adhd' in Claude Code as well as Codex?

Yes. The plugin architecture is compatible with both Codex and Claude Code. The same slash command syntax `/i-have-adhd` works in both environments because the registration mechanism via [`.codex-plugin/plugin.json`](https://github.com/ayghri/i-have-adhd/blob/main/.codex-plugin/plugin.json) is shared across these Anthropic coding tools.

### What arguments does the command handler accept?

The handler accepts three argument variations: **empty string** (toggles state), **`"on"`** (forces enabled), and **`"off"`** (forces disabled). Any other value falls back to toggle behavior. These are parsed in the handler defined in [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts).

### Where are the ADHD-friendly rules stored when not active?

The rules live in [[`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md)](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md) as static markdown. When the command disables the mode, the extension withdraws this content from the session context rather than storing a separate disabled version. The rules are re-injected from the same file on next activation.