agentleFS
tuanductrantuanductran/hr-skills/.agents/skills/jscpd/SKILL.md

jscpd

Skill58 starsChanged 2 months agoMITView on GitHub

Copy-paste detector for the hr-skills TypeScript packages (packages/hr-skills-build, packages/hr-skills-ref). Run jscpd to detect duplicated code and measure duplication percentages before refactoring.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Before opening a PR that adds or edits code under packages/hr-skills-build/src/client/, packages/hr-skills-build/src/server/, …

    line 64
  2. Distinctive:

    After a large refactor, to confirm clones were actually eliminated (re-run, don't assume)

    line 69
  3. Very specific:

    Run jscpd against packages/, never against the full repo root — skills/hr-*/SKILL.md files are prompt content, not code, and will produce …

    line 74
  4. Very specific:

    Test files (packages/*/test/) legitimately duplicate describe/it/expect scaffolding — don't chase 100% duplication-free tests.

    line 75

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

jscpd

Copy-paste detector for source code. Use this skill to run jscpd against packages/* in this repo and understand its output before handing clones to dry-refactoring.

Not to be confused with packages/hr-skills-build/src/server/validation/detect-duplicates.ts, which detects duplicated HR skill content (skills/hr-*/SKILL.md) at publish time. jscpd here targets TypeScript source code in packages/* only — keep the two concerns separate and never merge their logic.

Quick start

This repo uses Bun, so prefer bunx over npx:

# Scope to the TypeScript packages only — skip skills/ (markdown) and generated output
bunx jscpd@5 packages \
  --format typescript \
  --mode strict \
  --min-lines 3 \
  --min-tokens 20 \
  --reporters console,json,markdown \
  --output duplicate-report \
  --ignore "**/node_modules/**,**/dist/**,**/*.md"

# Compact output optimized for agents
bunx jscpd@5 packages --reporters ai --format typescript

duplicate-report/ is a generated artifact — do not commit it; add it to .gitignore if it isn't already covered.

AI reporter output format

The ai reporter produces compact, token-efficient output:

Clones:
packages/hr-skills-build/src/server/validation/validate.ts:53-59 ~
security.ts:89-94
---
N clones · X% duplication
  • Same directory: shared path prefix factored out
  • Different paths: full path shown for both sides

Options used in this repo

OptionValue hereWhy
--format typescriptscoped to .tsskills/**/*.md content duplication is handled by detect-duplicates.ts, not jscpd
--mode strictexact-match clonesavoids false positives from formatting-only similarity (Biome already normalizes formatting)
--min-lines 3 / --min-tokens 20low thresholdsthis is a small, young codebase; catch clones early before they compound
--ignorenode_modules, dist, *.mdmatches .gitignore / build output conventions

Full option reference: bunx jscpd@5 --help, or the upstream configuration docs.

When to run

  • Before opening a PR that adds or edits code under packages/hr-skills-build/src/client/**, packages/hr-skills-build/src/server/**, packages/hr-skills-ref/src/client/**, or packages/hr-skills-ref/src/server/**
  • After a large refactor, to confirm clones were actually eliminated (re-run, don't assume)
  • Optionally wired into lefthook.yml as a pre-push (not pre-commit — it's slower than biome) step; see CI and hooks for the pattern this repo's lefthook.yml follows for other tools

Tips

  • Run jscpd against packages/, never against the full repo root — skills/hr-*/SKILL.md files are prompt content, not code, and will produce noisy, irrelevant clones.
  • Test files (packages/*/test/**) legitimately duplicate describe/it/expect scaffolding — don't chase 100% duplication-free tests. Prioritize src/** clones.
  • Hand the clone list to dry-refactoring rather than refactoring ad hoc; it enforces "extract, don't just rename."

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.