Skip to content

gretchenfitze/anti-slop / skills/anti-slop-rollout

anti-slop-rollout

Verified

Carry out the next step of an anti-AI-slop rollout plan (anti-slop/todo.md, with the reasoning in anti-slop/plan.md) as one pull request: add a single check in whatever stack the plan records (a strict TypeScript flag, sonarjs, unnecessary-effect, or test lint rules, layer boundaries, a custom lint rule from a past bug, an agent hook, Stryker mutation testing, knip and dead-file scripts, jscpd, react-doctor, a CI gate, a scheduled report, and the final trim of the agent rules file), fix or baseline what it finds, document its commands in the agent rules file, verify it, and open the PR. Use when the user says "next anti-slop step", "do step N of the plan", asks which rules in AGENTS.md or CLAUDE.md the linters now cover, or asks to set up knip, jscpd, react-doctor, Stryker, sonarjs, or boundaries the gradual way (warnings first, CI gate last) in a repo that has an anti-slop plan. Needs the plan from anti-slop-audit; without one, run the audit first.

assets/scripts/find-dead-code.mjs

View on GitHub
// From ts-workbench (https://github.com/mikhin/ts-workbench) by Yuri Mikhin (https://github.com/mikhin), MIT.
import { readFileSync } from "node:fs";
import path from "node:path";

import { knipEntries, resolveModule, ROOT, sourceFiles } from "./resolve-module.mjs";

const SIDE_EFFECT_IMPORT_RE = /import\s+["']([^"']+)["']/g;
const FROM_IMPORT_RE = /(?:import|export)\s[^;]*?from\s+["']([^"']+)["']/g;
const DYNAMIC_IMPORT_RE = /import\s*\(\s*["']([^"']+)["']\s*\)/g;
const IMPORT_PATTERNS = [SIDE_EFFECT_IMPORT_RE, FROM_IMPORT_RE, DYNAMIC_IMPORT_RE];

const KEEP_MARKER = "@dead-code-allow";

const importsOf = (file) => {
  const content = readFileSync(file, "utf8");
  const imports = new Set();

  const specifiers = IMPORT_PATTERNS.flatMap((pattern) =>
    [...content.matchAll(pattern)].map((match) => match[1]),
  );

  for (const specifier of specifiers) {
    const resolved = resolveModule(specifier, file);

    if (resolved) imports.add(resolved);
  }

  return imports;
};

const reachableFrom = (entries, known) => {
  const reachable = new Set();
  const queue = [...entries];

  while (queue.length > 0) {
    const file = queue.pop();

    if (reachable.has(file) || !known.has(file)) continue;

    reachable.add(file);

    for (const dep of importsOf(file)) queue.push(dep);
  }

  return reachable;
};

const keptOnPurpose = (file) => readFileSync(file, "utf8").slice(0, 200).includes(KEEP_MARKER);

const known = new Set(sourceFiles().map((file) => path.resolve(ROOT, file)));
const entries = knipEntries().filter((entry) => known.has(entry));

if (entries.length === 0) {
  console.log("No knip entry is a source file — nothing to walk.");

  process.exit(0);
}

const reachable = reachableFrom(entries, known);
const dead = [...known]
  .filter((file) => !reachable.has(file) && !keptOnPurpose(file))
  .map((file) => path.relative(ROOT, file))
  .toSorted();

if (dead.length === 0) {
  console.log("No dead files.");
} else {
  console.log(
    `Dead files (${dead.length}), unreachable from ${entries.map((e) => path.relative(ROOT, e)).join(", ")}:\n`,
  );

  for (const file of dead) console.log(file);

  process.exit(1);
}
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall