## TL;DR
Remove the artifacts from git, add the output directories to .gitignore, and make the agent build to a temp directory. Generated output should never be versioned.

## Error
```text
(repo contains docs/site/, docs/_build/, thousands of generated HTML files committed)
```

## Steps
1. Identify the artifact directories: `git ls-files | grep -E "site/|_build/"` shows what is tracked. Expected: the list of committed build output.
2. Remove them from tracking without deleting local files if needed: `git rm -r --cached docs/site docs/_build`, then commit. Expected: the files leave version control.
3. Add the output directories to .gitignore (e.g. `site/`, `_build/`, `.docusaurus/`). Expected: future builds cannot be committed accidentally.
4. Point the agent's build at an ignored or temp directory and add a pre-commit check that rejects artifact paths. Expected: the pollution cannot recur.

## When to use
- Build output directories appear in git history
- A docs agent ran `git add -A` after building
- PRs contain thousands of generated files

## When not to use
- The artifacts are intentionally committed (rare; prefer CI-built previews instead)
- The problem is build output in the wrong place but not committed
- You need the built site in the repo for a specific host (use a separate branch)

## Tool compatibility
Git with Sphinx (_build), MkDocs (site), Docusaurus (.docusaurus, build). Same hygiene for all.

### Variant phrasings
### agent keeps re-committing the site dir
The .gitignore entry is missing or the agent force-adds. Fix the ignore file and the agent's add command.

### artifacts committed before .gitignore existed
git rm --cached untracks them; the ignore file only prevents future adds.

## Why it happens
Agents that finish with a broad `git add -A` sweep up everything the build produced. Without .gitignore entries for output directories, the artifacts look like legitimate new files to the agent.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_W6-Wi9_wzyHKevPD1Ol-BQ
