simplify-code
यह क्या करती है
यह स्किल आपके AI को कोड में अनावश्यक जटिलता ढूँढकर हटाने में मदद करती है। यह उन डेवलपर्स के लिए है जिनका कोड पढ़ने और संभालने में कठिन हो गया है।
कब इस्तेमाल करें
- ✓जब कोडबेस में ऐसे रैपर क्लास या एब्स्ट्रैक्शन हों जो बहुत कम काम करते हैं।
- ✓जब आपको बेकार कोड, न इस्तेमाल होने वाले इम्पोर्ट या गहराई से नेस्ट किया लॉजिक मिले जिसे समझना कठिन हो।
- ✓जब आप चाहते हों कि कोड पढ़ने में आसान हो, पर व्यवहार वही रहे।
Skill का लिंक
https://github.com/vudovn/ag-kit/blob/main/.agents/skills/simplify-code/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“इस मॉड्यूल को सरल कीजिए। जो इस्तेमाल नहीं हो रहा, वह हटाइए और गहरे नेस्टेड लॉजिक को समतल कीजिए, पर व्यवहार वही रखिए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
स्किल कोड को आम जटिलता समस्याओं की सूची से जाँचती है। फिर जो ज़रूरी नहीं है उसे हटाती या समतल करती है, और व्यवहार वही रखती है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Simplify Code — Reduce Unnecessary Complexity
The best code is the code you don't have to write. The second best is the code anyone can read.
Core Principle
Complexity is a cost. Every abstraction, every indirection, every clever pattern
adds cognitive load. Simplify ruthlessly unless complexity serves a clear purpose.
Simplification Checklist
1. Unnecessary Abstractions
| Smell | Simplification |
|---|---|
| Wrapper class that just delegates | Remove wrapper, use the inner class directly |
| Factory that creates only one type | Replace with direct constructor |
| Strategy pattern with one strategy | Replace with simple function |
| Interface with one implementation | Remove interface, use the class |
| Abstract class with one child | Merge into the child class |
| Config object for 2 values | Use function parameters |
2. Dead Code
| Smell | Action |
|---|---|
| Unused imports | Remove |
| Unreachable branches | Remove (check tests first) |
| Commented-out code | Remove (it's in git history) |
| Unused variables/functions | Remove |
| TODO comments older than 6 months | Remove or create issue |
| Feature flags for launched features | Remove flag, keep the code |
3. Deep Nesting
// ❌ Before: 4 levels deep
function process(data) {
if (data) {
if (data.items) {
for (const item of data.items) {
if (item.active) {
doSomething(item)
}
}
}
}
}
// ✅ After: Early returns + filter
function process(data) {
if (!data?.items) return
data.items
.filter(item => item.active)
.forEach(doSomething)
}
4. Over-Parameterized Functions
// ❌ Before: 8 parameters
function createUser(name, email, age, role, dept, active, verified, avatar) { }
// ✅ After: Object parameter
function createUser(opts: CreateUserOpts) { }
5. Premature Optimization
| Smell | Simplification |
|---|---|
| Custom cache for <100 items | Remove cache, measure first |
| Memoization on cheap functions | Remove memo |
| Lazy loading for small modules | Use direct import |
| Complex state machine for 3 states | Use simple if/else or switch |
Simplification Protocol
Step 1: Identify Complexity
- Count nesting levels (target: ≤3)
- Count function parameters (target: ≤4)
- Count lines per function (target: ≤30)
- Count abstractions per feature (target: ≤2)
- Check for dead code (target: 0)
Step 2: Verify Understanding
Before simplifying, ensure you understand:
- What the code does (not what it looks like it does)
- Why it was written this way (maybe there's a reason)
- What tests cover it (simplification must not break tests)
Step 3: Simplify Incrementally
1. Remove dead code first (safest)
2. Flatten nesting with early returns
3. Inline trivial abstractions
4. Merge related functions
5. Simplify data structures
Step 4: Verify Behavior Preserved
npm run test # All existing tests still pass
npm run build # Still compiles
When NOT to Simplify
| Situation | Why Keep Complexity |
|---|---|
| Performance-critical hot path | Optimization may look complex but is necessary |
| Required by framework/library | External constraints |
| Explicitly requested pattern | User chose this architecture |
| Will need extension soon | Abstraction prepares for known growth |
Ask first: "This pattern seems over-engineered. Should I simplify it, or is there a reason for the abstraction?"
अक्सर पूछे जाने वाले सवाल
क्या सरल करने से मेरे कोड का काम बदलेगा?
स्किल व्यवहार बनाए रखने के लिए बनी है, और शाखाएँ हटाने से पहले टेस्ट जाँचती है।
बेकार कोड किसे माना जाता है?
न इस्तेमाल होने वाले इम्पोर्ट, वेरिएबल और फ़ंक्शन, अपहुँचने वाली शाखाएँ और पुराना कमेंट किया गया कोड।
क्या यह फ़ीचर फ़्लैग हटाती है?
यह उन फ़ीचर के फ़्लैग हटाने का सुझाव देती है जो पहले ही लॉन्च हो चुके हैं, कोड खुद रखते हुए।
जानकारी
लेखक का मूल विवरण
Reduce complexity of over-engineered code. Identify unnecessary abstractions, remove dead code, flatten deep nesting, and simplify logic while preserving behavior.
repo: vudovn/ag-kit
लोकप्रियता
- GitHub स्टार
- 8.2k
- रैंकिंग में स्थान
- #12539
- लाइसेंस
- MIT
- अपडेट की गई
- 18/10/2026
कमेंट
- …
इस repository की और skills
batch-operations
8.2kयह आपके एजेंट को एक ही बदलाव कई फ़ाइलों में एक साथ करने में मदद करती है, जैसे किसी फ़ंक्शन का नाम बदलना या पुराना इम्पोर्ट हर जगह बदलना।
brainstorming
8.2kयह आपके एजेंट को कुछ भी नया या जटिल बनाने से पहले स्पष्ट सवाल पूछना सिखाती है, ताकि वह पहले आपका लक्ष्य समझे।
code-review-checklist
8.2kयह आपके एजेंट को सही होने, सुरक्षा, प्रदर्शन, परीक्षण और डॉक्यूमेंटेशन के लिए कोड जाँचने की चेकलिस्ट देती है, AI से जुड़े जोखिमों सहित।
code-review-graph
8.2kयह आपके एजेंट को संरचना के मानचित्र से बड़े प्रोजेक्ट में कोड समीक्षा करने में मदद करती है, ताकि वह केवल बदलाव से प्रभावित फ़ाइलें पढ़े।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।