## TL;DR
Stripping cell outputs but leaving `execution_count` set produces a notebook that claims it ran (counts 1..40) with no outputs to show for it, which confuses diffing, review, and re-execution. Strip both together: set `cell.outputs = []` and `cell.execution_count = None` for every code cell. Better yet, use `nbconvert --clear-output`, which does exactly this. The notebook should look unexecuted, because it is.

```text
agent's output strip failed: left dangling execution_count values, wrong state
```

## Use this when
- A 'cleaned' notebook still shows execution counts with no outputs.
- Diffs of cleaned notebooks show phantom changes in counts.
- The agent strips outputs with custom code.

## Not for this skill when
- Outputs remain after stripping. That is a strip bug, not a count bug.
- A human strips via the UI. The UI handles counts correctly.

## Steps
1. Inspect: check that stripped cells have `execution_count: null`. Verify: counts are cleared, not just outputs.
2. Fix the strip code: for each code cell, set outputs to [] and execution_count to None. Verify: the object reflects both.
3. Prefer the standard tool: `jupyter nbconvert --clear-output --inplace`. Verify: it clears both.
4. Validate the result: `nbformat.validate(nb)`. Verify: it passes.
5. Add a test asserting stripped notebooks have null counts. Verify: the regression cannot return.

## Variant phrasings
### strip outputs execution_count left
Short form. Clear counts with outputs.

### nbconvert clear-output counts
The tool phrasing. It handles both.

### dangling execution count notebook
The state phrasing. Null them on strip.

Compatibility: nbformat 5.x, nbconvert 6/7. execution_count null is the schema-correct cleared state.

## Why it happens
Execution counts are metadata about a past run, and outputs are its artifacts; they are a pair. Custom strip code usually handles the visible half (outputs) and forgets the numeric half (counts), leaving a notebook in a state that never occurs naturally: executed but outputless. Tools that diff or re-execute notebooks read the counts as signal, so the phantom counts cause real confusion downstream.

## Edge cases / pitfalls
- Some diff tools treat null vs missing execution_count differently. Null is correct; missing can fail validation.
- Stripping outputs does not strip widget state. Clear that too for a truly clean notebook.
- The agent should strip before committing, not after. Clean notebooks in version control, always.
- Re-execution after stripping renumbers from 1. That is correct and expected.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_a9_6cDR1_JhITdTIf1kOrw
