tuanductran/hr-skills/.agents/skills/dry-refactoring/SKILL.md
dry-refactoring
Guided workflow to eliminate copy-paste duplication in packages/hr-skills-build and packages/skills-ref, detected by jscpd. Extract shared functions, constants, and types into their own files instead of growing an existing one.
- Source repository stars
- 43
- Declared platforms
- 0
- Static risk flags
- 0
- Last source update
- 2026-08-05
- Source checked
- 2026-08-05
Decision brief
What it does—and where it fits
Guided workflow to eliminate copy-paste duplication in packages/ TypeScript source. Use after jscpd has produced a clone list.
Not for
- Tasks that require unconfirmed production actions or broad system permissions.
- Environments where the pinned source and install steps cannot be inspected.
Compatibility matrix
Platform support, with evidence labels
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
Inspect first. Install second.
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/tuanductran/hr-skills --skill ".agents/skills/dry-refactoring"Inspect the Agent Skill "dry-refactoring" from https://github.com/tuanductran/hr-skills/blob/26fae0e8572f0e3e50d4b28fbe3abbff2e6a0814/.agents/skills/dry-refactoring/SKILL.md at commit 26fae0e8572f0e3e50d4b28fbe3abbff2e6a0814. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
What the source asks the agent to do
- 01
Workflow
1. Run jscpd, scoped to packages/ only (never skills/, see the jscpd skill for why). 2. Parse each clone line to identify the two duplicated locations (file + line range). 3. Read both code fragments and understand what they do — don't refactor blind. 4. Decide the refactor targ…
Run jscpd, scoped to packages/ only (never skills/, see the jscpd skill for why).Parse each clone line to identify the two duplicated locations (file + line range).Read both code fragments and understand what they do — don't refactor blind. - 02
Prerequisites
Run jscpd first — see jscpd for the exact command this repo uses:
Run jscpd first — see jscpd for the exact command this repo uses: - 03
Where extracted code goes in this repo
This repo already separates code by domain under packages/hr-skills-build/src/{shared,validation,cli,planner,runtime,registry,search,build,evaluation}/ and packages/skills-ref/src/. Follow that structure — don't dump extracted helpers into whichever file happens to be open:
Duplicated logic used by 2+ files in the same domain folder (e.g. two files under src/validation/) → new file in that same folder, e.g. src/validation/security-helpers.ts, imported by both.Duplicated logic used across domain folders (e.g. src/cli/ and src/evaluation/) → src/shared/, alongside the existing shared/constants.ts, shared/helpers.ts, shared/schema.ts, shared/types.ts.Duplicated logic across packages (hr-skills-build and skills-ref both define it) → do not create a third copy in either package. Prefer keeping a single canonical definition in the package it conceptually belongs to (sk… - 04
Naming collisions
Before extracting, grep -rn "export (const|function|type|interface) " packages for the name you're about to reuse. If a same-named export already exists elsewhere in the monorepo:
Prefer a more specific name over a generic one (e.g. parseSkillFrontmatter over parse) rather than renaming the existing export and risking unrelated churn.If both are genuinely the same concept split across two files, that's itself a duplication signal — consolidate into one export instead of two similarly-named ones.Before extracting, grep -rn "export (const|function|type|interface) " packages for the name you're about to reuse. If a same-named export already exists elsewhere in the monorepo: - 05
Refactoring strategies
Extract function — duplicate is a block of logic → shared function, called from both places.
Extract function — duplicate is a block of logic → shared function, called from both places.Extract module — duplicate spans multiple files in the same or related domains → shared file per the placement rules above, imported by all call sites.Extract constant — duplicate is repeated literal data or config → named constant in the domain's constants.ts.
Permission review
Static risk signals and limitations
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
Why each signal appears
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 87/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 43 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Provenance and original SKILL.md
- Repository
- tuanductran/hr-skills
- Skill path
- .agents/skills/dry-refactoring/SKILL.md
- Commit
- 26fae0e8572f0e3e50d4b28fbe3abbff2e6a0814
- License
- MIT
- Collected
- 2026-08-05
- Default branch
- main
View the original SKILL.md
dry-refactoring
Guided workflow to eliminate copy-paste duplication in packages/* TypeScript source. Use after jscpd has produced a clone list.
Prerequisites
Run jscpd first — see jscpd for the exact command this repo uses:
bunx jscpd@5 packages --reporters ai --format typescript
Workflow
- Run jscpd, scoped to
packages/only (neverskills/, see thejscpdskill for why). - Parse each clone line to identify the two duplicated locations (file + line range).
- Read both code fragments and understand what they do — don't refactor blind.
- Decide the refactor target using the placement rules below.
- Extract the shared logic; update all call sites, not just the two jscpd reported.
- Run
bun run typecheckandbun run test(repo-wide or--filterto the affected package — seeturbo). - Re-run jscpd to confirm the clone is gone.
- Repeat, highest-impact cluster first (most repeated pattern, not just the first line in the report).
Where extracted code goes in this repo
This repo already separates code by domain under packages/hr-skills-build/src/{shared,validation,cli,planner,runtime,registry,search,build,evaluation}/ and packages/skills-ref/src/. Follow that structure — don't dump extracted helpers into whichever file happens to be open:
- Duplicated logic used by 2+ files in the same domain folder (e.g. two files under
src/validation/) → new file in that same folder, e.g.src/validation/security-helpers.ts, imported by both. - Duplicated logic used across domain folders (e.g.
src/cli/*andsrc/evaluation/*) →src/shared/, alongside the existingshared/constants.ts,shared/helpers.ts,shared/schema.ts,shared/types.ts. - Duplicated logic across packages (
hr-skills-buildandskills-refboth define it) → do not create a third copy in either package. Prefer keeping a single canonical definition in the package it conceptually belongs to (skills-reffor skill-file parsing primitives,hr-skills-buildfor build/registry/CLI concerns) and importing it from the other, or promote it to a small shared internal package if both genuinely need to own it independently. Never resolve this by copy-pasting into a third location. - Constants → their own
constants.tsin the relevant folder; don't fold them into a file that already holds functions or types. - Types/interfaces → their own
types.ts(or*.types.tsiftypes.tsalready exists and would grow unrelated concerns) in the relevant folder — never appended to a functions file "for now."
Naming collisions
Before extracting, grep -rn "export (const|function|type|interface) <name>" packages for the name you're about to reuse. If a same-named export already exists elsewhere in the monorepo:
- Prefer a more specific name over a generic one (e.g.
parseSkillFrontmatteroverparse) rather than renaming the existing export and risking unrelated churn. - If both are genuinely the same concept split across two files, that's itself a duplication signal — consolidate into one export instead of two similarly-named ones.
Refactoring strategies
Extract function — duplicate is a block of logic → shared function, called from both places.
Extract module — duplicate spans multiple files in the same or related domains → shared file per the placement rules above, imported by all call sites.
Extract constant — duplicate is repeated literal data or config → named constant in the domain's constants.ts.
Extract type/interface — duplicate or near-duplicate shape appears in two files → single definition in the domain's types.ts, both files import it.
Avoid the template/base class strategy in this codebase unless a real inheritance hierarchy already exists — this repo favors small composable functions and Valibot schemas (see valibot) over class hierarchies.
Tips
- All call sites updated, not just the two jscpd reported —
grepfor other near-identical blocks jscpd's thresholds may have missed. - Tests still pass after refactoring (
bun run test), andbun run typecheckis clean. - The extracted abstraction has a clear, descriptive name — see naming collisions above.
- If the duplication is between
packages/hr-skills-buildandpackages/skills-ref, check whether a changeset is needed — seechangeset. - Format with Biome after refactoring (
bun run formator letlefthookcatch it on commit) — seebiome.
Alternatives
Compare before choosing
alirezarezvani/claude-skills
app-store-optimization
App Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklist
dotnet/skills
migrate-vstest-to-mtp
Migrates .NET test projects from VSTest to Microsoft.Testing.Platform (MTP). Use when user asks to "migrate to MTP", "switch from VSTest", "enable Microsoft.Testing.Platform", "use MTP runner", set OutputType=Exe only for test projects in Directory.Build.props, or mentions EnableMSTestRunner, EnableNUnitRunner, or UseMicrosoftTestingPlatformRunner. USE FOR: MTP behavioral differences vs VSTest (exit code 8, zero tests discovered, --ignore-exit-code, TESTINGPLATFORM_EXITCODE_IGNORE); centralizing
HKUDS/Vibe-Trading
strategy-generate
Create, modify, and optimize quantitative trading strategies, then backtest and evaluate them.
K-Dense-AI/scientific-agent-skills
dask
Distributed computing for larger-than-RAM pandas/NumPy workflows. Use when you need to scale existing pandas/NumPy code beyond memory or across clusters. Best for parallel file processing, distributed ML, integration with existing pandas code. For out-of-core analytics on single machine use vaex; for in-memory speed use polars.