How i-have-adhd Implements Skill Persistence Across Different Sessions
The i-have-adhd skill maintains session persistence by using a filesystem flag combined with runtime hooks that prepend the skill rules to every system prompt, ensuring continuous application until the user explicitly disables it via voice command or file deletion.
The ayghri/i-have-adhd repository provides an AI assistant skill designed for ADHD users, featuring a sophisticated mechanism for skill persistence across different sessions that eliminates the need for repeated manual activation. Unlike standard skills that require invocation per conversation, this implementation leverages hook-based architecture to modify system prompts at runtime automatically. The persistence mechanism relies on three integrated components: the declarative skill definition, cross-platform always-on hooks, and runtime flag detection systems.
Skill Definition and Rule Lifetime
The persistence contract originates in skills/i-have-adhd/SKILL.md, where lines 15‑20 explicitly declare that rules "apply to every response for the rest of the session." This section establishes the temporal boundaries governing when the skill remains active.
The skill defines specific termination triggers—"stop adhd mode" and "normal mode"—which signal the runtime to cease rule injection for the current conversation. By codifying these stop commands within the skill definition, the system creates a durable contract that persists across unlimited message exchanges until explicitly voided by the user.
The Always-On Hook System
Cross-platform execution is managed through the hooks/always-on.* scripts, which the runtime invokes before processing each generation request. The primary implementation in hooks/always-on.sh (lines 36‑44) checks for the persistence flag and, when present, prints a banner and injects the complete SKILL.md ruleset into the active system prompt.
These hooks provide native support for Claude, OpenCode, and Pi through specialized variants including always-on.ps1 for PowerShell environments and always-on.mjs for Node.js runtimes. The shell implementation specifically handles the text prepending logic that ensures the AI model receives ADHD-specific instructions at the start of every turn.
Runtime Flag Detection and Management
Actual persistence state is maintained through user-side filesystem markers. The .opencode/plugins/i-have-adhd.mjs file implements detection logic at lines 12‑14, checking for ~/.config/opencode/.i-have-adhd-always before each prompt processing cycle.
When the flag file exists, the plugin reads the skill rules and prepends them to the current prompt:
// From .opencode/plugins/i-have-adhd.mjs
if (fs.existsSync(flagPath)) {
const rules = await fs.readFile(path.join(root, 'skills', 'i-have-adhd', 'SKILL.md'), 'utf8')
prompt = `${banner}\n${rules}\n${prompt}`
}
For Claude environments, the analogous logic checks ~/.claude/.i-have-adhd-always using identical conditional injection patterns. The hooks/hooks.json file (lines 9‑12) registers these scripts to execute automatically before each request, ensuring the persistence mechanism operates transparently without manual intervention.
Enabling and Disabling Persistent Mode
Users control skill persistence across different sessions through filesystem operations and voice commands. Enable persistent mode for future sessions by creating the appropriate flag file:
# Enable for OpenCode (persists across new sessions)
touch ~/.config/opencode/.i-have-adhd-always
# Enable for Claude
touch ~/.claude/.i-have-adhd-always
To disable persistence temporarily for the current conversation, state "stop adhd mode" or "normal mode" in the chat interface. This immediately halts rule injection without removing the flag file. Permanently disable persistence for future sessions by deleting the marker:
# Disable permanently for OpenCode
rm ~/.config/opencode/.i-have-adhd-always
# Disable permanently for Claude
rm ~/.claude/.i-have-adhd-always
The Persistence Execution Flow
The complete mechanism operates through a four-stage cycle that repeats every turn:
- Hook Initialization:
hooks/hooks.jsontriggers the appropriatealways-onscript before each generation request. - Flag Verification: The script checks for
.i-have-adhd-alwaysin the user's configuration directory. - Prompt Augmentation: When the flag exists, the script reads
SKILL.mdand prepends its contents to the system prompt. - Termination Handling: Stop commands skip injection for subsequent turns; flag deletion prevents future activations.
Because injection occurs every turn, the skill remains active regardless of conversation length or context window limitations, providing consistent support throughout the entire session.
Summary
- Declarative Persistence:
SKILL.mddefines session lifetime rules and stop commands at lines 15‑20, establishing when the skill applies. - Hook-Based Injection:
hooks/always-on.sh(lines 36‑44) and cross-platform variants handle the actual text prepending operation before each AI generation. - Flag File State: Runtime detection in
.opencode/plugins/i-have-adhd.mjs(lines 12‑14) uses filesystem markers to maintain persistence state across sessions. - Automatic Registration:
hooks/hooks.json(lines 9‑12) ensures persistence logic executes automatically through the runtime's hook system. - Dual Disable Methods: Users can stop the skill temporarily via voice commands or permanently by deleting the flag file.
Frequently Asked Questions
How does the i-have-adhd skill maintain state across multiple chat sessions?
The skill maintains state through a flag file stored in the user's configuration directory (e.g., ~/.config/opencode/.i-have-adhd-always). When this file exists, runtime hooks automatically inject the skill rules into every system prompt. The state persists across sessions because the file remains on disk until explicitly deleted, causing the hook to activate every time the AI runtime initializes.
What happens if I forget to disable the always-on mode?
If you forget to disable always-on mode, the skill continues injecting its rules into every conversation indefinitely. You can pause it immediately for the current session by saying "stop adhd mode," or permanently disable it by removing the flag file from your configuration directory. The persistence is designed as opt-out to ensure continuous support without requiring user intervention.
Can I use skill persistence across different AI runtimes simultaneously?
Yes, the repository supports Claude, OpenCode, and Pi through independent hook implementations. You can enable persistence for each runtime by creating the appropriate flag file in each platform's configuration directory (e.g., both ~/.claude/.i-have-adhd-always and ~/.config/opencode/.i-have-adhd-always). Each runtime's hook system operates independently, allowing consistent ADHD support across different platforms.
Where are the persistence rules technically implemented in the source code?
The persistence contract is defined in skills/i-have-adhd/SKILL.md at lines 15‑20, specifying the session duration and stop commands. The technical implementation appears in hooks/always-on.sh (lines 36‑44) for shell environments and .opencode/plugins/i-have-adhd.mjs (lines 12‑14) for Node.js environments. The registration that triggers these scripts occurs in hooks/hooks.json at lines 9‑12.
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 →