name: root-hygiene description: Keep the repository root clean when working on pytest, temp files, caches, or local artifacts. Use when tests create tmp* folders, .pytest* directories, repo-local caches, or when changing test fixtures or temp-path behavior.
Root Hygiene
Overview
Use this skill to prevent temporary files, pytest artifacts, and machine-local caches from leaking into the repository root.
This repository's preferred pattern:
- tests use
tmp_pathfixtures provided by pytest (notTemporaryDirectory(dir=Path.cwd())) - ad-hoc cleanup goes through
git clean -fdx --dry-runfirst, then manually
If a change touches pytest behavior, temp directories, or cache locations, follow this skill before adding more ignore rules.
When To Use
Use this skill when:
git statusshowstmp*,.pytest*,__pycache__, or.tmp/clutter in the root- tests use
TemporaryDirectory(dir=Path.cwd())or another path that writes into the repo root - you are adding or editing tests that need temporary files
- pytest config or temp-path behavior is changing
- you need to clean local artifacts without touching tracked files
Do not use this skill for general cleanup unrelated to test/temp/cache behavior.
Rules
- Treat root clutter as a behavior problem first, not an ignore-file problem.
- Do not introduce
TemporaryDirectory(dir=Path.cwd())in this repository. - For tests, prefer pytest's built-in
tmp_pathfixture — it routes temp files to a system temp directory outside the repo. - Use
.gitignoreonly as a second line of defense after fixing the write location.
Workflow
1. Inspect before editing
git status --short
Also check:
tests/conftest.pyfor any temp directory configurationpyproject.toml(orpytest.ini) fortmp_path_retention_policysettings
2. Fix the source of root clutter
Common fixes:
- replace
TemporaryDirectory(dir=Path.cwd())with thetmp_pathfixture - route analysis output to explicit
analysis_runs/(already in.gitignore) - avoid re-enabling pytest cache provider (already disabled via
addopts = "-p no:cacheprovider"if configured)
3. Update ignore rules only if needed
Expected ignored local artifacts (already in .gitignore):
.tmp/tmp*/.pytest_cache/analysis_runs/analysis_output*/results/.worktrees/
4. Verify with focused checks
pytest tests/ -v --tb=short -x
git status --short
Confirm git status shows no new untracked clutter after running tests.
Output Expectations
When reporting the result:
- state which files were causing root clutter
- state which fixture or path policy now owns temp creation
- include the verification commands you ran
- mention any leftover historical temp directories separately from new behavior