feat(ci): add non-blocking "slop cop" PR analyzer - #5552
Merged
Conversation
Adds a new "Slop Cop" workflow that runs on every PR and posts a single sticky comment flagging content that likely should not be in the PR - most importantly a footprint mismatch (narrow title, mass deletions), the signature of a bad rebase/merge that silently wiped commits. - New workflow slopCop.wac.ts (+ generated slopCop.yml). - Analysis script slopCop.js: reads PR intent + footprint + capped diff, calls the Anthropic Messages API (claude-sonnet-5) via Node 24 global fetch (zero new deps), returns JSON findings, renders a Markdown report. - Sticky comment via gh (marker-based), updated in place per push. Phase 1 is advisory only: the job always succeeds and never blocks a merge. Fork PRs are skipped (no secrets on pull_request); a missing key or API error is non-fatal and leaves the check green. Reads ANTHROPIC_API_KEY from repo secrets. Also regenerates assignMilestone.yml, which had drifted from its wac source (missing the createJob permissions baseline). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NFTbnZYKArMQiiCyUKuP6G
Extends the slop cop analysis with a second dimension: when CODE_STYLE_DIR
is set (wired to ai-context/code-style), it checks the diff's added/changed
lines against every code-style rule and reports violations in a separate
"Code-style rule checks" section, citing the rule file.
- Findings now carry a category ("integrity" | "style"); the report splits
them into two sections.
- Style check is only over added lines, capped, conservative, and still
fully non-blocking. Disabled cleanly when no rules dir is provided.
- Bumped max_tokens to 4000 to fit the extra findings.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFTbnZYKArMQiiCyUKuP6G
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A new Slop Cop workflow that runs on every PR, asks Claude to sanity-check the diff, and posts a single sticky comment with two kinds of feedback:
Motivating case for (1): #5496 was titled
feat(admin): breadcrumbsbut deleted 3508 lines across 245 files — the signature of a bad rebase/merge that wiped commits. A heads-up comment before merge would have caught it.How
pull_request(opened/reopened/synchronize) → one job:gh pr view --jsongathers intent (title/body/commits) + footprint (per-file+/-);gh pr diffgrabs a capped raw patch.slopCop.js(Node 24 globalfetch, zero new deps) calls the Anthropic Messages API (claude-sonnet-5) and returns JSON findings, each taggedcategory: integrity | style.Integrity checks (job A)
Footprint-vs-intent mismatch (highest priority), leaked secrets, committed artifacts (node_modules/build output), leftover debug code / focused tests, unresolved conflict markers, commit-history smells.
Code-style checks (job B)
Every rule under
ai-context/code-style/(one-import-per-line, no-console-in-backend, es-modules, one-class-per-file, …) is loaded from the PR's checkout and fed to the model. It flags violations only on lines the diff adds or changes — never pre-existing or removed code — respects each rule's scope (e.g.no-console-in-backendapplies only toapi-*), cites the offending rule file, and is capped to the ~15 most important. Wired viaCODE_STYLE_DIR; point it elsewhere without touching the script. Because rules come from the PR branch, a PR that adds/edits a rule is checked against its own new rules.Safety (phase 1 = advisory)
!head.repo.fork) — no secrets onpull_request, so nopull_request_targetpwn-request risk.Setup
Reads
ANTHROPIC_API_KEYfrom repo secrets (already configured).Notes
slopCop.wac.ts;slopCop.ymlis generated viaghawac build.assignMilestone.yml, which had drifted from its wac source (missing thecreateJobpermissions baseline).Future phases
🤖 Generated with Claude Code
https://claude.ai/code/session_01NFTbnZYKArMQiiCyUKuP6G