Toggle Theme

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

Easton editorial illustration: sculptural forked code-path tree, critic pruning ring
About 10
Default LLM calls
N=5 divergence, plus one scoring pass, one clustering pass, and K=3 deepening passes.
30-90 seconds
Typical wall-clock time
Useful at decision points, not in per-keystroke loops.
5-10x
Cost versus a single call
Token cost grows linearly with branch count, not as N squared.
9.00 / 4.83
Breadth (ADHD / baseline)
About 1.9x in the project's self-eval.
7.83 / 2.67
Novelty (ADHD / baseline)
About 2.9x in the project's self-eval.
9.50 / 1.83
Trap detection (ADHD / baseline)
The largest gap in the project's self-eval, about 5.2x.
数据来源: ADHD project self-reported evals: six open-ended engineering tasks, same model, independent LLM judging, randomized A/B order. This is not a third-party benchmark.

"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.

ADHD two-stage flow: multiple isolated branches diverge in parallel, a hard wall separates them from a separate critic that scores and prunes

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:

  1. The original problem.
  2. One frame’s vantage prompt, such as reframing the problem through latency, memory layout, regulation, on-call pressure, or inversion.
  3. 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:

  1. score: rate each branch for novelty, viability, and fit on a 0-10 scale, with mechanistic reasons for traps.
  2. cluster: group ideas by their underlying angle, not by surface keywords.
  3. 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

DimensionChain-of-Thought (CoT)Tree-of-Thought (ToT)ADHD
ThreadsSingle lineSingle tree traversalN parallel isolated branches
Shared contextyes, fully sharedyes, usually partly sharedno, hard isolation
generator/criticSynchronous evaluation inside one contextSame model alternates generation and evaluationSeparate stages, separate calls, opposite posture
Branch driverNo explicit branchNext-step variantsCognitive frames that ask the whole problem again
ParallelismNoneUsually sequentialReal concurrency, semaphore-controlled
Best fitMulti-step logic and mathSearch, planning, puzzlesOpen-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

framevantage
Hardware engineerThink through latency, memory layout, and physical constraints
Regulatory auditThink through compliance, risk, and accountability
10-year-old childThink with plain language and simple logic
Competitor trying to break itThink adversarially about vulnerabilities and weak points
BiologyThink through evolution, ecosystems, and metabolic constraints
LogisticsThink through supply chains, warehousing, and transport constraints
Game designThink through player experience, balance, and feedback loops
MarketThink through pricing, competition, and positioning
InversionWork backward from the desired outcome
$0 or infinite budgetThink through extreme budget constraints
Remove load-bearing assumptionsRemove what you currently take for granted
SpeedrunnerReach the goal in the fewest steps
Ant colonyThink through distributed, centerless coordination
3 a.m. on-callThink under urgency, fatigue, and limited resources
wild slotKeep 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:

  1. It has distinctive vocabulary, not just “think from multiple angles.”
  2. It has a distinctive posture, such as adversarial, constructive, naive, or extremely constrained.
  3. 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

ScenarioWhy it fits
Architecture/design decisionsHigh cost, multiple angles, easy-to-miss traps
API/SDK/CLI interface designUsers enter through different mental models
NamingTerms carry ambiguity across roles
Fuzzy debuggingRoot cause is unclear; hypotheses must come before verification
Migration and refactoring plansPerformance, security, compatibility, and rollout pace conflict
Broader code reviewYou want to simulate different reviewer concerns
Strategy and pricingBusiness constraints benefit from adversarial and market frames

Poor-Fit Scenarios

ScenarioWhy it does not fit
Fact lookupOne correct answer; no divergence needed
Known-root-cause bug fixThe causal chain is already clear, and divergence slows the fix
Searchable answersA baseline answer is faster and cheaper
Inner-loop/per-keystroke workA 30-90 second delay is unacceptable
Single-correct-answer problemsMore 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

DimensionData
LLM callsAbout 10: N=5 divergence + 1 scoring pass + 1 clustering pass + K=3 deepening passes
TimeUsually 30 to 90 seconds
Cost multiplier5 to 10 times a single call
Token costO(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

DimensionADHDbaselineLift
breadth9.004.831.9x
novelty7.832.672.9x
trap detection9.501.835.2x
actionability9.506.501.5x
builder usefulness7.676.831.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. 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. 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. 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. 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?
ADHD can be treated as a Tree-of-Thought variant, but it turns branch isolation, frame-driven exploration, and generator/critic separation into structural constraints. ToT usually expands the next step inside one context or search tree. ADHD makes each branch invisible to the others and asks the whole problem again through a different cognitive frame.
Does ADHD require Claude, or can it use a local model?
ADHD is built on the Claude and Codex Agent SDKs and defaults to Claude-like models. It is not a plug-and-play local-model tool. If you want to connect it to Ollama or another local model, you need to adapt the calling layer yourself.
How much does one ADHD run cost, and how slow is it?
The project describes the default run as about 10 LLM calls, usually 30 to 90 seconds of wall-clock time, and 5 to 10 times the cost of a single call. It frames the value as spending around 0.30 USD to support a 50,000 USD architecture decision. Treat that as a cost order of magnitude, not a fixed price.
Which tasks should use ADHD, and which should not?
Architecture design, API/SDK/CLI interface design, naming, fuzzy debugging, migration planning, and broader code review are good fits. Looking up an API, fixing a known-root-cause bug, answering something searchable, or working in a per-keystroke loop are poor fits.
How do I install and trigger it in Codex or Claude Code?
Use npx skills add UditAkhourii/adhd, then trigger it with /adhd "problem". If Codex does not auto-detect it, run npx skills add UditAkhourii/adhd -a codex -g, or place SKILL.md manually under ~/.codex/skills/adhd/.
Is a frame just a persona prompt?
No. A persona usually asks the model to act as someone. A frame is a vantage operator: it asks the whole problem again through latency, memory layout, regulation, on-call pressure, inversion, or another constraint. It changes the problem frame, not just the identity label.

12 min read · Published on: Jun 8, 2026 · Modified on: Jul 14, 2026

Comments

Sign in with GitHub to leave a comment

Easton BlogEaston Blog