# How the OpenCode Plugin Integrates with I-Have-ADHD: A Technical Breakdown

> Discover how the OpenCode plugin integrates with I-Have-ADHD using its unique three-file architecture. Learn how it enables specialized focus-enhancing responses for the OpenCode runtime.

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

---

**The OpenCode plugin integrates with I-Have-ADHD through a self-contained three-file architecture—[`opencode.json`](https://github.com/ayghri/i-have-adhd/blob/main/opencode.json) for permissions, `.opencode/plugins/i-have-adhd.mjs` for command registration, and [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md) for the ADHD-friendly rule definitions—enabling the OpenCode runtime to execute specialized focus-enhancing responses.**

The I-Have-ADHD repository provides a specialized skill designed to format responses according to ADHD-friendly cognitive principles. Its integration with the OpenCode runtime creates a unified execution environment where the plugin architecture handles permission management, command routing, and skill invocation without external dependencies or additional binaries.

## Core Integration Components

### Global Configuration via [`opencode.json`](https://github.com/ayghri/i-have-adhd/blob/main/opencode.json)

The integration begins with **[`opencode.json`](https://github.com/ayghri/i-have-adhd/blob/main/opencode.json)** at the repository root. This file declares the permission map that allows the runtime to read the repository structure and execute the plugin. It specifies the entry point path pointing to `.opencode/plugins/i-have-adhd.mjs` and configures the model settings for processing requests. According to the repository source, this JSON object defines the permission model that enables the runtime to access the `/cache/repos/` directory structure.

### Plugin Entry Point at `.opencode/plugins/i-have-adhd.mjs`

The JavaScript module serves as the bridge between the OpenCode SDK and the skill logic. It imports **`registerCommand`** from `@opencode-ai/sdk` and loads the canonical skill definition from [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md). The handler function wraps the skill's 10 ADHD-friendly rules around incoming prompts, applying formatting logic before returning responses to the OpenCode client.

### Command Interface in [`.opencode/command/i-have-adhd.md`](https://github.com/ayghri/i-have-adhd/blob/main/.opencode/command/i-have-adhd.md)

This markdown file provides the user-facing documentation displayed when running `opencode help i-have-adhd`. It defines usage examples and help text, ensuring the CLI interface remains consistent with the skill's cognitive accessibility goals. The file lives alongside the plugin code to keep documentation versioned with implementation.

## Execution Flow and Runtime Architecture

The integration follows a five-stage pipeline implemented in the OpenCode runtime:

1.  **Runtime Startup** – OpenCode reads **[`opencode.json`](https://github.com/ayghri/i-have-adhd/blob/main/opencode.json)** to establish permissions and locate the plugin entry point.
2.  **Command Registration** – The runtime executes `.opencode/plugins/i-have-adhd.mjs`, which calls `registerCommand('i-have-adhd', handler)` to expose the command to the CLI.
3.  **User Invocation** – When a user runs `opencode run i-have-adhd "prompt"`, the engine routes the request to the registered handler function.
4.  **Skill Processing** – The handler reads [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md) and applies the 10 ADHD-friendly formatting rules to the input prompt.
5.  **Response Delivery** – The formatted result returns through the OpenCode client to the terminal or UI, completing the integration cycle.

## Implementation Examples

### Command Line Interface

```bash

# Display help documentation

opencode help i-have-adhd

# Execute with a custom prompt

opencode run i-have-adhd "Explain how to maintain focus during long meetings"

```

### Programmatic Usage with Node.js

```javascript
import { OpenCode } from '@opencode-ai/sdk';

// Initialise the OpenCode client using configuration from opencode.json
const client = new OpenCode();

// Call the i-have-adhd command directly
const response = await client.runCommand('i-have-adhd', {
  prompt: 'Give me a quick tip for managing distractions.'
});

console.log(response);

```

### Plugin Entry Point Structure

```javascript
import { registerCommand } from '@opencode-ai/sdk';
import { readFileSync } from 'fs';
import path from 'path';

// Load the canonical skill definition from the skills directory
const skillPath = path.resolve(import.meta.dirname, '../../skills/i-have-adhd/SKILL.md');
const skillContent = readFileSync(skillPath, 'utf-8');

// Register the command that OpenCode will expose
registerCommand('i-have-adhd', async ({ prompt }) => {
  // Applies ADHD-friendly formatting rules from SKILL.md
  return `🧠 ${skillContent}\n\n🔎 Prompt: ${prompt}`;
});

```

## Summary

- The integration relies on three core files: **[`opencode.json`](https://github.com/ayghri/i-have-adhd/blob/main/opencode.json)**, **`.opencode/plugins/i-have-adhd.mjs`**, and **[`.opencode/command/i-have-adhd.md`](https://github.com/ayghri/i-have-adhd/blob/main/.opencode/command/i-have-adhd.md)**.
- The plugin loads ADHD-specific rules from **[`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md)** at runtime using Node.js filesystem APIs.
- Command registration uses the `@opencode-ai/sdk`** `registerCommand` function to bind the skill to the `i-have-adhd` CLI command.
- The architecture is **self-contained** within the repository and requires no external services beyond the OpenCode runtime.
- Users interact via standard OpenCode CLI commands or programmatic SDK calls, with help text defined in the command markdown file.

## Frequently Asked Questions

### What files comprise the OpenCode plugin integration?

The integration requires four critical files: the global configuration at **[`opencode.json`](https://github.com/ayghri/i-have-adhd/blob/main/opencode.json)**, the JavaScript entry point at **`.opencode/plugins/i-have-adhd.mjs`**, the command documentation at **[`.opencode/command/i-have-adhd.md`](https://github.com/ayghri/i-have-adhd/blob/main/.opencode/command/i-have-adhd.md)**, and the skill definition at **[`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md)**. Additionally, **[`AGENTS.md`](https://github.com/ayghri/i-have-adhd/blob/main/AGENTS.md)** provides high-level guidance for agent implementations.

### How does the plugin access the ADHD skill rules?

The plugin uses Node.js `fs` module functions to synchronously read **[`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md)** using a relative path resolved from `import.meta.dirname`. This ensures the canonical 10 ADHD-friendly rules are available during command execution without requiring external API calls.

### Is external configuration required beyond the repository?

No. The OpenCode plugin is **self-contained**. All necessary configuration resides in [`opencode.json`](https://github.com/ayghri/i-have-adhd/blob/main/opencode.json), and the skill logic lives within the repository. The OpenCode runtime handles permission management and execution context without additional binaries or external services.

### Can the skill function outside the OpenCode ecosystem?

The I-Have-ADHD skill is designed specifically for the OpenCode runtime environment. While the **[`SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/SKILL.md)** file contains portable rules, the command registration, permission handling via [`opencode.json`](https://github.com/ayghri/i-have-adhd/blob/main/opencode.json), and execution context depend on the `@opencode-ai/sdk` and the OpenCode plugin architecture.