Skip to content
Sym-jayPublic

About

A pre-commit check that has read your project's history. Sora the slime warns when a change removes a fix, re-adds a fixed bug, or forgets a file that always changes too.

Topics

Resources

Contributing

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

Blot

CI PyPI

Sora, the Blot slime, sliding back and forth

A pre-commit check that has read your project's history.

Meet Sora, the slime who remembers every fix.

Don't take down a fence until you know why it was put up.

Blot warns you before you commit when your change:

  • removes a fix: deletes or edits code that was added to fix a bug
  • re-adds a bug: brings back a line that a bug fix deliberately removed
  • forgets a related file: changes A but not B, when the two almost always change together

It runs locally, needs no account or AI, and stays quiet unless the history gives it a real reason to speak.

Blot catching a real Flask regression: simplifying self_ref = weakref.ref(self) triggers a removed-fix warning that traces past a 2023 refactor to the 2020 reference-cycle fix

A real run on Flask. Plain git blame points to a 2023 commit that only moved this line; Blot traces past it to the 2020 fix that explains it. (Regenerate with python assets/demo/make_demo.py.)

Status: alpha. The checks, why, map, the agent guard and the MCP server all work and are tested live; a check takes about 500 ms on Flask. Measured on the last 500 commits of Flask, requests, Express, Django and React, it warns on 0.6–11% of commits, and 70 of its 126 warnings (56%, each labelled by hand) were worth a reviewer's time. Numbers and method: bench/RESULTS.md.

What Blot catches, and what it doesn't

Blot catches one kind of regression well: a change that undoes or breaks an earlier bug fix. Replayed on 71 real regressions from the same five repos (commits that a later fix or revert named as the culprit), it warned on the right code before 11 of them were committed. Most regressions are a different kind: a bug in brand-new code, or in code that never came from a fix. Blot can't see those, so it caught 11 of the 25 regressions of its kind (44%), and 15% of all of them.

So treat Blot as a reviewer who remembers your project's bug history, not as a bug finder. It stays quiet about most changes, and when it speaks, it tells you which earlier fix to check. Details: recall on real regressions.

Meet Sora

Sora cycling through expressions

Sora is Blot's slime. You'll see a different face depending on what Blot finds:

Face When
Idle Checking your commit
Happy Nothing to worry about
Alert Found a fence: this line fixed a bug
Worried Risky change, take a look
Sleepy Indexing history
Sad A fix is being removed

Sora comes in four warm palettes:

Orange Sora Sage Sora Blue Sora Mustard Sora

Quickstart

pip install blot-git  # the PyPI name is blot-git; the command is just `blot`
cd your-repo
blot index            # optional: the first check builds .git/blot.db itself and keeps it current
blot install-hook     # adds Blot to .git/hooks/pre-commit without touching existing hooks

For the latest unreleased code, use pip install git+https://github.com/Sym-jay/Blot instead.

Remove it any time with blot install-hook --uninstall. Settings go in [tool.blot] in pyproject.toml or a .blot.toml file (see src/blot/config.py).

Or with the pre-commit framework, see .pre-commit-hooks.yaml.

Ask why a line exists

$ blot why src/flask/app.py:355
src/flask/app.py:355
  | self_ref = weakref.ref(self)
  explained by  8efea0cc  2020-10-03  Break reference cycle created by default in Flask instances.  [bug fix]
  traced past   0ec7f713  2023-06-11  Split the App and Blueprint into Sansio and IO parts  [refactor]

blot why FILE:LINE (or FILE:START-END) finds the commit that explains a line, skipping commits that only moved it. Plain git blame stops at the refactor.

Map a file's load-bearing lines

$ blot map src/flask/app.py
src/flask/app.py: 3 load-bearing lines in 2 ranges, from 2 fixes

355        | self_ref = weakref.ref(self)
             8efea0c "Break reference cycle created by default in Flask instances." (2020-10-03)
             traced past refactor 0ec7f71 "Split the App and Blueprint into Sansio and IO parts"

