From git-workflow-guards
Read-only repo-health scan. Use when running a manual repo-health pass to surface duplicated code. Finds blocks of more than 30 lines duplicated across the repo with at least 80% similarity, scores each candidate, and files one tracker issue per real finding. Never edits source. Tracker-agnostic.
How this skill is triggered — by the user, by Claude, or both
Slash command
/git-workflow-guards:gc-duplicated-blocksThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are running as a **garbage-collection agent** for this repo. Your single job in this session is to find duplicated code blocks and file one tracker issue per finding describing them. You are not fixing anything — you are surfacing findings so a human can later schedule the work.
You are running as a garbage-collection agent for this repo. Your single job in this session is to find duplicated code blocks and file one tracker issue per finding describing them. You are not fixing anything — you are surfacing findings so a human can later schedule the work.
Run on a manual cadence (cron-eligible, weekly is sensible) against a clean checkout. Not human-invoked at action boundaries.
Find blocks of more than 30 lines that are duplicated (verbatim or near-verbatim) across the repo, score each candidate, and open one tracker issue per real finding.
A contiguous run of source lines (more than 30 non-blank, non-comment lines) that appears in two or more places with at least 80% line similarity. Use your judgement; this is not an AST tool. Whitespace-only differences count as identical. Renamed locals count as identical.
All source files in the repo. Walk the working tree, focusing on hand-written code; skip the directories listed under guardrail 1.
Do not open issues for duplications that fall into these buckets — they're either expected, generated, or not worth fixing:
node_modules/, .git/, dist/, build/, .next/, target/, vendor/, **/*.d.ts, schema-migration directories (*/migrations/, */drizzle/, etc.), or files containing // AUTO-GENERATED / // DO NOT EDIT / # AUTO-GENERATED headers.migrations/ directory. Each migration is intentionally a frozen snapshot — duplication is the design.**/__fixtures__/, **/fixtures/, **/*.fixture.*, or large expect(...) arrays in test files. Test data is supposed to be repetitive and verbose.export default function Page() etc.), standard React imports, standard Express middleware wiring, Spring Boot @RestController shells, Rails ApplicationController inheritance. These are framework-imposed shapes, not duplication.import { ... } or export { ... } from '...' lines is not duplication.When in doubt: don't open the issue. False positives waste human attention and erode trust in the GC agent. It is better to surface 3 high-quality findings than 15 noisy ones.
For each candidate cluster, compute:
extract-helper — pull into a shared function/module.parameterize — same shape, differs in a few values; consolidate with parameters.accept — duplication is intentional or removing it would hurt readability. (If you reach accept, you should usually just not open the issue.)Only file an issue when size ≥ 30 lines AND similarity ≥ 80 AND the suggested action is extract-helper or parameterize.
This skill is tracker-agnostic. The repo's project tracker may be GitHub Issues (gh issue create), Linear, Jira, beads (bd create), or a plain markdown report. Detect what the project uses in this priority order and use the first match:
.beads/ directory at the repo root → bd create.gh auth status succeeds and gh repo view --json hasIssuesEnabled -q .hasIssuesEnabled returns true → gh issue create.LINEAR_API_KEY env var set → Linear API.JIRA_API_TOKEN env var set → Jira API.Before filing a new issue, check for an existing GC issue covering the same duplication (search the tracker for the file paths involved — bd list --label gc / gh issue list --label gc --search "<file_a>"). If a match exists, skip — don't file duplicates on every weekly run.
The payload shape is the same regardless of tracker:
Duplicated block: <one-line summary> (one short imperative sentence; this is the issue's headline)Body template:
**Locations:**
- `path/to/file_a.ts:123–187`
- `path/to/file_b.ts:42–106`
**Size:** 65 lines | **Similarity:** ~92% | **Distance:** cross-module (analysis ↔ books)
**What's duplicated:** <2–3 sentences describing the shared logic — what it does, not what it looks like>
**Suggested action:** extract-helper
**Sketch:**
<3–6 lines describing the proposed helper signature and where it would live, e.g. "Extract to `src/lib/<name>.ts` with signature `parseFoo(input: Bar): Baz`. Both call sites become a one-line call.">
**Why this matters:** <1 sentence — the cost of leaving it. e.g., "Future changes to the parsing rules need to be made in two places.">
_Filed by gc-duplicated-blocks skill._
If the tracker supports labels, add gc and duplicated-code. If not, embed them as a **Labels:** gc, duplicated-code line in the body.
If no tracker is wired up, write the findings to gc-findings/duplicated-blocks-<YYYY-MM-DD>.md at the repo root and tell the user where the report landed.
size × similarity × cross-distance and drop the rest. File one issue per surviving finding via the project's tracker. Print the issue IDs (or report path) as you go.After filing, print:
=== gc-duplicated-blocks summary ===
Filed N issues:
<id-or-path> <title>
...
Skipped M candidates (reasons):
<one-line reason per skip, grouped — e.g., "3× test fixture duplication", "2× shadcn boilerplate">
The skip list is itself useful signal — if every run skips the same category, that's a hint to update the guardrails in this skill.
grep, ls, cat, find, git log, git diff, git show) plus the tracker's read+create commands needed for filing and dedupe. For GitHub Issues that means gh repo view, gh issue list, gh issue view, gh issue create, gh label list, gh label create --force. For beads, bd list, bd show, bd create, bd label add. No git commit, no git push, no curl, no rm, no writes to the filesystem outside the tracker call (or the fallback markdown report).Provides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Fetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.
npx claudepluginhub zainrizvi/git-workflow-guards --plugin git-workflow-guards