Pre-Send Check Mechanism in i-have-adhd: Validating ADHD-Friendly Responses

The pre-send check mechanism in the i-have-adhd project is a validation interceptor that runs immediately before responses reach the user, ensuring all output complies with the ten ADHD-friendly formatting rules defined in the project's SKILL.md file.

The ayghri/i-have-adhd repository provides an OpenCode plugin designed to make AI interactions accessible for users with ADHD. Its pre-send check mechanism acts as a final quality gate, parsing and validating every generated response against strict formatting guidelines to ensure clarity and readability.

Architecture of the Pre-Send Check Mechanism

The Validation Pipeline

The pre-send check operates through a sequential validation pipeline implemented in .opencode/plugins/i-have-adhd.mjs. When the plugin prepares a reply, it executes five critical steps:

  1. Collect raw output: Gather the complete text generated by the language model.
  2. Execute preSendCheck: Pass the output through the preSendCheck validator function.
  3. Parse and verify: Check adherence to the ten ADHD-friendly response rules (e.g., sentence length limits, jargon avoidance).
  4. Content safety scan: Detect disallowed content including unsafe suggestions or copyrighted material, while respecting runtime token limits.
  5. Conditional forwarding: Only transmit the response after successful validation; otherwise, trigger regeneration or modification.

Integration with the Runtime

The mechanism integrates through hooks/always-on.mjs, which loads the plugin and registers the pre-send hook with the OpenCode runtime. This ensures the validation runs automatically for every outgoing message without manual intervention.

Core Implementation Files

.opencode/plugins/i-have-adhd.mjs

This file contains the preSendCheck function that implements the core validation logic. It serves as the primary entry point for the pre-send check mechanism, parsing responses and determining compliance with formatting rules.

skills/i-have-adhd/SKILL.md

This markdown file defines the ten ADHD-friendly response rules that serve as the validation criteria. For example, it mandates that no sentence exceed 20 words and prohibits technical jargon without explanation. The preSendCheck function references these rules during validation.

hooks/always-on.mjs

The entry point that wires the plugin into the runtime architecture. It ensures the pre-send check executes automatically before any response reaches the client, maintaining consistent accessibility standards across all interactions.

Code Implementation Example

The following example demonstrates how to invoke the pre-send check mechanism within the plugin architecture:

import { preSendCheck } from './.opencode/plugins/i-have-adhd.mjs';

// `rawResponse` is the text produced by the LLM.
async function sendResponse(rawResponse) {
  const validated = await preSendCheck(rawResponse);
  if (!validated.ok) {
    // Regenerate or modify the response until it passes.
    return sendResponse(await regenerateResponse());
  }
  // Only now is the response sent to the user.
  client.send(validated.text);
}

When preSendCheck detects a rule violation—such as a sentence exceeding the 20-word limit defined in SKILL.md—it flags the violation, triggers trimming or rewriting, and only permits transmission after the output achieves compliance.

Summary

  • The pre-send check mechanism intercepts all responses in .opencode/plugins/i-have-adhd.mjs before they reach users.
  • The preSendCheck function validates output against ten ADHD-friendly rules defined in skills/i-have-adhd/SKILL.md.
  • Validation failures result in automatic trimming, rewriting, or regeneration of non-compliant content.
  • The hooks/always-on.mjs file registers the plugin to ensure the check runs on every outgoing message.
  • Content must pass safety scans for disallowed material and token limit checks before transmission.

Frequently Asked Questions

What triggers the pre-send check mechanism in i-have-adhd?

The pre-send check triggers automatically for every response generated by the language model. The hooks/always-on.mjs file registers the plugin with the OpenCode runtime, ensuring the preSendCheck function executes immediately before any text reaches the user interface.

Where are the ADHD-friendly validation rules defined?

The validation rules are defined in skills/i-have-adhd/SKILL.md. This file specifies ten formatting requirements, including sentence length limits and jargon restrictions, which the preSendCheck function enforces during the validation pipeline.

How does the pre-send check handle validation failures?

When the preSendCheck function detects non-compliant content, it either trims or rewrites the offending sections, or aborts the send operation entirely. The system then regenerates the response and repeats the validation cycle until the output achieves compliance.

Can developers extend the pre-send check with custom validation rules?

Yes, developers can extend the mechanism by modifying the preSendCheck function in .opencode/plugins/i-have-adhd.mjs and adding corresponding criteria to skills/i-have-adhd/SKILL.md. The modular architecture allows additional validation layers to integrate seamlessly with the existing pipeline.

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 →