> ## Documentation Index
> Fetch the complete documentation index at: https://docs.commanderplugin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Intelligence Layer: How CC Commander Thinks Before It Acts

> How CC Commander scores task complexity, detects your stack, recommends skills, and compounds session knowledge automatically — zero configuration needed.

Before dispatching a single token to Claude Code, CC Commander runs four analysis modules that together decide the right model, budget, turn limit, and skills for your task. You never touch a config flag — the Intelligence Layer handles every dispatch automatically based on what your task actually needs.

<Note>
  The Intelligence Layer runs automatically — no configuration required.
</Note>

## The four modules

### 1. Weighted complexity scoring

Every task you describe is scored from 0 to 100 using 47 keyword signals, word count, and fuzzy regex matching. The score maps directly to a model, turn limit, and dollar budget.

```
"fix typo"             → score  0  → 10 turns, $1 budget, Haiku
"add dark mode"        → score 25  → 20 turns, $3 budget, Sonnet
"refactor auth module" → score 60  → 35 turns, $6 budget, Sonnet
"build SaaS platform"  → score 100 → 50 turns, $10 budget, Opus
```

The scorer starts at a baseline of 30 and adjusts up or down based on what it finds in your task description:

| Signal type                    | Example                                      | Effect         |
| ------------------------------ | -------------------------------------------- | -------------- |
| Trivial reducers               | `fix typo`, `rename`, `one line`             | −15 to −30 pts |
| Moderate adders                | `add feature`, `refactor`, `integrate`       | +10 to +20 pts |
| High-complexity adders         | `build saas`, `from scratch`, `multi-tenant` | +25 to +40 pts |
| Long description (25–50 words) | Detailed task prompt                         | +10 pts        |
| Long description (50+ words)   | Very detailed prompt                         | +20 pts        |
| File scope bonus               | Matches many project files                   | 0 to +20 pts   |

The four score ranges and what they produce:

| Score range | Label    | Turns | Budget | Effort |
| ----------- | -------- | ----- | ------ | ------ |
| 0–25        | Trivial  | 10    | \$1    | low    |
| 26–50       | Simple   | 20    | \$3    | low    |
| 51–75       | Moderate | 35    | \$6    | medium |
| 76–100      | Complex  | 50    | \$10   | high   |

File scope estimation adds a 0–20 point bonus by scanning how many project files the task is likely to touch. You never need to set `--model`, `--budget`, or `--max-turns` manually.

### 2. Stack detection

Before every dispatch, CCC reads your project directory and detects your technology stack automatically. It parses `package.json`, `Dockerfile`, `go.mod`, and `requirements.txt`. It also reads your current git branch and the themes of your last five commits, and detects monorepo setups (workspaces, lerna, turbo, nx).

From those files it recognizes: nextjs, react, vue, docker, python, rust, go, github-actions, orm, billing, and testing frameworks. No configuration needed — CCC reads what is already in your project.

### 3. Skill recommendations

Once the stack and task are known, CCC's skill recommender combines three signals to surface the most relevant skills:

| Signal        | Weight           | What it does                                         |
| ------------- | ---------------- | ---------------------------------------------------- |
| Stack match   | 10 pts           | Next.js project → `nextjs-app-router` ranks first    |
| Keyword match | 2 pts per hit    | "auth" task → `auth`, `jwt`, `better-auth` bubble up |
| Usage history | Boost multiplier | Skills that succeeded for you rank higher over time  |

Trending skills (7-day window) surface automatically. Skills that led to successful sessions compound their ranking advantage the more you use them.

### 4. Knowledge compounding

Every completed session extracts a lesson — keywords, category, tech stack, error patterns, success patterns — and stores it in `~/.claude/commander/knowledge/`. The next time you dispatch a similar task, those lessons are injected into the session prompt automatically.

Relevance is weighted by time:

| Age                | Multiplier |
| ------------------ | ---------- |
| Less than 7 days   | 2×         |
| 7–30 days          | 1.5×       |
| Older than 30 days | 1×         |

Fuzzy keyword matching and cross-domain boosts (web↔react, api↔backend, testing↔bugfix) catch related concepts across categories. Outcome weighting gives successful sessions a 1.5× boost and error sessions a 1.2× boost, so the knowledge base gets more useful the more you build.

## Smart dispatch in action

Here is what CCC's analysis output looks like before a session starts:

```
  Task: "Add authentication with JWT and OAuth"

  Intelligence Analysis:
  ├─ Complexity Score: 72/100 (complex)
  ├─ Keyword signals:  +15 (auth) +15 (implement) +20 (production)
  ├─ Word count:       +10 (detailed description)
  ├─ Stack detected:   nextjs, react, tailwind
  └─ Related lessons:  2 found (JWT auth succeeded, OAuth2 pattern)

  Auto-configured dispatch:
     Model: opus  |  Turns: 35  |  Budget: $6
     Skills: nextjs-app-router, ccc-saas, auth-patterns
     Knowledge: 2 past lessons injected

  Dispatching... ████████████████████░░░░ 78%
```

## How it compounds over sessions

| Session | What changed                                                        |
| ------- | ------------------------------------------------------------------- |
| 1       | Dispatches based on complexity score alone                          |
| 5       | Knows your stack, recommends proven skills                          |
| 20      | Has learned your patterns — feels like a PM who knows your codebase |

## Smart retry

The Intelligence Layer also handles failures automatically so you do not need to babysit long sessions:

* **Rate limit hit** — waits 60 seconds, then retries automatically
* **Context overflow** — reduces turns to 60% of original, then retries
* **Budget exceeded** — surfaces a clear error with next steps

<Tip>
  You can view your accumulated knowledge base stats at any time by running `ccc --stats`.
</Tip>
