The Problem A writer or editor wants to know whether a document was produced by an AI, without sending the text to an external service. The tool must analyse the first 262 kB of prose, score it against a set of documented patterns, and flag suspect spans locally.

What This Does sloptrim scores prose files on a 0‑100 scale based on 71 patterns (62 with automated detectors). The core logic lives in scripts/detect.py; it loads the pattern definitions from references/patterns.md, extracts prose from a file or archive, and returns a JSON payload containing the score and matched spans. The repository also ships a Claude Code skill under .claude‑plugin/. The skill uses JavaScript hooks (hooks/sloptrim‑*) to intercept file‑save events, invoke the Python detector, and surface the results in the editor UI. The commands (/sloptrim doctor, /sloptrim show) are defined in install/sloptrim‑command.md and wired to the hook library.

How It Is Wired Entry points

  • CLI – python scripts/detect.py <file> (used by the hook and by users).
  • Plugin – hooks/sloptrim‑guard.js registers a file:save listener. When a file is saved, it spawns detect.py via a child process, passing the file path. The child process returns JSON; the guard then forwards the score to hooks/sloptrim‑statusline.ps1 (PowerShell) or hooks/sloptrim‑stats.js (web UI).

Internal call graph

  1. hooks/sloptrim‑guard.js → child_process.execFile('python', ['scripts/detect.py', file])
  2. scripts/detect.py → load_patterns('references/patterns.md')
  3. scripts/detect.py → extract_prose(file) → score_text(prose) → json.dumps(result)
  4. JSON is streamed back to the guard; the guard calls hooks/sloptrim‑statusline.ps1 to render the score in the editor status line.

File responsibilities

  • scripts/detect.py – detection engine, CLI entry point.
  • references/patterns.md – pattern definitions.
  • hooks/sloptrim‑lib.js – shared helper functions for hooks.
  • hooks/sloptrim‑guard.js – orchestrates detection on file events.
  • hooks/sloptrim‑statusline.ps1 – renders the score in PowerShell.
  • hooks/sloptrim‑stats.js – aggregates statistics shown in the web UI.
  • .claude‑plugin/*.json – marketplace metadata.

The graph is linear; no cycles exist. Changing the detection logic only requires edits to scripts/detect.py and the pattern file; the hooks remain untouched.

How To Use It

# clone the repository
git clone https://github.com/moses-y/sloptrim ~/.claude/skills/sloptrim

# install the skill command
mkdir -p ~/.claude/commands
cp ~/.claude/skills/sloptrim/install/sloptrim-command.md ~/.claude/commands/sloptrim.md

# restart your Claude Code instance
# then run
/sloptrim doctor   # verifies local install

CLI

python scripts/detect.py path/to/document.md

Outputs a JSON object with score, matches, and duration.

Real‑World Use In a document‑editing workflow, a developer can add the skill to Claude Code or any editor that supports the hook API. Every time a draft is saved, the plugin automatically scores it and shows the result in the status line. If the score exceeds a threshold, the editor can prompt the author to revise the flagged spans.

Code Health & Issues

  • Tests – 269 unit tests (tests/).
  • Dependencies – None; pure stdlib.
  • Network – No outbound calls; all processing is local.
  • License – Apache‑2.0 (LICENSE.txt).
  • CI – GitHub Actions (.github/workflows/test.yml) runs all tests.
  • Missing items – No Dockerfile or continuous‑integration beyond GitHub Actions; no CI for Windows PowerShell beyond the provided script.

The Bottom Line sloptrim offers a lightweight, fully local AI‑prose detector that integrates cleanly into Claude Code or any editor supporting the provided hooks. Its zero‑dependency design and clear separation between detection (Python) and plugin plumbing (JavaScript) make it easy to audit and extend. It is ideal for teams that need to enforce AI‑writing guidelines without exposing content to external services.