## TL;DR

Align the pre-commit hook config with the repo's jupytext settings so commits stop rewriting notebooks.
The hook applies different format or output settings than the working tree expects, so every commit produces a spurious diff.
Make the hook config and pyproject settings agree on formats and output handling, then re-sync once.

```text
jupytext pre-commit hook stripped outputs on every commit: config drift
```

## Use this when

- Every commit touches notebook files even when you changed nothing
- The pre-commit jupytext hook rewrites outputs or cell metadata
- CI fails on a jupytext --check that passes locally

## Not for this skill when

- Notebook and script diverged outside of commits - that is item 110
- Conversion output is empty - that is item 109
- The hook fails to run at all - that is a pre-commit installation problem

## Steps

1. Show the drift: run the hook manually with pre-commit run jupytext --all-files and inspect git diff.
   Expected: the diff shows output stripping or format changes you did not make.

2. Read both configs: .pre-commit-config.yaml hook args and the jupytext section of pyproject.toml.
   Expected: a visible mismatch, for example the hook passes --update-metadata while pyproject pairs with outputs kept.

3. Unify the settings: give the hook the same formats and metadata filters as pyproject, or drop the redundant hook if jupytext pairing already handles it.
   Expected: one source of truth for jupytext behavior.

4. Re-sync the tree once with the unified settings: jupytext --sync on the notebooks, then commit the result.
   Expected: a single normalization commit, then clean commits after.

5. Verify: make a trivial non-notebook change and commit.
   Expected: the hook passes without touching any notebook.

## Tool compatibility

jupytext 1.14+ / 1.16+, pre-commit 3.x, Python 3.9+

## Variant phrasings

### jupytext pre-commit strips outputs every commit

Same fix applies: see the Steps section above.

### pre-commit jupytext rewrites notebooks

Same fix applies: see the Steps section above.

### jupytext hook config drift outputs removed

Same fix applies: see the Steps section above.

## Why it happens

Pre-commit runs the hook with its own argument list, independent of the project's pyproject settings. If the hook was added with different flags than the repo's pairing config (for example clearing outputs while the project keeps them), each commit applies the hook's view of the file and git records a rewrite. The drift is silent because the hook exits 0 after modifying files. Unifying the arguments makes the hook idempotent against the working tree, so commits only touch notebooks the author actually changed.

## Edge cases / pitfalls

- Two hooks that both normalize notebooks (jupytext plus nbstripout) fight forever; keep exactly one.
- The normalization commit should be separate and reviewed; it can hide real changes if mixed with feature work.
- Developers with an older pre-commit cache may still see rewrites until they run pre-commit autoupdate.

## Provenance

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