What Is the Pre-Send Check in I-Have-ADHD? Hook-Based Validation Explained
The pre-send check in I-Have-ADHD is an automated ESLint validation pipeline that executes via the hook system before any agent request is processed, halting execution immediately if code quality checks fail.
The pre-send check serves as a critical quality gate in the I-Have-ADHD repository, ensuring that only lint-free, syntactically correct code reaches the ADHD-friendly agent. Implemented through a JSON hook configuration and Node.js scripts, this validation layer prevents malformed inputs from triggering downstream failures.
How the Pre-Send Check Works
Hook Configuration in hooks/hooks.json
The validation pipeline originates in hooks/hooks.json, where the pre array specifies commands that must succeed before the skill executes. According to the source code, the configuration declares a mandatory linting step:
{
"hooks": {
"i-have-adhd": {
"description": "Runs i-have-adhd skill",
"pre": [
"npm run lint"
],
"post": [
"npm test"
]
}
}
}
When the agent receives a request, the system processes the pre array sequentially. If any command returns a non-zero exit code—indicating ESLint errors—the request aborts before reaching the skill logic.
ESLint Integration via package.json
The actual validation logic resides in the lint script defined in package.json. This script invokes ESLint across the entire codebase, targeting TypeScript and JavaScript files:
{
"name": "i-have-adhd",
"version": "1.0.0",
"scripts": {
"lint": "eslint . --ext .ts,.js",
"test": "npm run lint && jest"
}
}
The eslint . --ext .ts,.js command recursively scans all source files, enforcing style rules and catching syntax errors. Because the test script also invokes linting, the pre-send check effectively gatekeeps both execution and testing phases.
Verification Helper in scripts/check_context_compat.ts
The repository includes a compatibility checker at scripts/check_context_compat.ts that validates hook configurations programmatically. The script parses hooks.json and inspects each entry for the presence of pre-hooks:
import { readFileSync } from "fs";
import { resolve } from "path";
const cwd = resolve(process.argv[2] ?? ".");
const file = readFileSync(resolve(cwd, "hooks", "hooks.json"));
const json = JSON.parse(file.toString());
for (const [name, hook] of Object.entries(json.hooks)) {
if (hook?.pre?.length) {
// TODO: verify the pre hook...
}
}
While currently contains a placeholder TODO comment, this utility ensures that hooks declaring pre arrays are flagged for verification during development workflows.
Extending Validation with the OpenCode Plugin
The I-Have-ADHD project provides a runtime extension point for custom pre-send logic via the OpenCode plugin architecture. Located at .opencode/plugins/i-have-adhd.mjs, the current implementation offers an async pre hook placeholder:
export default {
name: "i-have-adhd",
description: "ADHD‑friendly agent behavior",
hooks: {
pre: async (context) => {
// TODO: implement pre‑send validation
},
post: async (context) => {
// placeholder post‑hook
}
}
};
Developers can extend this hook to implement request-specific validations. For example, enforcing prompt length limits:
pre: async (context) => {
if (context.prompt.length > 500) {
throw new Error("Prompt too long – pre‑send check failed");
}
}
Running the Pre-Send Check Manually
While the hook system triggers validation automatically, developers can execute the pre-send check independently using npm:
# Execute ESLint validation directly
npm run lint
# Or run the full check sequence (lint + test)
npm test
Manual execution proves useful during development to verify fixes before committing changes that would trigger the automated hook.
Summary
- Hook-driven architecture: The pre-send check is defined in
hooks/hooks.jsonthrough theprearray, which executes before skill processing begins. - ESLint enforcement: The validation runs
eslint . --ext .ts,.jsvia thenpm run lintcommand, ensuring TypeScript and JavaScript files meet quality standards. - Execution blocking: If linting detects errors, the process exits with a non-zero code, preventing the agent from processing malformed requests.
- Extensible runtime: The OpenCode plugin at
.opencode/plugins/i-have-adhd.mjsprovides an asyncprehook for implementing custom validation logic beyond static analysis. - Development utilities:
scripts/check_context_compat.tsoffers programmatic verification of hook configurations during build processes.
Frequently Asked Questions
What happens if the pre-send check fails?
If ESLint detects syntax errors or style violations during the npm run lint execution, the command returns a non-zero exit code. This failure propagates through the hook system, causing the agent to abort the request immediately before any skill logic executes. The user receives the linting error output rather than a processed response.
Can I customize the pre-send validation rules?
Yes. You can modify the ESLint configuration by editing .eslintrc files or updating the lint script in package.json to include additional flags or directories. For runtime validations—such as checking input length or content filtering—implement custom logic in the pre async function within .opencode/plugins/i-have-adhd.mjs.
Where exactly is the pre-send check configured?
The primary configuration resides in hooks/hooks.json under the i-have-adhd hook definition, specifically within the pre array. The actual command executed (npm run lint) is defined in package.json scripts section. This separation allows the hook system to remain agnostic of the specific linting implementation while enforcing execution order.
Does the pre-send check run automatically on every request?
Yes. When the I-Have-ADHD agent processes a request, the hook system automatically executes all commands listed in the pre array of hooks/hooks.json. This occurs before any skill-specific code runs, ensuring consistent code quality checks without requiring manual intervention for each interaction.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →