Catch files that don't belong before you commit them. A git pre-commit hook that asks TypeSafe Jev whether each new file belongs in your repo. It catches scratch scripts, debug dumps, build output and local config before they land. Takes under a second, costs a fraction of a cent, needs no config.
git add . adds everything. Sometimes that includes:
test_fix2.py, a throwaway scriptdebug_output.json, which you dumped while chasing a bugnotes-to-self.mddata_export.csvwith real customer rows.env.localwith your own settings- a whole
dist/folder
Coding agents make this worse, they create helper scripts and scratch files and often don't clean them up. Whatever coding tool you use most likely miss most of these files:
| Tool | Catches | Misses |
|---|---|---|
.gitignore |
Names you listed in advance | Every name you didn't think of |
| Secret scanners | API keys and tokens | Junk scripts, data dumps, notes |
| Large-file checks | Big files | Small junk files |
| strayguard | Files that don't look like part of the project | Changes to files git already tracks |
- You run
git commit. - strayguard looks only at files that are new in this commit.
- A few local rules run first, such as
.envand.DS_Store. Files they match are never sent anywhere. - For the other files, Jev picks one category: belongs, scratch / leftover, output dump, build output or local only.
- If Jev is at least 70% sure a file doesn't belong, strayguard shows it to you.
- If everything belongs, you see nothing.
Jev never writes text(not good for that anyways) It only picks a category and returns a probability. The same file always gets the same answer, because strayguard caches the result.
You need Python 3.9+ and an API key from TypeSafe or OpenRouter.
pipx install strayguardpipx install git+https://github.com/Eve2512/Strayguardexport TYPESAFE_API_KEY=your-key # or: export OPENROUTER_API_KEY=your-keyThen, inside your repo:
strayguard install✓ strayguard installed in .git/hooks/pre-commit
That's it, there's no config file
Add this to .pre-commit-config.yaml:
repos:
- repo: https://github.com/Eve2512/Strayguard
rev: v0.1.0
hooks:
- id: strayguardThe pre-commit framework captures the output of its hooks, so strayguard cannot ask you questions there. It shows the warning and lets the commit through, as described in GUI clients, CI and coding agents.
Nothing, your commit goes through as normal.
$ git commit -m "add login page"
[main 4f2a91c] add login page
3 files changed, 120 insertions(+)
$ git commit -m "add login page"
⚠ strayguard: 2 new files look like they don't belong
debug_output.json output dump 87%
test_fix2.py scratch / leftover 91%
[u] unstage [g] add to .gitignore [k] keep and commit [o] one by one
> g
✓ Added 2 files to .gitignore and staged .gitignore.
✓ Unstaged 2 files. They are still on your disk.
Commit stopped so you can check. Run git commit again.
| Key | What it does |
|---|---|
u |
Takes the files out of this commit. They stay on your disk. |
g |
Adds the files to .gitignore so this never happens again, and takes them out of this commit. |
k |
Commits the files anyway. strayguard won't ask about them again. |
o |
Lets you choose u, g or k for each file. |
| Enter | Same as k. |
strayguard never deletes files. It stops the commit only if it changed something for you, so you can check before you commit again.
strayguard asks you a question only when its output goes straight to your terminal. GUI git clients, CI, coding agents and the pre-commit framework all capture the output, so there strayguard warns and lets the commit through:
⚠ strayguard: 2 new files may not belong (not blocking)
debug_output.json output dump 87%
test_fix2.py scratch / leftover 91%
To unstage them:
git rm --cached -r -- debug_output.json test_fix2.py
To block the commit instead, set STRAYGUARD_STRICT=1, this is a good setting for coding-agent sessions.
These files are never sent to Jev, so they show rule instead of a percentage:
.env.local local only rule
It prints one line, still runs its local rules, and lets the commit through:
strayguard: no TYPESAFE_API_KEY or OPENROUTER_API_KEY set, so only the local rules ran.
strayguard: Jev did not answer in 5 s, so only the local rules ran.
Everything is optional except one key.
| Variable | Default | What it does |
|---|---|---|
TYPESAFE_API_KEY |
none | Your TypeSafe API key. You need this key or OPENROUTER_API_KEY. |
OPENROUTER_API_KEY |
none | Your OpenRouter API key. strayguard uses it when TYPESAFE_API_KEY is not set. |
STRAYGUARD_PROVIDER |
by key | typesafe or openrouter. Use it when both keys are set. |
STRAYGUARD=off |
on |
Skip the check for one commit: STRAYGUARD=off git commit ... |
STRAYGUARD_STRICT=1 |
0 |
Block the commit when strayguard can't ask you, such as in CI or with agents. |
STRAYGUARD_THRESHOLD |
0.70 |
How sure Jev must be before strayguard warns you. |
STRAYGUARD_MODEL |
jev-latest (TypeSafe), ~typesafe/jev-latest (OpenRouter) |
Pin a version, for example jev-1.13.0 or typesafe/jev-1.13, to keep answers stable. On OpenRouter you can also try other decision models. |
STRAYGUARD_NAMES_ONLY=1 |
0 |
Send only file names and sizes, never content. |
You can also skip every hook for one commit with git commit --no-verify.
For each new text file, strayguard sends TypeSafe its path, its size, its first 40 lines (at most 2,000 characters) and the names of a few tracked files next to it.
It never sends:
- files that a local rule catches, such as
.envfiles, keys and certificates - binary files, or files larger than 1 MB
- any content at all when
STRAYGUARD_NAMES_ONLY=1is set
TypeSafe says it does not train models on customer data. See its legal page.
With OPENROUTER_API_KEY, the same data goes to OpenRouter, and OpenRouter sends it to the company that runs the model. See OpenRouter's privacy page.
tests/eval/run_eval.py stages 100 new files in a sample project (60 that belong, 40 strays) and runs them through the same steps as a commit, against the real API. The result on 2026-10-12 with jev-1.13.0:
| Measure | Result | Target |
|---|---|---|
| False alarms (files that belong, but flagged) | 0 of 60 | at most 5% |
| Strays caught | 40 of 40 | at least 80% |
| Changes when the order of the options changes | 0 | at most 2 |
Limitation: the same author wrote the sample files and the category descriptions, so the sample may fit the descriptions better than real-world files do. If strayguard gets a file wrong for you, please open an issue with the file name and what it said. Each report becomes a new test case.
To run it yourself, set TYPESAFE_API_KEY or OPENROUTER_API_KEY first, then run this from the repo folder (it costs less than one cent):
uv run --no-project python tests/eval/run_eval.py- A typical commit costs less than $0.0001.
- The check usually finishes in under a second.
- Each file's answer is cached by its content, so running the commit again is instant and free.
strayguard uninstallThis removes the hook only if strayguard wrote it.
| Command | What it does |
|---|---|
strayguard install |
Add the pre-commit hook to this repo |
strayguard uninstall |
Remove the hook |
strayguard check |
Run the check on staged new files (the hook runs this) |
strayguard --version |
Show the version |
Run the unit tests. They use no network and no API key:
uv run --no-project --with pytest pytestGitHub Actions runs the same tests on Python 3.9 to 3.14 for each push to main and for each pull request.
MIT. See LICENSE.