Skip to main content

find-duplication

Find code duplication in the codebase. Supports two modes - scoped to current branch changes or a full codebase sweep. Use when the user asks to find duplicated code, copy-paste, repeated patterns, or wants to deduplicate before a PR.

소스 정보

저장소
openshift/lightspeed-service
최근 소스 활동
2026년 3월 18일 15:56
감지된 SKILL.md 언어
영어
스타
70
포크
94

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
find-duplication
description
Find code duplication in the codebase. Supports two modes - scoped to current branch changes or a full codebase sweep. Use when the user asks to find duplicated code, copy-paste, repeated patterns, or wants to deduplicate before a PR.
disable-model-invocation
true
# Find Code Duplication Detect duplicated or near-duplicate code and suggest consolidation candidates. ## Rules - Report findings, do not refactor. Refactoring is a separate task. - Focus on production code (`ols/`). Skip test duplication unless explicitly asked. - Group findings by severity: exact duplicates first, then near-duplicates. - For each finding, state whether extraction is worth it or acceptable duplication. ## Step 1: Determine Scope Ask the user: - **Branch mode**: only files changed in the current branch vs main. - **Full mode**: scan the entire `ols/` directory. For branch mode: ```bash git diff --name-only origin/main -- 'ols/' | grep '\.py$' ``` For full mode, the target is `ols/`. ## Step 2: Run Pylint Duplicate Detection ```bash uv run pylint --disable=all --enable=duplicate-code --min-similarity-lines=6 <target files or directory> ``` Review output. Filter out false positives: - Import blocks (common imports are not duplication) - Pydantic model boilerplate (Field declarations) - Single-line patterns (logging, raises) ## Step 3: Semantic Duplication Search Pylint only catches textual similarity. Also look for: 1. **Similar function signatures** — functions with near-identical parameter lists doing similar work. 2. **Repeated error handling** — same try/except/log/return pattern across multiple files. 3. **Copy-pasted blocks** — search for distinctive string literals or variable names that appear in multiple files. ```bash rg "<distinctive pattern>" ols/ --type py -l ``` ## Step 4: Classify Findings For each duplicate found, classify: | Category | Action | |----------|--------| | **Extract** — identical logic in 3+ places | Recommend a shared helper | | **Parameterize** — same structure, different values | Recommend a common function with parameters | | **Acceptable** — similar but serving different domains | Note it, no action needed | | **Test-only** — repeated test setup/fixtures | Recommend shared fixture (only if user asked) | ## Step 5: Report For each finding: 1. Files and line ranges involved 2. What is duplicated (brief description) 3. Classification (extract / parameterize / acceptable) 4. Suggested location for shared code (if applicable) Summary: total findings, how many actionable, estimated lines saved.
GitHub에서 보기