मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग107k · #765

code-simplification

यह क्या करती है

यह टूल प्रोग्रामिंग कोड को पढ़ने और समझने में आसान बनाने में मदद करता है। यह कोड का काम बदले बिना उसकी स्पष्टता बढ़ाता है।

कब इस्तेमाल करें

  • ✓जब कोड काम तो करता है, पर पढ़ने में कठिन है।
  • ✓बहुत जटिल कोड की समीक्षा के दौरान।
  • ✓जब लॉजिक बहुत उलझा हुआ हो या नाम साफ़ न हों।

Skill का लिंक

https://github.com/addyosmani/agent-skills/blob/main/skills/code-simplification/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/addyosmani/agent-skills/blob/main/skills/code-simplification/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“इस कोड को सरल बनाओ ताकि इसे समझना आसान हो:”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

टूल कोड का विश्लेषण करता है और उसे सीधा बनाने के तरीके ढूँढता है, जैसे बेहतर नाम रखना या लॉजिक को व्यवस्थित करना। यह पक्का करता है कि कोड पहले जैसा ही काम करता रहे।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Code Simplification

Inspired by the Claude Code Simplifier plugin. Adapted here as a model-agnostic, process-driven skill for any AI coding agent.

Overview

Simplify code by reducing complexity while preserving exact behavior. The goal is not fewer lines — it's code that is easier to read, understand, modify, and debug. Every simplification must pass a simple test: "Would a new team member understand this faster than the original?"

When to Use

  • After a feature is working and tests pass, but the implementation feels heavier than it needs to be
  • During code review when readability or complexity issues are flagged
  • When you encounter deeply nested logic, long functions, or unclear names
  • When refactoring code written under time pressure
  • When consolidating related logic scattered across files
  • After merging changes that introduced duplication or inconsistency

When NOT to use:

  • Code is already clean and readable — don't simplify for the sake of it
  • You don't understand what the code does yet — comprehend before you simplify
  • The code is performance-critical and the "simpler" version would be measurably slower
  • You're about to rewrite the module entirely — simplifying throwaway code wastes effort

The Five Principles

1. Preserve Behavior Exactly

Don't change what the code does — only how it expresses it. All inputs, outputs, side effects, error behavior, and edge cases must remain identical. If you're not sure a simplification preserves behavior, don't make it.

ASK BEFORE EVERY CHANGE:
→ Does this produce the same output for every input?
→ Does this maintain the same error behavior?
→ Does this preserve the same side effects and ordering?
→ Do all existing tests still pass without modification?

2. Follow Project Conventions

Simplification means making code more consistent with the codebase, not imposing external preferences. Before simplifying:

1. Read CLAUDE.md / project conventions
2. Study how neighboring code handles similar patterns
3. Match the project's style for:
   - Import ordering and module system
   - Function declaration style
   - Naming conventions
   - Error handling patterns
   - Type annotation depth

Simplification that breaks project consistency is not simplification — it's churn.

3. Prefer Clarity Over Cleverness

Explicit code is better than compact code when the compact version requires a mental pause to parse.

// UNCLEAR: Dense ternary chain
const label = isNew ? 'New' : isUpdated ? 'Updated' : isArchived ? 'Archived' : 'Active';

// CLEAR: Readable mapping
function getStatusLabel(item: Item): string {
  if (item.isNew) return 'New';
  if (item.isUpdated) return 'Updated';
  if (item.isArchived) return 'Archived';
  return 'Active';
}
// UNCLEAR: Chained reduces with inline logic
const result = items.reduce((acc, item) => ({
  ...acc,
  [item.id]: { ...acc[item.id], count: (acc[item.id]?.count ?? 0) + 1 }
}), {});

// CLEAR: Named intermediate step
const countById = new Map<string, number>();
for (const item of items) {
  countById.set(item.id, (countById.get(item.id) ?? 0) + 1);
}

4. Maintain Balance

Simplification has a failure mode: over-simplification. Watch for these traps:

  • Inlining too aggressively — removing a helper that gave a concept a name makes the call site harder to read
  • Combining unrelated logic — two simple functions merged into one complex function is not simpler
  • Removing "unnecessary" abstraction — some abstractions exist for extensibility or testability, not complexity
  • Optimizing for line count — fewer lines is not the goal; easier comprehension is

5. Scope to What Changed

Default to simplifying recently modified code. Avoid drive-by refactors of unrelated code unless explicitly asked to broaden scope. Unscoped simplification creates noise in diffs and risks unintended regressions.

The Simplification Process

Step 1: Understand Before Touching (Chesterton's Fence)

Before changing or removing anything, understand why it exists. This is Chesterton's Fence: if you see a fence across a road and don't understand why it's there, don't tear it down. First understand the reason, then decide if the reason still applies.

BEFORE SIMPLIFYING, ANSWER:
- What is this code's responsibility?

…
अक्सर पूछे जाने वाले सवाल

क्या इससे कोड का काम बदलता है?

नहीं, लक्ष्य सिर्फ़ स्पष्टता बढ़ाना है। कोड वही काम करेगा जो वह पहले करता था।

क्या इसे इस्तेमाल करने के लिए प्रोग्रामिंग आनी चाहिए?

प्रोग्रामिंग की बुनियादी समझ होना मददगार है ताकि पता चले कोड क्या करता है, लेकिन टूल कोड को सरल बनाने के लिए बना है, इसलिए यह उसे आसान बनाता है।

क्या इससे कोड की लाइनें कम की जा सकती हैं?

इसका मुख्य ध्यान स्पष्टता और समझने में आसानी पर है, लाइनें घटाना नहीं। कभी-कभी थोड़ा लंबा कोड पढ़ने में आसान होता है।

जानकारी

लेखक का मूल विवरण

Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

repo: addyosmani/agent-skills

लोकप्रियता

GitHub स्टार
107k
रैंकिंग में स्थान
#765
लाइसेंस
MIT
अपडेट की गई
13/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

api-and-interface-design

107k

अच्छी तरह परिभाषित APIs और interfaces डिज़ाइन करने में मदद करता है। सॉफ्टवेयर के अलग-अलग हिस्से आपस में कैसे बात करेंगे, यह तय करते समय उपयोगी है।

कोडिंगAPI और सर्वर (backend)

browser-testing-with-devtools

107k

आपके एजेंट को असली browsers में सीधे code टेस्ट करने में मदद करता है। जिस माहौल में चीज़ इस्तेमाल होगी, वहाँ वह कैसे चलती है यह जाँचने और errors व performance की समस्याएँ ढूंढने के लिए उपयोगी है।

कोडिंगटेस्टिंग

ci-cd-and-automation

107k

आपके AI एजेंट को दोहराए जाने वाले काम अपने-आप करना, प्रोजेक्ट्स शिप करना और इंफ्रास्ट्रक्चर मैनेज करना सिखाता है।

प्रोडक्टिविटीऑटोमेशन

code-review-and-quality

107k

कई पहलुओं पर detailed code reviews करता है। नए changes merge करने से पहले quality सुनिश्चित करने और आगे की समस्याएँ रोकने के लिए उपयोगी है।

कोडिंगटेस्टिंग

मिलती-जुलती skills