codebase-refactoring
यह क्या करती है
यह पूरे प्रोजेक्ट के लिए एक निर्देशित सफ़ाई योजना है, जिसमें दोहराया कोड, इस्तेमाल न होने वाला कोड और बहुत जटिल फ़ाइलें शामिल हैं। यह उन डेवलपर्स के लिए है जो रखरखाव का काम कम करना चाहते हैं।
कब इस्तेमाल करें
- ✓जब टीम किसी प्रोजेक्ट की तकनीकी देनदारी साफ़ करना या घटाना चाहे।
- ✓जब डेवलपर जानना चाहे कि कोडबेस के किस हिस्से पर सबसे पहले काम करना है।
- ✓जब टीम सफ़ाई से पहले और बाद में प्रोजेक्ट का सेहत स्कोर मापना चाहे।
Skill का लिंक
https://github.com/kucherenko/jscpd/blob/master/skills/codebase-refactoring/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“इस प्रोजेक्ट की सफ़ाई कीजिए। सबसे बड़ी समस्याओं से शुरू कीजिए और बाद में सेहत स्कोर दिखाइए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
यह स्किल समस्याओं को क्रम देने के लिए कोड विश्लेषण टूल चलाती है, फिर AI को दोहराव, बेकार कोड और जटिल फ़ाइलें ठीक करने में मार्गदर्शन देती है और अंत में स्कोर दोबारा मापती है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
codebase-refactoring
A guided pass over a codebase's three biggest maintenance costs — duplicated code, dead code, and complexity — using jscpd to find each and a strategy to fix it. Use this skill when asked to "clean up", "improve", "refactor" or "pay down tech debt in" a codebase, rather than to fix one specific bug.
Start here: measure, then prioritize
npx jscpd --health --reporters ai <path>
health 74 B (duplication 75, dead-code 72, complexity 76; 93 code lines)
The health score is a weighted mix of three sub-scores, each a share of the
code lines — high is good, 100 is clean. The lowest of the three names where
the codebase actually hurts most; if it isn't the order below, do that
dimension first instead. n/a on a dimension (e.g. dead code n/a) means
jscpd could not measure it — dead-code detection needs JavaScript,
TypeScript or Python to be a real share of the code — skip that step rather
than treating it as clean.
For the full picture behind that score — largest duplicated formats, most
complex files, largest dead-code findings, all in one screen — run npx jscpd --dashboard instead. Its console output (the default) is the only
reporter with that per-file detail; --reporters ai on --dashboard prints
the same one-line summary shown above, not the breakdown, so don't reach for
it expecting more than the score. Use --reporters json on --dashboard if
you need the detail in a parseable form.
The three passes below are otherwise independent and safe to run in any order; duplication → dead code → complexity is the default because fixing duplication first means step 2 isn't wasting effort tracing call sites that a later extract-function pass will move anyway, and clearing dead code before step 3 means the files ranked for simplification are ones actually worth simplifying, not ones about to be deleted.
Step 1 — Duplicated code
npx jscpd --reporters ai --summary <path>
Find and read each clone, decide whether it is a real copy worth merging, and apply the matching refactoring strategy (extract function, parameterize, extract a shared module or constant, or a base class/template for structural duplication). Full guided workflow, triage rules for renamed/near-miss clones, and worked examples per clone kind:
→ dry-refactoring — run this now, then
come back here for steps 2 and 3. Its own --summary hotspot ranking is the
same one the health score's duplication dimension reads from, so a file it
flags as a duplication hotspot is the same file that dragged the score down.
Step 2 — Dead code
npx jscpd --dead-code --reporters ai <path>
basta dead code report — 18 findings across 30 files (22.1% of 272 lines)
Confidence is 0-100; anything below 90 has a listed reason it may be wrong. Verify a finding before deleting the code.
unused-file typescript/src/legacy-export.ts:1:1 confidence=95 typescript/src/legacy-export.ts is never imported and is not an entry point
unused-export typescript/src/invoice.ts:21:17 confidence=85 exported function `renderReceipt` is never imported
unused-symbol typescript/src/invoice.ts:29:10 confidence=90 function `describeTotal` is never used in typescript/src/invoice.ts
unused-import typescript/src/invoice.ts:2:10 confidence=100 `roundToCents` is imported but never used
This is a graph traversal from the project's entry points (package.json
main/bin/exports/scripts, pyproject.toml scripts, framework
conventions, or --entry <glob>), not a reference count — a helper whose
only caller is itself dead is reported too, so deleting one finding can make
another true that wasn't reported yet. Covers JavaScript, TypeScript, JSX,
TSX, Vue, Svelte, Astro and Python.
The four categories, and what to do with each
| Category | Meaning | Usual fix |
|---|---|---|
unused-file |
Never imported anywhere, not an entry point | Delete the file |
unused-export |
Exported, but no other file imports it | Delete it, or drop the export keyword if something in the same file still uses it |
unused-symbol |
A module-private declaration nothing in its own file references | Delete it |
unused-import |
Imported but never referenced in the file | Delete the import line |
Workflow
- Run with
--reporters ai(add--dead-code-categoriesto focus on one category,--include-testsif test-only usage shouldn't count as "used", `--i
अक्सर पूछे जाने वाले सवाल
यह तय कैसे करती है कि पहले क्या ठीक करें?
यह दोहराव, बेकार कोड और जटिलता पर आधारित सेहत स्कोर इस्तेमाल करती है और सबसे कम स्कोर से शुरू करती है।
क्या यह हर भाषा के लिए काम करती है?
बेकार कोड की पहचान के लिए JavaScript, TypeScript या Python का कोड का बड़ा हिस्सा होना ज़रूरी है।
क्या यह बग ठीक करती है?
यह किसी एक खास बग के बजाय रखरखाव की समस्याओं पर केंद्रित है।
जानकारी
लेखक का मूल विवरण
Three-part workflow to improve overall codebase health with jscpd — find and fix duplicated code, find and remove or refactor dead code, then find and simplify the largest/most complex files. Starts from --dashboard/--health to prioritize and ends by re-measuring the score.
repo: kucherenko/jscpd
लोकप्रियता
- GitHub स्टार
- 6.5k
- रैंकिंग में स्थान
- #14188
- लाइसेंस
- MIT
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
code-migration
6.5kआपके एजेंट को एक भाषा या फ़्रेमवर्क से दूसरे में कोड एक-एक फ़ंक्शन करके ले जाने में मदद करती है, पहले टेस्ट के साथ और मूल से तुलना करके प्रगति मापते हुए।
compare-codebases
6.5kआपके एजेंट को दो कोड फ़ोल्डरों की तुलना फ़ंक्शन-दर-फ़ंक्शन करने में मदद करती है, भाषाएँ अलग होने पर भी, यह देखने के लिए कि कौन से फ़ंक्शन मेल खाते हैं और कौन से गायब हैं।
dry-refactoring
6.5kआपके एजेंट को प्रोजेक्ट से कॉपी-पेस्ट किया हुआ कोड हटाने में मदद करती है, दोहराए गए ब्लॉक को साझा फ़ंक्शन में मिलाकर, सबसे बड़े दोहराव से शुरू करते हुए।
jscpd
6.5kआपके एजेंट को प्रोजेक्ट में सटीक, नाम बदले हुए या लगभग-नकल वाले कॉपी-पेस्ट कोड खोजने में मदद करती है, और यह मापने में कि कितना कोड दोहराया गया है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।