1061-1062  | rv = self.response_class()
           | rv.allow.update(methods)
             dbf55de "Fixed an issue where the default `OPTIONS` response was not exposing all valid methods in the `Allow` header." (2010-07-28, fixes #97)
             traced past refactor 0ec7f71 "Split the App and Blueprint into Sansio and IO parts"

blot map FILE runs why over a whole file and keeps the lines whose explaining commit is a bug fix: the lines blot check would warn about if you changed them. Consecutive lines from one fix are grouped. --full prints the whole file with the fix commit in the gutter, --format json gives the ranges and commits as JSON, --rev maps an older version, and --min-severity 1 also counts routine fixes. On Flask's 1,625-line app.py it takes about 1.5 s.

Give agents the history before they edit (MCP)

blot mcp is a Model Context Protocol server on stdio, so a coding agent can ask about a file before it plans a change, instead of hearing about it from blot guard at the last moment. It has two read-only tools:

Tool Same as Arguments
load_bearing_lines blot map FILE path, optional rev, min_severity
explain_lines blot why FILE:START-END path, start, optional end, rev

Each returns one paragraph per commit: short sha, date, subject, linked issues, the lines it explains and any refactor traced past. The same data comes back as JSON in structuredContent.

blot install-mcp           # adds `blot` to .mcp.json at the repo root and builds the index
blot install-mcp --local   # or just for you, via `claude mcp add --scope local` (needs the claude CLI)

Claude Code asks each person once before it starts a server from .mcp.json. The entry names this machine's Python by absolute path, like install-agent-hook does, so prefer --local if your team commits .mcp.json. Other servers in the file are left alone; remove Blot's entry with blot install-mcp --uninstall (add --local if you installed it that way). To register it by hand:

claude mcp add --scope local --transport stdio blot -- python -m blot mcp

The server works on the repository it is started in (or blot --repo PATH mcp). It speaks MCP 2026-07-28 and the earlier initialize-handshake versions (2024-11-05 to 2025-11-25), uses only the standard library, writes nothing but protocol messages to stdout, and answers a bad path or an untracked file with a tool error rather than exiting.

Guard coding agents

Coding agents are the most likely to "clean up" a line they don't understand. blot guard is a Claude Code PreToolUse hook on Edit, Write and MultiEdit: it runs the removed-fix and readded-bug checks on the edit the agent is about to make, and hands any finding to the agent as context:

blot: 1 warning

  ! removed-fix  src/flask/app.py:355
    You're removing or changing a line that a bug fix added.
    Check that the bug it fixed can't come back.
    8efea0c "Break reference cycle created by default in Flask instances." (2020-10-03)
    traced past refactor 0ec7f71 "Split the App and Blueprint into Sansio and IO parts"
Run `blot why FILE:LINE` for the full history before you change it.
blot install-agent-hook           # adds the hook to .claude/settings.json and builds the index
blot install-agent-hook --local   # or .claude/settings.local.json, which isn't committed
blot install-agent-hook --ask     # also ask you to approve edits that touch a fix

The hook command names this machine's Python by absolute path (like install-hook), so prefer --local if your team commits .claude/settings.json. Remove it with blot install-agent-hook --uninstall (add --local if you installed it there); other hooks in the file are left alone.

By default the guard only warns: Claude Code adds the warning to the agent's context with the edit's result, and the normal permission flow is unchanged. With --ask, Claude Code stops before the edit and asks you, showing the warning. The guard prints nothing when it has nothing to say, stays quiet for files outside a git repo or not tracked at HEAD, and never blocks an edit because of its own errors. It doesn't build a first index (that can take a minute): install-agent-hook does, or run blot index. After that it refreshes the index incrementally. On Flask a guarded edit takes about 450 ms. forgot-related-file is left out: it had no useful warnings among the 45 labelled in replays.

Issue and PR titles (optional)

blot index --github

With the GitHub CLI logged in, Blot fetches the titles and labels of the issues and PRs your fix commits mention, so warnings read fixes #2935 "copy_current_request_context copies old session object" (a real Flask issue) instead of a bare number. A bug label makes a commit count as a load-bearing fix; a fix-looking commit whose issues are only labelled enhancement or documentation is demoted. Refreshes only fetch what's new. Repos with GitHub Issues turned off (they track bugs elsewhere) are skipped.

Use in CI

Run Blot on every pull request and see its findings as warnings on the changed lines:

# .github/workflows/blot.yml
name: Blot
on: pull_request
jobs:
  blot:
    runs-on: ubuntu-latest
    steps:
      - uses: Sym-jay/Blot@v0.7.2

The action checks out the pull request with its full history, installs Blot, runs blot index and blot check --range origin/<base>..HEAD --format json, and turns each finding into a warning annotation. It never fails the job because of findings. Inputs: blot-package (what to pip install; default blot-git, the latest PyPI release), python-version (default 3.13) and base-ref (default: the pull request's base branch).

Measure it on your repo

blot bench --replay 500

Re-checks your last 500 commits as if each were being committed, and lists every warning Blot would have shown. See bench/README.md.

Docs

License

MIT

Sora's body shape is based on Animated Pixel Slime by rvros (CC0), recolored and given new expressions. Regenerate the sprites with python assets/sora/build_sprites.py.

About

A pre-commit check that has read your project's history. Sora the slime warns when a change removes a fix, re-adds a fixed bug, or forgets a file that always changes too.

Topics

Resources

Contributing

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages