Why Working Memory Limitations Drive Rule 5 for Restating State Across Turns in AI Interactions
Working memory limitations in ADHD require AI assistants to restate the current state every turn because users cannot retain progress information that is not visible on screen.
The ayghri/i-have-adhd repository formalizes this requirement as Rule 5 (also referenced as Rule S), a strict protocol for AI-human interactions that compensates for the cognitive reality that anything not immediately visible is effectively forgotten. This constraint fundamentally shapes how multi-step conversations must be structured to maintain user engagement and prevent task abandonment.
The Cognitive Constraint Behind Rule 5
The foundation of Rule 5 rests on a specific cognitive limitation documented in the skill definition. In skills/i-have-adhd/SKILL.md at line 25, the author explicitly states the driving principle:
"Working memory is small. Anything not on screen is forgotten. Do not ask the reader to keep in mind X."
This statement acknowledges that users with ADHD cannot reliably maintain a mental model of conversation progress when that information scrolls out of view. Traditional AI assistants often assume users remember preceding context—asking them to "refer to the previous step" or "as mentioned earlier"—which creates friction for users with limited working memory capacity. When the current step number or required action disappears from the screen, it is cognitively erased, forcing the user to scroll or guess, both of which increase cognitive load and stall execution.
How Rule 5 Compensates for Working Memory Constraints
Rule 5 is codified in skills/i-have-adhd/SKILL.md between lines 73 and 80 with specific instructions for state restatement:
"### 5. Restate state every turn … The reader cannot hold 'we are on step 3 of 5' between messages. Restate it."
By mandating that every response include an explicit recap of current progress, the rule delivers three critical compensatory functions:
- Reinforces the current position so the user does not need to maintain a mental checklist of completed versus pending steps.
- Provides a clear checkpoint that can be visually inspected by scrolling upward, externalizing memory onto the screen itself.
- Keeps the conversation self-contained, ensuring that even if the UI only renders the most recent turn, the user still possesses sufficient context to proceed.
This approach transforms the conversation interface into a cognitive prosthetic, removing the burden of retention from the user and placing it on the system.
Implementing Rule 5 in Code
Developers working with the i-have-adhd specification can enforce Rule 5 through several implementation patterns. The following examples demonstrate how to embed state restatement directly into response-generation logic.
Manual Restatement in Markdown
For static content or simple chat interfaces, explicit headers can restate progress at the beginning of every turn:
**Step 1 of 3 – Create a new file**
Create `src/util.ts` with the skeleton below.
```ts
export function greet(name: string) {
return `Hello, ${name}!`;
}
Next: Run npm test to verify the new utility works.
This pattern ensures that both the current position ("Step 1 of 3") and the next required action ("Run `npm test`") remain visually available, eliminating the need for the user to remember the task sequence.
### Automated State Restatement in Node.js
For dynamic applications, helper functions can automate the formatting of Rule 5 compliant messages. In `hooks/always-on.mjs` or related runtime hooks, implement a utility like:
```javascript
function restate(step, total, description) {
return `Step ${step} of ${total} done: ${description}. Next:`;
}
// Usage in a chatbot response
const msg = `${restate(2, 4, 'API endpoint added')} run \`npm run lint\`.`;
This function guarantees consistent formatting across all turns while ensuring the state restatement is never accidentally omitted by developers.
Conversational Pipeline Integration in Python
Backend systems generating responses can integrate Rule 5 directly into their formatting pipeline:
def format_reply(step, total, action, detail):
header = f"Step {step} of {total} done: {detail}"
footer = f"Next: {action}"
return f"{header}\n{footer}"
Using this function ensures that every message passed to the frontend contains the mandatory state information required by the specification.
Repository Architecture Supporting Rule 5
The ayghri/i-have-adhd repository structures its codebase to enforce these working memory compensations across the entire system. Key files include:
skills/i-have-adhd/SKILL.md– Contains the canonical definition of Rule 5 and the working memory constraint at line 25.hooks/always-on.mjs– Runtime hook that applies Rule 5 consistently across all conversation turns.extensions/i-have-adhd.ts– TypeScript utilities that export helper functions for state restatement.tests/test_always_on_hooks.py– Unit tests verifying that the always-on hook correctly persists state-restating behavior.README.md– High-level documentation explaining how the rules compensate for ADHD-specific cognitive constraints.
This architecture ensures that working memory limitations are addressed at every layer of the application, from specification to testing.
Summary
- Working memory constraints documented in
SKILL.mdrequire that AI assistants never assume users retain information between turns. - Rule 5 mandates explicit restatement of current step and next action in every response to externalize memory onto the screen.
- Implementation patterns range from manual Markdown headers to automated helper functions in Node.js and Python.
- Repository structure includes specific hooks and tests to enforce Rule 5 compliance across all interactions.
Frequently Asked Questions
What is Rule 5 in the i-have-adhd repository?
Rule 5 is a protocol requiring AI assistants to restate the current conversation state—including step number and next required action—on every single turn. According to skills/i-have-adhd/SKILL.md, this rule exists because users cannot reliably remember "we are on step 3 of 5" once that information scrolls off the screen.
How does working memory affect multi-turn AI conversations?
Working memory limitations mean that information not currently visible is effectively forgotten by the user. In multi-turn conversations, this causes users to lose track of progress, forget prerequisites, or abandon tasks when they cannot recall what step they are on. Rule 5 compensates by making every turn self-contained.
Where is Rule 5 defined in the source code?
Rule 5 is defined in skills/i-have-adhd/SKILL.md at lines 73 through 80, with the underlying cognitive rationale provided at line 25. The rule is implemented and enforced by hooks/always-on.mjs and tested in tests/test_always_on_hooks.py.
Can Rule 5 be implemented in languages other than JavaScript and Python?
Yes. While the repository provides examples in Node.js and Python, Rule 5 is a language-agnostic design pattern. Any system generating conversational responses can implement state restatement by prepending progress indicators (e.g., "Step X of Y") and appending next actions to every message payload, regardless of the underlying programming language.
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 →