# How the i-have-adhd Plugin Changes AI Assistant Output: A Technical Deep Dive

> Discover how the i-have-adhd plugin transforms AI output by injecting ADHD formatting rules, generating structured, action-oriented responses with numbered steps and suppressed tangents. Explore the technical details.

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

---

**The i-have-adhd plugin rewrites the conversation context by injecting ADHD-specific formatting rules into the system prompt, forcing the AI to produce structured, action-oriented responses with numbered steps and suppressed tangents.**

The `ayghri/i-have-adhd` repository provides a Pi Coding Agent extension that fundamentally alters how an AI assistant generates responses. By intercepting the prompt pipeline and injecting custom behavioral rules, the i-have-adhd plugin transforms verbose, meandering outputs into concise, actionable guidance optimized for neurodivergent users.

## Rule Injection via syncContext()

The primary mechanism for changing AI output occurs in [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts) within the `syncContext()` function (lines 122-136). When ADHD mode is enabled, the plugin inserts a custom message containing the ADHD-style rules from [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md) into the conversation context.

```typescript
// The plugin sends the rules as a custom message type
pi.sendMessage({
  type: 'i-have-adhd-rules',
  content: skillMarkdown, // Contents of SKILL.md
});

```

This injection happens via `pi.sendMessage`, placing the formatting constraints directly into the model's context window. Because these rules persist as a custom message, they effectively act as persistent system instructions for every subsequent generation.

## State Tracking and Persistence

The plugin maintains awareness of whether ADHD mode is active through several state handling functions defined in [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts) (lines 60-71). The `getSavedState` and `setEnabled` functions manage a custom session entry called `i-have-adhd-state` that persists across agent sessions.

Users can activate the mode through multiple entry points:

- **CLI Flag**: Starting the agent with `--adhd` sets `pi.getFlag("adhd")` to `true`
- **Always-on Marker**: Creating a file like `.i-have-adhd-always` in the agent root directory
- **Session Storage**: The custom session entry maintains state between restarts

## UI Status Indicators

When ADHD mode is active, the plugin provides visual feedback through the `updateStatus()` function (lines 8-16). This updates `ctx.ui.setStatus` to display a small "● ADHD ON" badge, ensuring users always know when the special output formatting is in effect.

```typescript
function updateStatus(enabled: boolean) {
  ctx.ui.setStatus(
    enabled ? '● ADHD ON' : '',
    enabled ? 'active' : 'inactive'
  );
}

```

## Command and Input Handling

Users control the plugin through the `/i-have-adhd [on|off]` slash command and natural language triggers. The `pi.registerCommand` handler (lines 73-95) processes explicit toggle commands, while an `input` listener (lines 97-110) intercepts phrases like "stop adhd mode".

When disabling the mode, the plugin sends a custom message of type `i-have-adhd-disabled` that removes the behavioral rules from the context, immediately restoring the model's default conversational style.

## How the Injected Rules Reshape AI Output

The markdown in [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md) defines 10 concrete style rules that constrain the model's generation behavior. Because these rules are passed as a persistent custom message, every response is biased to:

- **Lead with the next action** rather than explanations or pleasantries
- **Number multi-step tasks** using short, scannable lists
- **Suppress tangents** and eliminate preambles like "Certainly!" or "Here's what you need to know"
- **Provide concrete time estimates** for tasks rather than vague durations
- **End with a single next-step cue** that clearly indicates what the user should do next

The rules effectively function as a system prompt overlay, forcing the AI to prioritize executive function support over conversational fluency.

## Implementation Details and Code Examples

Enable ADHD mode programmatically or via CLI:

```typescript
// Check if enabled via CLI flag
if (pi.getFlag("adhd") === true) {
  console.log('ADHD mode active via --adhd flag');
}

// Toggle via slash command
await pi.executeCommand("i-have-adhd", "on");   // Enables rules injection
await pi.executeCommand("i-have-adhd", "off");  // Removes rules from context

// Natural language disabling
await pi.receiveInput({ text: "stop adhd mode" }); 
// Returns: "ADHD mode disabled."

```

## Key Files and Architecture

| File | Role |
|------|------|
| [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts) | Core extension logic: loads rules, tracks state, injects/removes context, registers commands, updates UI status |
| [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md) | Authoritative markdown containing the 10 ADHD-style formatting rules |
| [`plugin.json`](https://github.com/ayghri/i-have-adhd/blob/main/plugin.json) | Plugin manifest declaring name, version, and metadata |
| `hooks/always-on.*` | Helper scripts (e.g., [`always-on.sh`](https://github.com/ayghri/i-have-adhd/blob/main/always-on.sh)) for auto-enabling mode at agent startup |

## Summary

- The i-have-adhd plugin operates as a Pi Coding Agent extension that modifies the conversation context, not the model weights or training.
- **Rule injection** via `syncContext()` inserts [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md) content as a persistent custom message, effectively altering the system prompt.
- **State persistence** across sessions is handled through `getSavedState` and `setEnabled` functions managing the `i-have-adhd-state` entry.
- Users control the mode through CLI flags (`--adhd`), slash commands (`/i-have-adhd`), or natural language ("stop adhd mode").
- When active, the plugin forces AI output to use numbered lists, concrete time estimates, and single next-step cues while suppressing conversational filler.

## Frequently Asked Questions

### How does the i-have-adhd plugin technically modify the AI's system prompt?

The plugin does not directly edit the system prompt object. Instead, it uses `pi.sendMessage` in the `syncContext()` function to inject a custom message of type `i-have-adhd-rules` containing the formatting constraints from [`SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/SKILL.md). Because this message persists in the conversation context, the model treats these rules as binding instructions for all subsequent generations.

### Can I toggle ADHD mode without restarting the agent?

Yes. The plugin supports runtime toggling through the `/i-have-adhd [on|off]` slash command or natural language phrases like "stop adhd mode" (handled in lines 97-110 of [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts)). When toggled off, the plugin sends an `i-have-adhd-disabled` message that removes the rules from the active context, immediately restoring default output behavior.

### What specific formatting changes occur when ADHD mode is enabled?

According to the [`SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/SKILL.md) rules injected into the context, the AI must lead responses with the immediate next action, use short numbered lists for multi-step procedures, provide concrete time estimates instead of vague durations, end with a single clear next-step cue, and eliminate tangential chatter, preambles, and social pleasantries.

### Where does the plugin store the user's ADHD mode preference?

The plugin persists state through a custom session entry named `i-have-adhd-state`, managed by the `getSavedState` and `setEnabled` functions (lines 60-71). Additionally, it checks for the `--adhd` CLI flag at startup and can detect always-on marker files in the agent root directory for automatic activation.