# Understanding the codeMode Flag in ADHD Frame Selection

> Learn how the codeMode flag in ADHD frame selection prioritizes code and design perspectives for enhanced engineering insights. Disable it for an unbiased frame pool.

- Repository: [Udit Akhouri/adhd](https://github.com/UditAkhourii/adhd)
- Tags: deep-dive
- Published: 2026-07-30

---

**The `codeMode` flag biases the frame selection algorithm toward engineering-oriented perspectives tagged with "code" or "design" when enabled, or uses the full unbiased frame pool when disabled via `--no-code-mode`.**

The `codeMode` flag controls the heuristic filtering mechanism in ADHD (Automated Divergent-Thinking Helper for Developers), determining whether the system prioritizes software engineering frames or maintains an open-ended perspective selection. This boolean parameter, exposed through the CLI as `--no-code-mode`, directly influences how the `selectFrames` function curates perspectives for LLM-powered brainstorming sessions according to the UditAkhourii/adhd source code.

## What is the codeMode Flag?

**`codeMode`** is a configuration boolean that defaults to `true` in the ADHD frame selection system. When active, it instructs the `selectFrames` function to filter the master frame list (`FRAMES`) to include only those entries tagged with `"code"` or `"design"`, ensuring the generated perspectives align with software engineering and architectural thinking patterns.

The flag also guarantees that at least one **wildcard frame** (tagged `"wild"`) remains in the selection pool. This maintains the system's characteristic divergence even when operating in technical mode, preventing the output from becoming overly constrained by conventional engineering patterns.

## How Frame Selection Works

The selection logic operates through a conditional filter applied to the complete frame repository. When `codeMode` is enabled, the system constructs a candidate pool consisting exclusively of engineering-relevant frames before applying randomization or selection algorithms.

When the flag is disabled via `--no-code-mode`, the selector bypasses this filter and draws from the full `FRAMES` array. This mode suits non-technical brainstorming scenarios—such as marketing campaigns or creative writing projects—where architectural or coding perspectives might introduce inappropriate constraints.

## Technical Implementation

### Frame Filtering Logic in src/frames.ts

The core bias logic resides in the `selectFrames` function implementation. As defined in [`src/frames.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/frames.ts) (lines 34-38), the function accepts a count parameter `n` and an optional `codeMode` parameter defaulting to `true`:

```typescript
// src/frames.ts – bias toward engineering tags when codeMode is on
export function selectFrames(n: number, codeMode = true): Frame[] {
  const pool = codeMode
    ? FRAMES.filter(f => f.tags.includes("code") || f.tags.includes("design"))
    : [...FRAMES];
  // ... selection logic continues
}

```

This implementation creates a shallow copy of the filtered array when `codeMode` is active, ensuring the original `FRAMES` constant remains immutable while the selector works with the engineering-biased subset.

### CLI Flag Parsing in src/cli.ts

The command-line interface exposes this functionality through the `--no-code-mode` flag. In [`src/cli.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/cli.ts) (line 66), the argument parser toggles the boolean value within the flags configuration object:

```typescript
// src/cli.ts – parse flag to toggle codeMode
case "--no-code-mode": f.codeMode = false; break;

```

This parsing occurs during the CLI initialization phase, storing the inverted value in the `Flags` interface instance before the engine initialization begins.

### Engine Integration in src/engine.ts

The execution engine propagates this configuration directly to the frame selector. In [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts) (line 349), the `selectFrames` function receives the current `codeMode` value from the runtime configuration:

```typescript
// src/engine.ts – use the flag when picking frames for a run
const frames = selectFrames(framesPerRun, codeMode);

```

This direct passthrough ensures that the user's CLI preference affects the actual frame selection without intermediate transformation or caching issues.

## Practical Usage Examples

The default behavior optimizes for software development scenarios by automatically filtering for technical frames:

```bash

# Default: bias toward engineering frames (codeMode enabled)

adhd "design a rate‑limiter that survives a leader election"

```

For creative or business-oriented problems where coding perspectives might limit divergent thinking, disable the filter explicitly:

```bash

# Disable the bias – useful for more open‑ended or non‑technical prompts

adhd "brainstorm a marketing campaign for a new board game" --no-code-mode

```

## Summary

- **The `codeMode` flag** controls whether ADHD filters frames for engineering relevance or uses the complete perspective pool.
- **Default behavior** (`codeMode = true`) selects frames tagged with `"code"` or `"design"` while guaranteeing at least one `"wild"` wildcard frame appears in the output.
- **Disable via CLI** using `--no-code-mode` to access the full frame repository for non-technical brainstorming scenarios.
- **Implementation spans** three key files: [`src/frames.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/frames.ts) (filtering logic), [`src/cli.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/cli.ts) (argument parsing), and [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts) (runtime application).

## Frequently Asked Questions

### What specific tags does codeMode filter for in ADHD?

When enabled, `codeMode` filters the frame pool to include only entries containing the tags **`"code"`** or **`"design"`** in their metadata arrays. Additionally, the selection algorithm guarantees that at least one frame tagged **`"wild"`** is included in the final output to maintain divergent thinking characteristics regardless of the technical bias.

### How do I disable codeMode from the command line?

Pass the **`--no-code-mode`** flag when invoking the ADHD CLI. This sets the internal `codeMode` boolean to `false`, causing `selectFrames` to use the unfiltered `FRAMES` array rather than the engineering-specific subset. The flag should appear after your prompt string or command arguments.

### Is codeMode enabled by default in ADHD?

Yes, `codeMode` defaults to `true` in the current implementation. The `selectFrames` function signature declares `codeMode = true` as the default parameter value, ensuring that engineering-biased frame selection occurs unless explicitly disabled. This default aligns with the tool's primary use case of assisting software developers with technical problem-solving.

### Why does ADHD include wildcard frames when codeMode is enabled?

The system intentionally guarantees at least one **`"wild"`** tagged frame even in codeMode to preserve the **divergent-thinking** objective of the tool. Without this safeguard, filtering exclusively for `"code"` and `"design"` frames might produce overly conventional or predictable engineering solutions. The wildcard injection ensures unpredictable, creative perspectives remain part of the ideation process.