# How Rule 5 (Restate State Every Turn) Maintains Context Across Messages in i-have-adhd

> Discover how Rule 5 in i-have-adhd ensures message continuity by restating state, maintaining context across conversations for a seamless user experience.

- Repository: [Ayoub Ghriss/i-have-adhd](https://github.com/ayghri/i-have-adhd)
- Tags: internals
- Published: 2026-08-05

---

**Rule 5 forces the model to explicitly restate current progress and workflow state in every response, creating visible continuity that survives truncated history or new chat windows.**

The `i-have-adhd` skill, developed by ayghri, is designed for users who need persistent, unambiguous task tracking during multi-step workflows. The fifth of its core guidelines—**"Restate state every turn"**—solves a critical problem in conversational AI: context decay across message turns. This article explains how Rule 5 maintains context across messages based on the actual implementation in the repository.

## What Rule 5 Actually Requires

Rule 5 mandates that every generated response includes a **structured state line** summarizing:
- Current step number and total steps
- Action just completed
- Next action pending

According to [[`SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/SKILL.md)](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md#L75-L77), this rule is defined as guideline 5 in the skill's core ruleset. The implementation enforces this pattern at the response formatting layer, not through prompt engineering alone.

## Three Mechanisms That Preserve Context

The restate-state requirement achieves persistent context through three deliberate design choices:

**Visible Continuity**
The user sees `Step 3 of 5` in every reply, eliminating the need to mentally track position across turns. The state line becomes a visual anchor.

**Stateless Interaction**
Because the full context exists in the latest message, the conversation remains resumable even if:
- Chat history truncates due to token limits
- User opens a fresh browser window
- Previous messages are lost or unavailable

**Error-Resistant Guidance**
Repetitive state declaration makes model mistakes immediately detectable. If step numbering jumps inconsistently, the error surfaces in plain sight.

## Code Implementation and File Structure

The repository implements Rule 5 across multiple configuration layers. Key files include:

- **[`SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/SKILL.md)** – Defines the complete rule set at lines 75-77, including the exact phrasing "5. Restate state every turn"
- **[`README.md`](https://github.com/ayghri/i-have-adhd/blob/main/README.md)** – Documents the five core rules and emphasizes state restatement at line 68
- **[`plugin.json`](https://github.com/ayghri/i-have-adhd/blob/main/plugin.json)** – Line 3 contains the Antigravity plugin description mentioning "restates state"
- **[`gemini-extension.json`](https://github.com/ayghri/i-have-adhd/blob/main/gemini-extension.json)** – Line 4 mirrors this description for Gemini CLI integration

The runtime applies the following formatting pattern (derived from the skill's pseudo-code implementation):

```python
def format_output(step, total, completed_action, next_action):
    state_line = f"Step {step} of {total} done: {completed_action}. Next: {next_action}."
    return f"{state_line}\n\n{generated_content}"

```

This function prepends the state line before any generated content, ensuring every response carries forward the workflow position.

## Example Output in Practice

For a database migration with five steps, Rule 5 produces output like:

```

Step 3 of 5 done: schema updated. Next: backfill the new column.

```

The model then appends its substantive response below this line. The pattern repeats identically at every turn, with only the step count and action descriptions updating.

## Why This Beats Implicit Context

Most conversational systems rely on the model's internal attention to previous turns. Rule 5 rejects this fragile approach. By externalizing state into every response, the `i-have-adhd` skill creates:

- **Recoverability** – Any single message contains sufficient context to resume work
- **Inspectability** – Users and developers can audit progression without scrolling
- **Robustness** – Token limits or context window failures cannot strip away position information

## Summary

Rule 5 in `ayghri/i-have-adhd` maintains context across messages through explicit, repetitive state declaration built into response formatting:

- The skill prepends a structured state line to every output
- Source definitions reside in [`SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/SKILL.md) lines 75-77 and supporting config files
- Pattern survives history truncation, window changes, and context loss
- Implementation uses simple string formatting rather than complex state management

## Frequently Asked Questions

### Does Rule 5 consume significant tokens with repetition?

The state line typically adds 15-25 tokens per response. The tradeoff favors clarity and resilience over minimal token usage, which aligns with the skill's goal of reducing cognitive load for ADHD users.

### Can the state format be customized per workflow?

The core pattern—`Step X of Y done: [action]. Next: [action].`—is fixed by the skill configuration. The variables (step number, action descriptions) populate dynamically based on the declared task structure.

### What happens if the model violates Rule 5?

The skill's runtime enforcement (`format_output` pattern) prevents omission. If raw model output lacks the state line, the formatting layer injects it before delivery to the user interface.

### How does this compare to conversational memory systems?

Traditional memory relies on retrieving and attending to previous turns. Rule 5 makes state **present in the current turn alone**, eliminating dependency on memory mechanisms that can fail or truncate.