UditAkhourii/adhd

GitHub: UditAkhourii/adhd

为编程 Agent 提供并行发散式思维树技能,通过隔离的多认知框架推理打破线性思维链的锚定局限。

Stars: 2470 | Forks: 201

ADHD for Claude Code

# ADHD — agent 的技能 [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/ad/ad5834178f7599af9fdda11629d49cae07f2997beec49821b2920eff5bfd50e7.svg)](https://github.com/UditAkhourii/adhd/actions/workflows/ci.yml) [![npm](https://img.shields.io/npm/v/adhd-agent.svg)](https://www.npmjs.com/package/adhd-agent) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE) [![Node](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](./documentation/install.md) [![论文](https://img.shields.io/badge/paper-preprint-blueviolet)](https://adhdstack.github.io/) [![特稿:The New Stack](https://img.shields.io/badge/featured-The%20New%20Stack-ff5500)](https://thenewstack.io/claude-code-adhd/) [![Discord](https://img.shields.io/badge/Discord-Join%20the%20chat-5865F2?logo=discord&logoColor=white)](https://discord.gg/NbWwkwwGw) UditAkhourii%2Fadhd | Trendshift 线性的 Chain-of-Thought 会锚定在它最开始说的话上。Tree-of-Thought 扩大了搜索范围,但仍然是在同一个共享的上下文中行进,因此这种锚定效应在不同分支间依然存在。**ADHD 将其视为一个架构问题,而不是提示词问题**——它会在刻意扭曲的认知框架下生成 N 个相互隔离的推理过程,在分歧阶段保持零共享上下文,然后再运行一个独立的评估阶段来进行打分、聚类、修剪陷阱,并深化那些留存下来的方案。 在处理**设计决策、模糊调试、命名、API 表面设计、战略规划,以及任何类似“给我几种方法来……”的提示词**时,非常适合使用它。 📄 **预印本:** [ADHD:面向编程 Agent 的并行发散式构思](https://adhdstack.github.io/) · 👤 **作者:** Udit Akhouri — [@akhouriudit](https://x.com/akhouriudit) · [LinkedIn](https://www.linkedin.com/in/udit-akhouri-10160a168/) ## 并排对比:baseline 与 ADHD 同一个评估问题,同一个模型,两种策略。完整记录见 [`bench/results.json`](./bench/results.json)。
🟦 Baseline (单次生成) 🟧 ADHD
梳理了四种**教科书式**的模式: 1. 带有分阶段 UI 的渐进式超时 (10s / 30s / 60s) 2. 快速失败 + 指数退避重试 3. 对冲并行请求 4. 流式传输与保活机制 最终给出了一个**混合型**建议——首个 token 15秒超时,token 间隔 30秒超时,绝对超时 90秒,自动重试一次。很合理。符合 Google SRE 手册第 22 章的观点。这是一个高级工程师在 30 秒内就能给出的答案。 **缺失了什么:** 没有指出任何陷阱,没有意识到*用户*可能想要主动放弃一个缓慢的请求,也没有对“等待然后重试同一个模型”这一框架提出质疑。 生成了 6 个独立的框架,在 `economic-incentive`、`async-control-surface`、`gamification`、`perceptual-distortion`、`collective-intelligence`、`redundancy-race` 等集群中浮现出了包含 30 多个创意的**庞大集合**,然后: - ★ **非显而易见的选择:** *“rage-quit = 立即中止 + 转向更便宜/更快的模型”*——一个随着你等待时间越长跳动感越强烈的按钮。点击一下即可取消,并重新提交给 Haiku 级别的模型。baseline 从未考虑过的事情:**对于这个提示词,慢速模型可能只是用错了模型。** - 加上候选名单:在 30秒时分叉探测备用 endpoint;使用工单 ID 将 CLI 守护进程化;让 3 个 LLM 副本赛跑,缓存赢家的结果。 - **标记了 20 个陷阱并附有一行原因**——包括“反向流式传输 token”和“耐心 token 计费”这些看似巧妙的想法,以防它们浪费工程时间。
针对该问题的独立 LLM 评审结果:**广度 9 vs 6,新颖度 8 vs 3,陷阱检测 ~8 vs ~2。** 方法论详见 [documentation/evals.md](./documentation/evals.md)。 ## 特稿 - 🔌 **被 [repowire](https://github.com/prassanna-ravishankar/repowire) 采用**——第一个正式集成 ADHD 的 OSS 项目。其维护者在 [PR #313](https://github.com/prassanna-ravishankar/repowire/pull/313)(已合并)中将该框架移植到了 repowire 的 mesh-orchestrator 原语上:框架变成了帧位移的临时对等节点,generator/critic 的分离映射到了独立对等节点与 orchestrator 自身轮次的对比,通过 `metadata.based-on` 进行归属说明 (MIT)。 - 📰 **[The New Stack](https://thenewstack.io/claude-code-adhd/)** 发表了一篇关于 ADHD 在 Claude Code 中应用的专题报道。 - 💬 **OpenClaw / 多 agent 社区**正在跨 agent 进行独立测试。一位测试者表示:*“我读了一下,把它安装到了两个不同的 agent 上……我真的很喜欢它。这太棒了。我以为这只是又一个没用的帖子。但事实并非如此。”* - 🔬 一篇独立的**[基于证据的研究综述](https://github.com/testdouble/han/blob/adhd-swarm-research/docs/research/adhd-application-to-han.md)**(11 个来源,8 轮验证)针对该方法发表了——研究结果作为 [issues #16–#18](https://github.com/UditAkhourii/adhd/issues) 公开追踪。 ## 早期采用者 正式集成或整合了 ADHD 的项目: | Project | What they did | Status | |---|---|---| | [**repowire**](https://github.com/prassanna-ravishankar/repowire) | 将 ADHD 移植到 repowire 的 mesh-orchestrator 原语上——框架变成了帧位移的临时对等节点,generator/critic 的分离映射到了独立对等节点与 orchestrator 自身轮次的对比。已在默认的 orchestrator 模板中集成。([PR #313](https://github.com/prassanna-ravishankar/repowire/pull/313)) | ✅ 已合并 · MIT 归属 | | [**mstack**](https://github.com/mayank-io/mstack) | 将 ADHD 作为 `think` 插件引入其 Claude 插件市场——将“先发散后收敛”的循环接入 mstack,用于架构设计、命名、API 设计和模糊调试。 | ✅ 已集成 · MIT 归属 | | [**zk-flow-oss**](https://github.com/matt-metivier/zk-flow-oss) | 将 ADHD 的 `IDEATION_FRAMES` 改造到其评审工作流中 ([`src/workflows/critique.src.js`](https://github.com/matt-metivier/zk-flow-oss/blob/main/src/workflows/critique.src.js)),作为在审查前减少锚定偏差的预处理步骤。 | ✅ 已集成 · MIT 归属 | | [**han**](https://github.com/testdouble/han) | 发表了一篇将 ADHD 应用于 Han 插件模型的[基于证据的研究报告](https://github.com/testdouble/han/blob/adhd-swarm-research/docs/research/adhd-application-to-han.md)——11 个来源,8 轮验证。研究结果作为 issues [#16](https://github.com/UditAkhourii/adhd/issues/16)–[#18](https://github.com/UditAkhourii/adhd/issues/18) 发布。 | ✅ 研究整合 | | [**app-library** (yslee5005)](https://github.com/yslee5005/app-library) | 基于 ADHD 模式构建了一个 `expert-thinker` MoAI agent——具备独立发散性的 Tree-of-thought 以及独立的 critic 过程。 | ✅ 已集成 | | [**striatum**](https://github.com/halbritt/striatum) | Claude Code 的脚手架安装程序推荐使用 `npx skills add UditAkhourii/adhd` 来进行架构、API 设计和命名工作。 | ✅ 已集成 | | [**awesome-prompts**](https://github.com/ai-boost/awesome-prompts) | 将 ADHD 循环打包成一个独立的提示词 (`adhd_parallel_ideation_skill.txt`),供未安装该技能的用户使用。 | ✅ 已集成 | | [**nix-skills**](https://github.com/sudosubin/nix-skills) | ADHD 技能的 Nix 打包版本(固定在 commit `770834e`),用于基于 Nix 的 agent-skills 生态系统。 | ✅ 已集成 | | [**caioniehues/adhd**](https://github.com/caioniehues/adhd) | 一个分支,拥有自定义的 `SKILL.md`,将安装和文档指向了他们自己的发行版,同时保留了上游归属。 | ✅ 分支 · 保留归属 | | [**ktg-one/adhd**](https://github.com/ktg-one/adhd) | 用作个人的“我大脑运作方式的编码模型”的分支——作为一种认知架构模式接入到 [may-2026-kb](https://github.com/ktg-one/may-2026-kb) 知识库中。 | ✅ 分支 · 使用中 | | [**wtfismyrepo**](https://github.com/nandnijaiswal/wtfismyrepo) | 使用 ADHD 作为代码库入职引导的解释引擎。确定性层(import-graph PageRank、git-churn 脆弱性、GitHub PR/issue 信号)生成一个分析对象,被格式化为 ADHD 的 `problem` + `context`。ADHD 的发散→打分→聚类→深化循环随后会在 12 个特定于代码库的框架(`new-grad`、`archeologist`、`security-researcher`、`on-call-at-3am`、`refactorer`、`inversion` 等)中生成入职视角,根据开发者的水平与目标对它们进行契合度评分,修剪陷阱,并将非显而易见的选择深化为完整的演练。在 Claude Code 技能 (`SKILL.md`) 中集成了 ADHD 方法,无需额外依赖——Claude 会自行运行这些框架。 | ✅ 已集成 · MIT 归属 | | [**mythify**](https://github.com/hannsxpeter/mythify) | 在评估了 ADHD 的发散框架后再评估的模式后,向其分析提示词包中添加了陷阱条款和替代方案指导——在确定计划之前,浮现出“那个看起来不错但其实不然的东西,以及原因”。([PR #18](https://github.com/hannsxpeter/mythify/pull/18)) | ✅ 已合并 | | [**godaudits**](https://github.com/hannsxpeter/godaudits) | 发布了 v2.11.0 版本,采纳了 ADHD 评审中的测量与溯源规范——一次独立的反驳过程 (`refute plan`/`apply`)、具备严重性感知的召回指标,以及评估结果上的归属/限制追踪。([PR #13](https://github.com/hannsxpeter/godaudits/pull/13)) | ✅ 已集成 | | [**godplans**](https://github.com/hannsxpeter/godplans) | 发布了 v1.8.0 版本,将其自我审计转变为一个独立的审计关卡(独立的打分阶段、隔离的上下文),并在其评估工具中添加了一个无技能的 baseline 对照组,这受到了 ADHD generator/critic 分离的启发——同时明确拒绝了新颖度评分轴和随机框架选择,因为它们不符合其自身目标。([PR #8](https://github.com/hannsxpeter/godplans/pull/8)) | ✅ 已集成 | | [**Claude1.0** (Ro-Sama-33)](https://github.com/Ro-Sama-33/Claude1.0) | 将 ADHD 技能安装到了 `.agents/skills/adhd/` 中。([PR #16](https://github.com/Ro-Sama-33/Claude1.0/pull/16)) | ✅ 已安装 | 要在你的项目中集成 ADHD 吗?提交一个 PR 在此处添加,或者[发起一个 issue](https://github.com/UditAkhourii/adhd/issues/new),我们会把你添加进来。 ## 安装说明 只需一条命令,会自动检测你的 agent(Claude Code, Cursor, Antigravity, Codex, Cline, Gemini CLI, Windsurf 及其他约 50 种工具): ``` npx skills add UditAkhourii/adhd ``` 然后通过 `/adhd "你的问题"` 显式调用,或者让它在检测到构思意图时自动触发。 ### Codex 快速路径 如果上面的通用命令未能在 Codex 中成功注册(某些 Codex 版本会从特定路径发现技能),请强制指定目标: ``` npx skills add UditAkhourii/adhd -a codex -g ``` 或者手动安装到 Codex 的技能目录中: ``` mkdir -p ~/.codex/skills/adhd curl -fsSL https://raw.githubusercontent.com/UditAkhourii/adhd/main/skills/adhd/SKILL.md \ -o ~/.codex/skills/adhd/SKILL.md ``` 重启 Codex。现在 `/adhd "设计一个限流器"` 应该会通过该技能进行路由。该技能附带了一条单行描述(≤600 字符),特别是因为某些 Codex 版本会截断或拒绝多行的 YAML 块描述。 CLI 和库的安装方式、针对其他 agent 的手动 curl 命令,以及各平台的路径详见 **[documentation/install.md](./documentation/install.md)**。 ``` npm install -g adhd-agent # CLI npm install adhd-agent # library ``` ## 快速入门 ``` adhd "design a rate limiter that survives a leader election" adhd "name this function" --frames 3 --ideas 8 --top 2 ``` ``` import { run, renderText } from "adhd-agent"; const result = await run({ problem: "How should we shard this queue under bursty load?", framesPerRun: 5, topK: 3 }); console.log(renderText(result)); // result.shortlist · result.nonObviousPick · result.traps · result.deepened · result.clusters ``` 完整参考:**[documentation/api.md](./documentation/api.md)**。 ## 运行原理 一个在两个阶段之间设有硬隔离的循环。 1. **发散。** 选取 N 个认知框架。生成 N 个并行的、**相互隔离**的 Agent 调用——每个调用都会看到问题加上某一个框架的视角提示词,以及一个禁止进行评估的系统提示词。各个分支永远看不到彼此,因此没有锚定效应。 2. **。** 一个独立的 critic 调用会对每一个想法进行打分(`novelty / viability / fit`),附上理由标记出陷阱,按照底层角度进行聚类,并将排名前列的 K 个幸存者深化为包含风险和初步步骤的草案。 generator 和 critic 的分离是**机制性**的——这是两个拥有完全相反系统提示词的独立 LLM 调用——而不是在一个提示词中做出的承诺。深入剖析:**[documentation/how-it-works.md](./documentation/how-it-works.md)**。与 CoT 和 ToT 的区别:**[documentation/vs-cot-and-tot.md](./documentation/vs-cot-and-tot.md)**。 ## 结果 在 6 个开放式工程问题上的平均得分(0–10 分),ADHD 与在相同模型下的单次 baseline 进行对比,由带有怀疑论资深工程师提示词的独立 LLM 进行评判,A/B 顺序已随机化。 | Dimension | ADHD | Baseline | Δ | Ratio | | ------------------ | -------: | -------: | --------: | ----: | | 广度 | **9.00** | 4.83 | **+4.17** | 1.9× | | 新颖度 | **7.83** | 2.67 | **+5.17** | 2.9× | | 陷阱检测 | **9.50** | 1.83 | **+7.67** | 5.2× | | 可操作性 | **9.50** | 6.50 | **+3.00** | 1.5× | | 构建者可用性 | **7.67** | 6.83 | **+0.83** | 1.1× | **ADHD 在 6 个问题中赢得了 5 个。** 差距最大的是陷阱检测——baseline 极少能指出那些看似诱人实则行不通的想法。方法论、局限性以及如何复现:**[documentation/evals.md](./documentation/evals.md)**。 ## 文档 | Page | What's in it | |---|---| | [快速入门](./documentation/quickstart.md) | 包含实用命令的首次技能、CLI 和 TypeScript 运行指南 | | [安装说明](./documentation/install.md) | 所有安装路径——技能、CLI、库、Agent SDK、各平台指南 | | [运行原理](./documentation/how-it-works.md) | 两阶段循环 + 架构(上下文、修剪、编排) | | [对比 CoT 与 ToT](./documentation/vs-cot-and-tot.md) | 结构对比,三个核心差异,框架 vs 角色设定 | | [框架](./documentation/frames.md) | 15 种认知框架,选择机制如何运作,如何编写自己的框架 | | [何时使用](./documentation/when-to-use.md) | 使用 / 不使用的场景,为什么它在创意工作中表现出色,成本与速度 | | [CLI 与 API](./documentation/api.md) | CLI 参数,库类型,如何在你自己的 agent 中使用 ADHD | | [评估](./documentation/evals.md) | 方法论,核心数据,局限性,路线图 | 此外:[SKILL.md](./skills/adhd/SKILL.md)(可运行技能) · [SOURCE-SPEC.md](./SOURCE-SPEC.md)(原始规范) · [CONTRIBUTING.md](./CONTRIBUTING.md) · [预印本](https://adhdstack.github.io/)。 ## 外部评测 - [**Han 插件兼容性分析**](https://github.com/testdouble/han/blob/adhd-swarm-research/docs/research/adhd-application-to-han.md) 作者 [@mxriverlynn](https://www.reddit.com/user/mxriverlynn)——使用 Han 自己的 `/research` 技能进行的基于证据的评审,11 个来源,8 轮验证。研究结果作为 issues [#16](https://github.com/UditAkhourii/adhd/issues/16)、[#17](https://github.com/UditAkhourii/adhd/issues/17)、[#18](https://github.com/UditAkhourii/adhd/issues/18) 追踪。 - [**与单次生成的精准对决**](https://miyagadget.page/en/blog/2026/06/03/adhd-coding-agent-skill-en/) 作者 Shichinomiya ([@shichinomiya_s](https://miyagadget.page))——独立的盲审基准测试(2 个问题,LLM-as-judge,A/B 位置互换)。ADHD 赢得了这两项测试,在新颖度 (4.5→9.0) 和陷阱检测 (5.0→9.0) 上提升最大,其实际成本约为 ~2.3× 的时间和 ~1.9× 的输出量。 ## 许可证 MIT License。 ADHD 将 *Divergent Ideation* 源规范 ([SOURCE-SPEC.md](./SOURCE-SPEC.md)) 进行了具体操作化。可运行的技能位于 [`skills/adhd/SKILL.md`](./skills/adhd/SKILL.md)。 ## 联系方式 **Udit Akhouri** — 预印本作者及维护者。 [adhdstack.github.io](https://adhdstack.github.io/) · [@akhouriudit](https://x.com/akhouriudit) · [LinkedIn](https://www.linkedin.com/in/udit-akhouri-10160a168/) · [researchudit@gmail.com](mailto:researchudit@gmail.com) · [@UditAkhourii](https://github.com/UditAkhourii) 欢迎从事推理、规划和 agentic 系统研究的研究实验室和应用 AI 团队合作。
标签:AI智能体, AI编程助手, Claude, CVE检测, GNU通用公共许可证, MITM代理, Node.js, 思维树, 推理优化, 暗色界面, 自动化攻击