## TL;DR
A kernel that restarts on every execution is not crashing randomly; something in the execution path kills it deterministically, most often a misbehaving IPython extension, `%autoreload` interacting badly with a module, or a kernel provisioner configured to relaunch. Disable all extensions and autoreload, then run a bare `1+1`. If it survives, re-enable one at a time to find the killer.

```text
kernel restarts and wipes variables on every cell execution, bug
```

## Use this when
- Every cell execution triggers a restart and clears all variables.
- Even `1+1` in a fresh notebook causes a restart.
- The behavior started after installing an extension or changing config.

## Not for this skill when
- Only one cell triggers a restart. That cell's code is the killer.
- The kernel restarts occasionally. That is a different, intermittent crash.

## Steps
1. Disable IPython extensions: start the kernel with `--InteractiveShellApp.extensions=[]` or comment them out of config. Verify: `1+1` executes without restart.
2. Turn off autoreload: remove `%autoreload` lines and the extension. Verify: the restart stops, implicating autoreload.
3. Check the kernelspec provisioner: read kernel.json for a custom provisioner. Verify: it is the default local provisioner, not a relaunching wrapper.
4. Re-enable extensions one at a time. Verify: you identify the one whose enablement brings the restart back.
5. Remove or update the guilty extension. Verify: a full notebook run keeps variables across cells.

## Variant phrasings
### kernel restarts every cell execution
Short form. Extension or provisioner.

### jupyter variables wiped each run
The symptom phrasing. Something relaunches per execution.

### kernel auto restart on execute
General phrasing. Bisect extensions.

Compatibility: ipykernel 6.x, IPython 8/9. Extension loading is the same across versions.

## Why it happens
IPython loads extensions at startup and some execute code on every cell via pre/post-run hooks. A hook that segfaults or raises SystemExit kills the kernel on each execution, and the UI restarts it, wiping variables. Autoreload is a frequent offender because it re-imports modules on every run and can execute import-time code with side effects. Custom provisioners that wrap the kernel launch can also misbehave per execution.

## Edge cases / pitfalls
- The guilty extension may only crash when combined with another. Bisect in combinations if single re-enables look clean.
- Notebook metadata can auto-load extensions per notebook. Check the notebook's metadata, not just global config.
- A restart-on-every-cell can also be the OOM killer if each execution allocates hugely. Rule out memory with a trivial cell first.
- Do not reinstall everything as the first step. The bisect takes ten minutes and tells you exactly what broke.

## Provenance

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