ADHD for Coding Agents: A Tree-of-Thought Style Parallel Reasoning Engine

"The ADHD README confirms the project positioning, the adhd-agent npm package, the MIT license, installation commands, the two-stage mechanism, and the eval reporting frame."
"The how-it-works document confirms the Diverge/Focus stages, isolated branches, semaphore-based concurrency, and linear token-cost model."
"The vs-cot-and-tot document confirms the structural differences between ADHD, Chain-of-Thought, and Tree-of-Thought, including the claim that frames are not personas."
"The frames document confirms the 15 cognitive frames, codeMode, the wild slot, and the standards for custom frames."
"The when-to-use document confirms the fit and non-fit scenarios, default call count, 30-90 second time range, and cost positioning."
"The New Stack coverage provides third-party ecosystem context for ADHD."
When a CLI call to an LLM occasionally freezes for 90 seconds, how should you design retries and timeouts? The textbook answer is predictable: use exponential backoff with jitter, set an absolute timeout, and retry once. That is not wrong, but it may miss the sharper question: is the network actually slow, or did you pick the wrong model? Should the button feel more urgent the longer the user waits, with a one-click option to switch to a faster model?
ADHD is built for that class of problem. It is not a prompt that tells the agent to “think again.” It is a parallel reasoning structure for AI coding agents: multiple isolated branches diverge through different cognitive frames, then a separate critic scores, clusters, prunes traps, and deepens the survivors. This guide focuses on the skill’s mechanism, boundaries, and when it is worth using.
What ADHD Is (Not a Prompt Trick)
ADHD’s positioning is specific: it tries to fix premature convergence in autoregressive reasoning, not sprinkle more encouragement into a prompt.
Autoregressive models generate one token at a time. Once the first few steps pick a direction, the rest of the answer tends to build around it. That is efficient, but open-ended engineering tasks expose the downside: the first plausible answer becomes the anchor. The model slides toward the most common, most textbook-shaped path. That answer is often correct enough, and it often misses the less obvious option that would matter more.
Normal prompts can ask a model to “compare multiple options,” “think from different angles,” or “avoid jumping to conclusions.” The problem is that those branches still share one context. The model generates and evaluates in the same space, so once an early direction appears, later branches struggle to escape it.
ADHD takes a harder route. The divergence phase becomes N fully isolated Agent SDK calls. Each branch sees only the original problem, one cognitive frame, and a system prompt that forbids evaluation. Branches share no context. A later focus phase uses a separate critic call to score, cluster, prune, and deepen the results.
In one sentence: CoT makes one mind think more slowly, Tree-of-Thought makes one mind search more broadly, and ADHD makes multiple minds think differently in parallel before a critic chooses.
Two-Stage Mechanism: A Hard Wall Between Diverge and Focus
ADHD is built around two stages: Phase 1 Diverge and Phase 2 Focus. A hard wall sits between them. Divergence forbids evaluation; only the focus stage is allowed to converge.

