# Atomic Commits

Every commit must be a single, self-contained logical change. Tests must pass at each commit.

## What "atomic" means

- One purpose per commit: a bug fix, a new function, a refactor — not all three
- If you need to rename something to enable a feature, that's two commits: rename first, feature second
- A commit that adds a function also adds its tests and updates exports — that's one logical change
- Never commit broken intermediate states (syntax errors, failing tests, missing imports)

## Commit sizing

- Too small: renaming a variable in one commit, updating its references in another
- Right size: adding `replace_function_source` with its tests, `__init__` export, and example update
- Too large: implementing all of context extraction (stages 4a–4e) in one commit

## Commit messages

- First line: imperative verb + what changed ("Add get_function_source for Jedi-based resolution")
- Keep the first line under 72 characters
- Use the body for *why*, not *what* — the diff shows what changed
- Reference the pipeline stage or roadmap item when relevant

## Pre-push

- Run `prek run --all-files` before pushing to catch lint/format issues CI would flag
- This catches pre-existing issues in files you didn't touch — CI lints the whole repo, not just your diff

## Branch Hygiene

- Delete feature branches locally after merging into main (`git branch -d <branch>`)
- Don't leave stale branches around — if it's merged or abandoned, remove it
- Before starting new work, check for leftover branches with `git branch` and clean up any that are already merged
- Use `/clean_gone` to prune local branches whose remote tracking branch has been deleted
