# How Caveman Handles Multi-Step Sequences When Fragment Order Is Critical

> Discover how Caveman manages multi-step sequences with critical fragment order. Learn how it ensures accuracy by switching to explicit step-by-step output when needed.

- Repository: [Julius Brussee/caveman](https://github.com/JuliusBrussee/caveman)
- Tags: how-to-guide
- Published: 2026-07-08

---

**Caveman temporarily disables its terse fragment-oriented style and switches to explicit step-by-step output whenever it detects multi-step sequences where fragment order could be misinterpreted, automatically resuming the caveman style once the clarification is complete.**

Caveman is an OpenCode agent plugin that generates concise, fragment-oriented responses designed for rapid technical communication. When users request multi-step sequences where the order of operations matters, the system must ensure clarity to prevent dangerous misinterpretations or out-of-order execution. According to the Caveman source code in [`src/hooks/caveman-activate.js`](https://github.com/JuliusBrussee/caveman/blob/main/src/hooks/caveman-activate.js), the plugin implements an **"Auto-Clarity"** rule that temporarily pauses the terse output style during critical multi-step interactions.


## How Caveman Detects Critical Multi-Step Sequences

The detection mechanism relies on pattern recognition within the activation hook to identify when fragment ordering risks misread.

### The Auto-Clarity Rule in caveman-activate.js

The core logic resides in [`src/hooks/caveman-activate.js`](https://github.com/JuliusBrussee/caveman/blob/main/src/hooks/caveman-activate.js) at lines 133-138, where the activation hook constructs the ruleset that governs style switching:

```javascript
'## Auto-Clarity\n\n' +

'Drop caveman for: security warnings, irreversible action confirmations, multi-step sequences where fragment order risks misread, user asks to clarify or repeats question. Resume caveman after clear part done.\n\n' +

```

This rule string is injected into the model's context, instructing it to recognize **order-critical sequences** and temporarily abandon the caveman persona. The detection occurs at the conversation level, analyzing user intent for operations requiring sequential precision—such as configuration changes followed by service restarts, or database migrations requiring specific ordering.


## Temporary Style Deactivation and Recovery

When the Auto-Clarity trigger fires, Caveman executes a controlled suspension of its terse output format to ensure user safety and comprehension.

### Switching to Explicit Step-by-Step Mode

Rather than emitting fragmented, out-of-order hints, the model reverts to a **normal, explicit style** that labels each step clearly. For example, when a user requests a two-step fix involving configuration edits and service restarts, Caveman outputs structured instructions with clear ordinal markers instead of terse fragments. This prevents the user from accidentally restarting services before updating configurations due to fragment misordering.

### Automatic Resumption of Caveman Style

The deactivation is strictly temporary. According to the implementation in [`src/hooks/caveman-activate.js`](https://github.com/JuliusBrussee/caveman/blob/main/src/hooks/caveman-activate.js), the model **automatically resumes** the caveman style after the user confirms completion of the clear part or repeats the question. This state management ensures that the terse style remains available for subsequent routine queries without requiring manual reactivation.


## Code Examples: Standard vs. Multi-Step Handling

The following examples demonstrate how Caveman adapts its output format based on sequence complexity.

### Typical Single-Step Fragment Output

For simple, single-step issues where order is irrelevant, Caveman maintains its terse style:

```text
Bug in auth middleware. Token expiry check use `<` not `<=`. Fix:

```

This format delivers maximum information density with minimal tokens.

### Multi-Step Sequence with Explicit Ordering

When the user requests a two-step process where execution order matters, Caveman drops the fragment style:

```text
To safely apply the changes, let's go step-by-step:

**Step 1** – Edit the configuration file:

```bash

# edit /etc/app/config.yaml

```

**Step 2** – Restart the service:

```bash
systemctl restart app.service

```

```

Each step is clearly labeled and separated, eliminating ambiguity about execution sequence.

### Resuming After User Confirmation

Once the user acknowledges completion with a phrase like "That's fine, continue," Caveman automatically reactivates:

```text
Config updated. Service restarted. All good.

```

The return to fragment-oriented output confirms that the Auto-Clarity mode has ended.


## Implementation Architecture

Several files collaborate to enforce the multi-step sequence handling:

- **[`src/hooks/caveman-activate.js`](https://github.com/JuliusBrussee/caveman/blob/main/src/hooks/caveman-activate.js)** – Contains the activation hook that emits the ruleset, including the Auto-Clarity logic at lines 133-138 that triggers style suspension.
- **[`plugins/caveman/skills/caveman-stats/SKILL.md`](https://github.com/JuliusBrussee/caveman/blob/main/plugins/caveman/skills/caveman-stats/SKILL.md)** – Provides the base skill description used by the activation hook to generate constraint rules.
- **[`bin/lib/opencode-agent.js`](https://github.com/JuliusBrussee/caveman/blob/main/bin/lib/opencode-agent.js)** – Loads the skill and applies model overrides, forming the infrastructure that enables the caveman style management.

Together, these components ensure that fragment order is respected by temporarily switching to explicit response modes whenever sequence-critical operations are detected.


## Summary

- **Caveman detects multi-step sequences** where fragment order could be misinterpreted through the Auto-Clarity rule defined in [`src/hooks/caveman-activate.js`](https://github.com/JuliusBrussee/caveman/blob/main/src/hooks/caveman-activate.js).
- **Style switching is automatic**—the model temporarily drops the terse "caveman" style for explicit, step-by-step output when handling order-critical operations.
- **Recovery is seamless**—once the user confirms completion or repeats the question, Caveman automatically resumes its standard fragment-oriented style.
- **Safety is prioritized** over brevity in security warnings, irreversible actions, and multi-step sequences to prevent dangerous misinterpretations.


## Frequently Asked Questions

### Does Caveman permanently disable the terse style for multi-step sequences?

No, the deactivation is strictly temporary. According to the implementation in [`src/hooks/caveman-activate.js`](https://github.com/JuliusBrussee/caveman/blob/main/src/hooks/caveman-activate.js), the Auto-Clarity rule explicitly states "Resume caveman after clear part done," meaning the terse style automatically reactivates once the sequence is complete or the user confirms understanding.

### What other triggers activate the Auto-Clarity mode besides multi-step sequences?

The Auto-Clarity rule in [`src/hooks/caveman-activate.js`](https://github.com/JuliusBrussee/caveman/blob/main/src/hooks/caveman-activate.js) lists four specific triggers: security warnings, irreversible action confirmations, multi-step sequences where fragment order risks misread, and user requests to clarify or repeat questions. Any of these conditions causes the temporary style switch.

### How does Caveman know when to resume the fragment-oriented style?

The model resumes caveman style automatically after the "clear part" is done, which occurs when the user confirms completion of the steps, acknowledges the clarification, or repeats their question. This logic is embedded in the activation hook's ruleset generation without requiring explicit user commands to reactivate.

### Can users manually prevent Caveman from switching styles during sequences?

The source code does not expose a manual override mechanism for disabling Auto-Clarity. However, if a user wants to maintain explicit output, they can ask to clarify or repeat the question, which ironically triggers the very mode they wish to sustain until they indicate completion.