Phase 1 Diverge: N Concurrent Isolated Branches
The first stage chooses N cognitive frames, with N=5 by default, then starts N isolated Agent SDK queries in parallel. Each branch receives only three inputs:
- The original problem.
- One frame’s vantage prompt, such as reframing the problem through latency, memory layout, regulation, on-call pressure, or inversion.
- A system prompt that forbids evaluation, ranking, and hedging.
Branches cannot see each other. The regulatory-audit branch cannot read what the speedrunner branch wrote. The hardware-engineer branch is not anchored by the ten-year-old branch. Each branch is an independent stateless session, so anchoring is not suppressed by model discipline; it is removed by structure.
Concurrency is controlled by a semaphore, with concurrency=4 by default. Token cost grows linearly with the branch count: O(N x each branch), not N squared, because later branches do not reread the full contents of earlier branches.
Phase 2 Focus: A Separate Critic Call
The second stage switches to a separate critic call. It does three things:
- score: rate each branch for novelty, viability, and fit on a 0-10 scale, with mechanistic reasons for traps.
- cluster: group ideas by their underlying angle, not by surface keywords.
- deepen top-K: deepen the default K=3 surviving ideas with sketches, load-bearing risks, first actions, and 3 to 5 sub-ideas.
The important design choice is mechanical generator/critic separation. The generator phase must not evaluate; the critic phase must evaluate. These are not two promises inside one chat. They are separate API calls with different system prompts and opposite posture.
The isolated-branch call shape looks roughly like this:
const branches = await Promise.all(
frames.map((frame) =>
withSemaphore(concurrency, () =>
callLLM({
systemPrompt: `${frame.vantage}\n\nFORBIDDEN: evaluation, ranking, hedging. JSON array out.`,
userPrompt: `${problem}\n\n${context ?? ""}`,
}),
),
),
);
Back to the retry/timeout example. A baseline answer tends to produce a standard hybrid: 15 seconds for first-token timeout, 30 seconds for inter-token timeout, a 90-second hard cap, and one automatic retry. ADHD’s value is not making that answer longer. It may surface an extra option such as “make the button feel hotter as the wait grows, and let the user cancel and rerun on a faster model,” while also flagging amusing but dangerous ideas like “stream tokens in reverse” or “charge by user patience” before anyone spends engineering time on them.
Structural Comparison with CoT and ToT
| Dimension | Chain-of-Thought (CoT) | Tree-of-Thought (ToT) | ADHD |
|---|---|---|---|
| Threads | Single line | Single tree traversal | N parallel isolated branches |
| Shared context | yes, fully shared | yes, usually partly shared | no, hard isolation |
| generator/critic | Synchronous evaluation inside one context | Same model alternates generation and evaluation | Separate stages, separate calls, opposite posture |
| Branch driver | No explicit branch | Next-step variants | Cognitive frames that ask the whole problem again |
| Parallelism | None | Usually sequential | Real concurrency, semaphore-controlled |
| Best fit | Multi-step logic and math | Search, planning, puzzles | Open-ended engineering design and ideation |
Three Load-Bearing Differences
First, ADHD is isolation, not search. ToT branches still unfold inside one tree, where early nodes influence later nodes. ADHD branches cannot see each other during divergence, so anchoring is removed by construction.
Second, ADHD uses frames rather than next-step variants. ToT often expands “what should the next move be?” ADHD asks the whole problem again from another cognitive position. It does not tweak a parameter; it asks the model to reconsider the problem through latency, physical constraints, regulatory responsibility, or 3 a.m. on-call pressure.
Third, generator-critic separation is mechanical, not a promise. Saying “do not evaluate yet” inside one context still lets the model compare ideas while generating them. ADHD separates that work through different calls, different system prompts, and different posture.
One clarification matters: a frame is not a persona. A persona says “you are this kind of person.” A frame says “re-ask this problem through these constraints and this vocabulary.” The former changes an identity label. The latter changes the problem frame.
The 15 Cognitive Frames and How to Customize Them
ADHD ships with 15 cognitive frames that bend the same problem in different directions. codeMode defaults toward code and design perspectives, and each run keeps one wild slot so divergence does not become too tidy.
Built-In Frame Examples
| frame | vantage |
|---|---|
| Hardware engineer | Think through latency, memory layout, and physical constraints |
| Regulatory audit | Think through compliance, risk, and accountability |
| 10-year-old child | Think with plain language and simple logic |
| Competitor trying to break it | Think adversarially about vulnerabilities and weak points |
| Biology | Think through evolution, ecosystems, and metabolic constraints |
| Logistics | Think through supply chains, warehousing, and transport constraints |
| Game design | Think through player experience, balance, and feedback loops |
| Market | Think through pricing, competition, and positioning |
| Inversion | Work backward from the desired outcome |
| $0 or infinite budget | Think through extreme budget constraints |
| Remove load-bearing assumptions | Remove what you currently take for granted |
| Speedrunner | Reach the goal in the fewest steps |
| Ant colony | Think through distributed, centerless coordination |
| 3 a.m. on-call | Think under urgency, fatigue, and limited resources |
| wild slot | Keep one random vantage point |
Selection Rules
- The same problem with the same seed selects the same frame set, which makes runs reproducible.
- codeMode defaults toward code/design frames, so an engineering task is not handed entirely to unrelated metaphors.
- Each run keeps one wild slot, giving the system a chance to escape an overly tidy frame set.
Custom Frames
A custom frame does not need to be long. It needs to actually change the problem. A good frame satisfies at least two of these three rules:
- It has distinctive vocabulary, not just “think from multiple angles.”
- It has a distinctive posture, such as adversarial, constructive, naive, or extremely constrained.
- It has a reproducible distortion that reliably changes the reasoning direction.
For example, you could write a subscription-product frame:
name: subscription_retention
vocabulary: ["subscription", "retention", "churn", "renewal", "lifecycle"]
stance: "Think in terms of subscription churn and lifetime value, not one-time transactions"
distortion: "Assume users will churn; design mechanisms that reduce churn"
This does not merely label the model as a “growth lead.” It pushes the problem into retention, churn, and lifetime value constraints.
When to Use It, and When Not To
ADHD is a decision-point tool, not an everyday per-keystroke tool. A simple test works well: if a junior developer can Google it, the baseline wins. If a senior developer would pause and say “let me think about that from another angle,” ADHD is in range.
Good-Fit Scenarios
| Scenario | Why it fits |
|---|---|
| Architecture/design decisions | High cost, multiple angles, easy-to-miss traps |
| API/SDK/CLI interface design | Users enter through different mental models |
| Naming | Terms carry ambiguity across roles |
| Fuzzy debugging | Root cause is unclear; hypotheses must come before verification |
| Migration and refactoring plans | Performance, security, compatibility, and rollout pace conflict |
| Broader code review | You want to simulate different reviewer concerns |
| Strategy and pricing | Business constraints benefit from adversarial and market frames |
Poor-Fit Scenarios
| Scenario | Why it does not fit |
|---|---|
| Fact lookup | One correct answer; no divergence needed |
| Known-root-cause bug fix | The causal chain is already clear, and divergence slows the fix |
| Searchable answers | A baseline answer is faster and cheaper |
| Inner-loop/per-keystroke work | A 30-90 second delay is unacceptable |
| Single-correct-answer problems | More branches do not add useful information |
Installation and Triggering
Review the third-party skill before installing it. At minimum, read its SKILL.md: what does it ask the agent to do, can it run external commands, and can it touch directories you care about? The checklist in the OpenClaw skill security review guide is a useful starting point.
General Install
The general install command is:
npx skills add UditAkhourii/adhd
It auto-detects about 50 agents, including Claude Code, Cursor, Antigravity, Codex, Cline, Gemini CLI, and Windsurf, then installs the matching skill file.
Codex-Specific Install
If the general command does not register the skill in Codex, force the target:
npx skills add UditAkhourii/adhd -a codex -g
You can also install it manually:
curl -o ~/.codex/skills/adhd/SKILL.md https://raw.githubusercontent.com/UditAkhourii/adhd/main/SKILL.md
After a manual install, restart Codex so the skill directory is reloaded.
Triggering
Trigger it with:
/adhd "problem"
For example:
/adhd "CLI 调用 LLM 偶发 90s 卡死,该怎么设计 retry/timeout/UX?"
Do not wire it into every completion. The better use is to trigger it explicitly at architecture, interface design, naming, or fuzzy-debugging points.
Cost and Value
Cost Data
| Dimension | Data |
|---|---|
| LLM calls | About 10: N=5 divergence + 1 scoring pass + 1 clustering pass + K=3 deepening passes |
| Time | Usually 30 to 90 seconds |
| Cost multiplier | 5 to 10 times a single call |
| Token cost | O(N x each branch), linear growth, not N squared |
Value Positioning
The project’s positioning is: spend around 0.30 USD to support an architecture decision worth 50,000 USD. That is not an argument for running ADHD on every small question. It is a reminder that a wrong open-ended engineering decision can cost far more than one multi-branch reasoning run.
In real projects, context cost also matters. In Claude Code or a similar agent session, each branch may reload the base project context, tool instructions, and repository rules. The pure algorithmic cost is O(N x each branch), but the practical bill is closer to N x (base context + branch work). That makes it a tool for “should we design it this way?” rather than “what is the next line of code?”
Reading the Eval Results
The ADHD project publishes a self-eval: six open-ended engineering tasks, the same model, independent LLM judging, and randomized A/B order. Keep that scope visible. It is not a third-party academic benchmark, and it is not a human evaluation.
Five-Dimension Comparison
| Dimension | ADHD | baseline | Lift |
|---|---|---|---|
| breadth | 9.00 | 4.83 | 1.9x |
| novelty | 7.83 | 2.67 | 2.9x |
| trap detection | 9.50 | 1.83 | 5.2x |
| actionability | 9.50 | 6.50 | 1.5x |
| builder usefulness | 7.67 | 6.83 | 1.1x |
Reporting Caveat
These numbers are useful for direction, not as authoritative benchmark claims. They do not prove that ADHD beats every reasoning strategy. They support a narrower reading: on open-ended engineering prompts, isolated divergence plus a separate critic can change breadth, novelty, and trap detection in visible ways.
So do not write it as “industry-leading benchmark performance.” The safer statement is: in the project’s self-eval across six open engineering tasks, ADHD won five, with the largest gap in trap detection. Keep the factual boundary clear and the reader can decide how much weight to give the numbers.
Conclusion
ADHD is interesting not because it makes answers longer, but because it turns “think differently” into structure: branches are isolated, frames ask the problem again, and a separate critic prunes the results. That structure maps well to a common weakness in coding agents on open-ended engineering tasks: converging too early on the first answer that looks right.
Use it at decision points, not in everyday per-keystroke loops. Architecture, interfaces, naming, migrations, and fuzzy debugging are worth an extra 30 to 90 seconds. Fact lookup, known-root-cause bugs, and one-line boilerplate are better handled by a baseline agent.
If you are organizing your AI coding toolchain, read the 2026 AI coding tools landscape to see where this kind of skill fits, or the DeepAgents architecture guide to understand how subagents and planning tools organize longer reasoning chains.
Install and trigger ADHD in Codex or Claude Code
Install the ADHD skill and trigger parallel divergent reasoning at architecture, naming, fuzzy-debugging, or other high-value decision points.
- 1
Step 1: Review the third-party skill first
Open the project's SKILL.md and check what it asks the agent to do, which commands it may run, and whether it needs extra permissions. Do not install third-party skills blindly. - 2
Step 2: Run the general install command
Run npx skills add UditAkhourii/adhd. The installer auto-detects about 50 agents, including Claude Code, Cursor, Antigravity, Codex, Cline, Gemini CLI, and Windsurf. - 3
Step 3: Force the Codex target if needed
If the general command does not register the skill in Codex, run npx skills add UditAkhourii/adhd -a codex -g, or download SKILL.md manually into ~/.codex/skills/adhd/. - 4
Step 4: Trigger it at a decision point
Use /adhd "your problem". Prefer architecture, interface design, naming, and fuzzy debugging. Do not trigger it for fact lookup or per-keystroke completion.
FAQ
How is ADHD different from Tree-of-Thought?
Does ADHD require Claude, or can it use a local model?
How much does one ADHD run cost, and how slow is it?
Which tasks should use ADHD, and which should not?
How do I install and trigger it in Codex or Claude Code?
Is a frame just a persona prompt?
12 min read · Published on: Jun 8, 2026 · Modified on: Jul 14, 2026
AI Agent Toolbox: Codex, Claude Code, Skills, and Gateways
If you landed here from search, the fastest way to build context is to jump to the previous or next post in this same series.
Previous
female-portrait-director: Turn AI portrait prompts into a reusable Skill
female-portrait-director is an open-source project that turns AI portrait prompts into a structured, reusable Skill. This guide explains its parameter locking, on-demand routing, modular director-style expansion, safety boundaries, and a five-step way to turn your own prompt workflow into a Skill.
Part 4 of 5
Next
This is the latest post in the series so far.



Comments
Sign in with GitHub to leave a comment