How Do the 15 Cognitive Frames Work in ADHD? Understanding Frame Selection and Vantage Operators
The ADHD repository implements 15 cognitive frames as deliberate "vantage-operator" prompts that re-pose problems from different conceptual angles, utilizing a deterministic selection algorithm in src/frames.ts that guarantees at least one "wild" frame per run while biasing toward code-centric perspectives when codeMode is enabled.
The UditAkhourii/adhd open-source project introduces a specialized architecture for divergent AI reasoning through cognitive frames—compact system prompt payloads that force language models to examine challenges from unconventional vantage points. These frames are defined in src/frames.ts and documented in documentation/frames.md, forming the backbone of a parallel reasoning engine that prevents convergent thinking. Understanding how these 15 frames function and how the deterministic selection algorithm balances engineering rigor with creative disruption is essential for leveraging the project's full analytical capabilities.
What Are Cognitive Frames in ADHD?
Cognitive frames in the ADHD project function as vantage operators—deliberate epistemological shifts encoded in approximately five-line system prompts. Rather than allowing the generator to follow its natural reasoning trajectory, each frame corners the model into exploring conceptual territory it would otherwise ignore, such as hardware constraints, biological systems, or adversarial gaming perspectives.
The 15 Built-In Cognitive Frames
The complete frame registry defined in src/frames.ts comprises fifteen distinct perspective shifts, each categorized by functional tags that drive the selection algorithm:
| Frame ID | Label | Vantage | Tags |
|---|---|---|---|
hardware-eyes |
Hardware engineer | Think in latency, memory layout, physical constraints | code, wild |
regulator |
Regulator / auditor | Audit for provable, traceable, refusable aspects | design, general |
ten-year-old |
10-year-old | Naïve, unencumbered approach; ignore conventions | general, wild |
adversary |
Competitor trying to break it | Generate adversarial exploits and then invert them | code, design |
biology |
Cross-domain: biology | Transplant mechanisms from immune systems, neural plasticity | code, wild |
logistics |
Cross-domain: logistics | Apply queues, batching, just-in-time, hub-and-spoke ideas | code, design |
game-design |
Cross-domain: game design | Identify loops, rewards, friction, speed-run tricks | design, general |
markets |
Cross-domain: markets | Model the problem as an auction, futures contract, clearing house | design, wild |
inversion |
Inversion | Ask the opposite question, then negate the answers | code, design, general |
extreme-zero |
Extreme: $0 budget, 1 hour | Produce the crudest workable version under severe constraints | code, general |
extreme-infinite |
Extreme: infinite budget, 10 years | Imagine a maximalist solution with unlimited resources | design, wild |
remove-assumption |
Remove the load-bearing assumption | Drop assumed infrastructure and redesign | code, design, wild |
speedrunner |
Speedrunner | Find glitches, skips, frame-perfect shortcuts | code, wild |
ant-colony |
Ant colony / swarm | Use decentralized local rules and emergent behavior | code, wild |
ops-3am |
On-call at 3 am | Design to avoid paging; create runbook-friendly solutions | code, design |
Each frame combines a specific vantage (the analytical angle) with categorical metadata (code, design, general, wild) that controls its eligibility during the selection process orchestrated by src/engine.ts.
How Frame Selection Works in ADHD
The frame selection logic resides in the selectFrames function within src/frames.ts, implementing a deterministic six-step algorithm that balances engineering relevance with creative divergence. The function signature exposes a configurable interface:
export function selectFrames(n: number, codeMode = true): Frame[] { … }
The Six-Step Selection Algorithm
The selection process enforces specific constraints through the following sequence:
- Code-mode bias filtering – When
codeModeistrue(default), the algorithm filters the pool to include only frames tagged withcodeordesign. Setting this tofalseexposes the full frame set including generalist perspectives. - Wildcard reservation – Frames bearing the
wildtag are segregated into a reserved pool, ensuring high-divergence perspectives remain available regardless of primary filtering. - Deterministic shuffling – The primary pool undergoes a Fisher-Yates shuffle, providing uniform random distribution while maintaining reproducibility when seeded.
- Primary pool selection – The algorithm extracts the first
n-1frames from the shuffled primary pool (or at least one whennequals 1). - Wild frame insertion – One random frame from the wild pool is guaranteed insertion if not already present, ensuring every execution retains at least one unconventional perspective.
- Final trimming – The combined collection is sliced to the requested count
n, yielding the final array passed to the parallel execution engine.
Key Properties of the Selection System
The implementation enforces three architectural constraints critical to the ADHD reasoning model:
- Deterministic reproducibility – Identical random seeds produce identical frame selections, enabling controlled A/B testing of reasoning strategies across multiple runs.
- Wild frame guarantee – Every execution includes at least one
wild-tagged frame, preventing systemic collapse into purely conventional engineering patterns. - Tag-based bias control – The
codeModeparameter allows runtime adjustment between focused technical analysis and unrestricted conceptual exploration.
Implementing Frame Selection in TypeScript
To retrieve frames in your implementation, import the selection logic and frame definitions from src/frames.ts:
// Retrieve all available frame definitions
import { FRAMES } from "./src/frames";
console.log("Available cognitive frames:", FRAMES.map(f => f.label));
For standard usage with the default code-mode bias, request a specific count of frames. The function returns a deterministic set based on the internal seed:
// Select 5 frames with code-mode bias (default behavior)
import { selectFrames } from "./src/frames";
const selected = selectFrames(5);
console.log("Selected frames:");
selected.forEach(f => console.log(`- ${f.label} (${f.id})`));
To access the full conceptual range including generalist perspectives, explicitly disable codeMode:
// Disable code-mode to include general-tagged frames
const diverseSelection = selectFrames(4, false);
console.log("Frame IDs:", diverseSelection.map(f => f.id));
These implementations can be executed via the repository's CLI or integrated into larger orchestration pipelines using the patterns established in src/engine.ts.
Summary
- The ADHD repository defines 15 cognitive frames in
src/frames.ts, each representing a deliberate vantage shift implemented as compact system prompts. - Frame selection occurs through the
selectFramesfunction, which implements a deterministic six-step algorithm guaranteeing at least onewild-tagged frame per execution. - Code-mode bias filters selections toward
codeanddesigntagged frames by default, while thecodeModeparameter allows full configurability. - The Fisher-Yates shuffle ensures reproducible randomization, enabling consistent experimental replication when using fixed seeds.
- These frames integrate into the broader parallel reasoning architecture through
src/engine.ts, with full documentation available indocumentation/frames.mdand high-level context inskills/adhd/SKILL.md.
Frequently Asked Questions
What is the purpose of cognitive frames in the ADHD repository?
Cognitive frames serve as vantage operators that force language models to re-examine problems from unconventional angles. According to src/frames.ts, each frame is designed as a "corner" that pushes the generator into conceptual territory it would not naturally explore, thereby producing divergent solutions that conventional prompting might miss.
How does the selectFrames function ensure deterministic output?
The function employs a Fisher-Yates shuffle algorithm seeded for reproducibility. When called with the same random seed, the selection process produces identical frame arrays, enabling consistent experimental conditions. This deterministic approach is critical for the parallel reasoning architecture in src/engine.ts, where reproducible frame selection ensures comparable outputs across multiple LLM invocations.
What distinguishes wild frames from code and design frames?
Wild frames (tagged wild) represent high-divergence, unconventional perspectives such as "ant colony" or "ten-year-old" thinking. Unlike code or design frames that focus on engineering rigor, wild frames prioritize creative disruption. The selection algorithm guarantees at least one wild frame per run to prevent convergence on predictable solutions, segregating them into a reserved pool before insertion into the final selection.
Can I customize which cognitive frames are available for selection?
While the built-in 15 frames are defined in src/frames.ts, the architecture supports extension through the Frame type interface. Developers can modify the FRAMES array to include custom vantage operators, provided they conform to the established schema requiring id, label, vantage description, and tags array. The selectFrames function automatically incorporates new frames into its filtering logic based on their assigned tags.
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 →