# How the I-Have-ADHD Skill Restructures LLM Output: Technical Implementation Guide

> Discover how the I-Have-ADHD skill restructures LLM output by embedding a 10-point rule set into the context window for actionable, formatted responses with time estimates. Learn the technical implementation.

- Repository: [Ayoub Ghriss/i-have-adhd](https://github.com/ayghri/i-have-adhd)
- Tags: technical-implementation-guide
- Published: 2026-08-27

---

**The I-Have-ADHD skill reshapes LLM responses by injecting a 10-point formatting rule set directly into the model’s context window via hidden system messages, ensuring every output leads with actionable steps, uses numbered lists for multi-step tasks, and provides concrete time estimates without post-processing filters.**

The open-source `ayghri/i-have-adhd` repository demonstrates a sophisticated approach to prompt engineering that modifies LLM behavior at the generation level. By embedding ADHD-friendly formatting rules directly into the active context rather than manipulating responses after generation, this skill creates a persistent behavioral scaffold that guides every response according to specific communication standards.

## Rule Definition and Storage in SKILL.md

The foundation of the output restructuring logic resides in [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md). This markdown file contains a human-readable style guide that dictates how the LLM should structure its responses. According to the source code, the file includes concrete directives such as "Lead with the next action", "Number multi-step tasks", and "Give specific time estimates" at line 33.

The file begins with YAML front-matter metadata, followed by the 10-point rule set that the model must follow. These rules remain static during runtime but are loaded dynamically when the extension initializes.

## Loading and Preparing Rules for Injection

The [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts) file implements the `loadRules()` function to extract pure instruction text from the markdown source. Located at lines 61-78, this utility strips the YAML front-matter and validates that content exists before returning the rule string:

```typescript
function loadRules(): string {
  const content = readFileSync(SKILL_PATH, "utf8");
  const rules = stripFrontmatter(content);
  if (!rules) {
    throw new Error(`The i-have-adhd rules file is empty: ${SKILL_PATH}`);
  }
  return rules;
}

```

This preprocessing ensures that only the actionable formatting directives—not the metadata headers—reach the model’s context window.

## Context Injection via Hidden System Messages

The core mechanism that restructures LLM output occurs in the `syncContext` function at lines 34-59 of [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts). When ADHD mode is enabled, the extension checks whether rules are already active using `latestMarkerIsActive` (lines 5-11), which inspects the most recent custom markers in the session history to prevent duplicate injections.

If the rules are absent, the extension sends a custom message with `customType: 'i-have-adhd-rules'`:

```typescript
if (enabled && !injected) {
  pi.sendMessage(
    {
      customType: RULES_MESSAGE_TYPE,
      content: `${RULES_HEADER}\n\n${rules}`,
      display: false,
    },
    { triggerTurn: false },
  );
}

```

As implemented at lines 34-47, the `display: false` property ensures the rule text never appears in the user interface, while the message becomes part of the prompt the model receives. The `RULES_HEADER` constant prefixes the content to clearly demarcate the instruction block. Because these rules saturate the model’s context window as persistent system instructions, the LLM naturally generates compliant responses during inference without requiring output filters.

## Session Persistence and State Synchronization

The extension maintains consistent formatting across conversation turns through sophisticated state management. When ADHD mode is disabled, the system sends a "disabled" marker to cancel previously injected rules, ensuring clean state transitions without context pollution.

The `restoreState` function (lines 61-71) retrieves the `i-have-adhd-state` entry from the session branch upon initialization. This function reconciles saved state with multiple initialization sources, including command-line flags, configuration files, or persistent "always-on" markers, enabling the skill to maintain consistent output formatting across session restarts and tree reconstructions.

## User Control: Commands and Natural Language Triggers

Users interact with the skill through the `/i-have-adhd` slash command. The command handler, implemented at lines 87-100, accepts specific arguments (`on`, `off`, or empty to toggle) and invokes `setEnabled` to update the session state and trigger context re-synchronization:

```typescript
pi.registerCommand("i-have-adhd", {
  description: "Toggle ADHD-friendly output for this session",
  handler: async (args, ctx) => {
    const argument = args.trim().toLowerCase();
    if (argument === "") setEnabled(!enabled, ctx);
    else if (argument === "on") setEnabled(true, ctx);
    else if (argument === "off" || argument === "stop") setEnabled(false, ctx);
    else ctx.ui.notify("Usage: /i-have-adhd [on|off]", "warning");
  },
});

```

Additionally, the input hook watches for natural language stop phrases including "stop adhd mode" and "normal mode" (lines 111-134). When detected, these phrases automatically trigger `setEnabled(false, ctx)`, providing an intuitive escape mechanism that immediately removes the formatting constraints from future context.

## Summary

- The I-Have-ADHD skill stores its formatting directives in [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md), a 10-point style guide that mandates actionable first steps, numbered task lists, and concrete time estimates.
- Rule injection occurs through hidden custom messages (`customType: 'i-have-adhd-rules'`) sent via `syncContext` in [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts), saturating the model’s context without UI visibility.
- The `latestMarkerIsActive` function prevents duplicate injections and context bloat by tracking custom markers, while `restoreState` maintains settings across session boundaries using the `i-have-adhd-state` session entry.
- Users control the mode through the `/i-have-adhd` slash command or natural language stop phrases, with the extension automatically managing context synchronization and rule cancellation.

## Frequently Asked Questions

### How does the I-Have-ADHD skill technically modify LLM responses without post-processing?

The skill injects formatting rules directly into the model’s context window using hidden system messages with `display: false`. By including the rule set as part of the active prompt context via `pi.sendMessage()` with `customType: 'i-have-adhd-rules'` as seen in lines 34-47 of [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts), the model naturally generates compliant responses during the inference phase rather than filtering output after generation.

### Where are the ADHD formatting rules defined in the repository?

The rules are defined in [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md), which contains 10 specific directives including imperatives to lead with the next action and number multi-step tasks. The `loadRules()` function in [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts) (lines 61-78) reads this file at runtime and strips the YAML front-matter to extract the pure instruction text for injection.

### How does the skill prevent duplicate rule injection during a session?

The extension uses the `latestMarkerIsActive` function (lines 5-11 of [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts)) to inspect recent custom markers in the conversation history. This validation ensures rules are only injected when `enabled && !injected` conditions are met, preventing context window bloat from repeated rule insertions while maintaining the formatting constraints across multiple turns.

### Can users disable the ADHD mode once enabled, and how?

Yes, users can disable the mode through multiple interfaces. The `/i-have-adhd off` command explicitly calls `setEnabled(false, ctx)`. Alternatively, natural language phrases like "stop adhd mode" or "normal mode" trigger the input hook (lines 111-134) to automatically disable the mode. When disabled, the extension sends a cancellation marker to remove the formatting constraints from the model’s future context.