complexity-cuts
यह क्या करती है
'complexity-cuts' आपके code को तेज़ और ज़्यादा efficient बनाने में मदद करता है। यह ऐसे हिस्से ढूंढता है जो धीमे हैं या ज़्यादा memory लेते हैं, और एक-एक करके सुधार सुझाता है, ताकि सब कुछ पहले की तरह काम करता रहे।
कब इस्तेमाल करें
- ✓आपका code बड़े data के साथ धीमा चलता है।
- ✓आपका program crash होता है या ज़्यादा memory इस्तेमाल करता है।
- ✓आपको मौजूदा code को optimize करना है।
Skill का लिंक
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/complexity-cuts/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मैं इस code को तेज़ कैसे बना सकता हूं? बड़ी lists को process करने में बहुत समय लग रहा है।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
यह आपके code का विश्लेषण करके bottlenecks (धीमे बिंदु) ढूंढता है और खास बदलाव सुझाता है। हर बदलाव की test से जांच होती है कि code टूटे नहीं। अगर कोई बदलाव fail हो जाए, तो वह अपने आप वापस हो जाता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
complexity-cuts — Lower Big-O on Existing Code
lemmaly prevents bad complexity before code is written. complexity-cuts fixes it after the fact: code already exists, it works, but its time or space complexity is worse than necessary.
Violating the letter of these rules is violating the spirit of the skill. Adapting "just a little" is how a faster-but-wrong rewrite ships.
When to Use This Skill
Use complexity-cuts when refactoring existing code that has poor Big-O:
- Nested loops,
O(n²)or worse scans, repeated work, redundant allocations, blown memory. - Stated symptoms: "this is slow on large inputs", "times out", "OOM", "too much memory", "reduce complexity", "optimize this algorithm".
- N+1 query patterns in ORMs (Prisma, Drizzle, SQLAlchemy, Django, ActiveRecord).
awaitinsideforover independent items causing serial latency.
For preventing bad complexity before code is written, use lemmaly. For math-level optimizations (Bloom, HLL, FFT, JL projection), escalate to mathguard.
The Iron Law
NO TRANSFORMATION WITHOUT EXISTING TESTS GREEN BEFORE AND AFTER
If the code has no tests, you write a characterization test first (golden input → current output). Then transform. Then verify the test still passes. If you skip this, the optimization can silently break callers — and faster-but-wrong is worse than slow-and-right.
Non-negotiable rules
State current and target Big-O before touching code. In one line:
- Current:
time = O(?),space = O(?) - Target:
time = O(?),space = O(?) - Dominant input dimension (n = what, how large in practice)
If you cannot state current Big-O, you do not yet understand the code. Read more.
- Current:
Identify the bottleneck, do not guess. Point to the exact line(s) responsible for the dominant term. Nested loop? Repeated linear scan? Recomputation? Allocation inside a hot loop? The fix lives there, not elsewhere.
One transformation at a time, with a verify-revert-stop loop. The loop is:
- Apply exactly one transformation from the playbook.
- Run the existing test suite (or the characterization test you wrote per the Iron Law).
- If any test breaks: revert immediately. Do not patch the test. Do not patch around the failure. Revert.
- Count reverts on this piece of code. If 3 reverts in a row, STOP optimizing. The bottleneck is wrong, the transformation is wrong, or the code has invariants you have not modeled. Escalate to
invariant-guardand write the missing contract — do not try a fourth transformation. - Only after a transformation lands green: pick the next one.
Stacked changes hide regressions. Patched tests hide regressions louder.
Preserve semantics exactly. Lower complexity must not change outputs, ordering guarantees, stability, or error behavior. If the optimization requires a semantic change (e.g. unordered output), call it out explicitly and confirm it is acceptable.
No invented numbers. Never write "10x faster" or "saves 200MB" without measuring. Write
<measured: TBD>and move on, or actually measure with a representative input.Always report the measured speedup ratio after a transformation lands. Once the new code is green, run a representative benchmark (same input, same machine, warm cache) and report
before → afterplus the ratio asN× faster(orN× less memory). One line, attached to the diff:p50: 186 ms → 1.1 ms (169× faster, n=20,000, 200 samples)If you cannot measure (e.g. the win is purely asymptotic on inputs you don't have), say so explicitly:
asymptotic only, no measurement — O(n²) → O(n). Never silently skip this step.
The transformation playbook
The vast majority of real-world Big-O wins come from a small set of moves. Try them in this order:
Time-complexity reductions
| Smell | Fix | Typical win |
|---|---|---|
for x in A: if x in B where B is list/array |
Convert B to Set/Map once |
O(n·m) → O(n+m) |
| Nested loop computing pairs/joins | Hash-join on the key; index by lookup field | O(n·m) → O(n+m) |
Repeated .find / .indexOf / .includes inside a loop |
Precompute index Map<key, item> outside loop |
O(n^2) → O(n) |
| Repeated recomputation of same value | Memoize / cache by input key | O(n·f(n)) → O(n + f(n)) |
| Sort inside a loop | Sort once outside | O(n^2 log n) → O(n log n) |
…
अक्सर पूछे जाने वाले सवाल
'Big-O' क्या है?
यह एक तरीका है यह बताने का कि data बढ़ने पर code कितनी तेज़ी से धीमा होता है। जैसे 'O(n²)' का मतलब है कि अगर data दोगुना हो, तो समय चार गुना हो सकता है।
अगर code में tests नहीं हैं तो?
कोई भी बदलाव करने से पहले आपको एक सरल test बनाना होगा जो दिखाए कि code अभी कैसे काम करता है। उसके बाद ही optimization करें और जांचें कि test अब भी pass होता है या नहीं।
क्या मैं एक साथ कई बदलाव कर सकता हूं?
नहीं। 'complexity-cuts' के लिए ज़रूरी है कि बदलाव एक-एक करके किए जाएं। इससे पता रहता है कि कौन सा बदलाव सुधार लाया, और code बिना कारण पता चले टूटता नहीं।
जानकारी
लेखक का मूल विवरण
Lower Big-O on existing code via a one-transformation-at-a-time playbook with verify-revert-stop. For new code use lemmaly; for math-level wins escalate to mathguard.
लोकप्रियता
- GitHub स्टार
- 48k
- रैंकिंग में स्थान
- #4223
- लाइसेंस
- MIT
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
00-andruia-consultant
48kआपके एजेंट को AI प्रोजेक्ट शुरू करने या उन्हें बेहतर बनाने में मदद करता है। यह code का विश्लेषण करता है, tools सुझाता है और स्पेनिश भाषा में action plan बनाता है।
007
48kआपका एजेंट security audit और threat modeling करता है। यह प्रोजेक्ट को हमलों और कमजोरियों से बचाने में काम आता है।
10-andruia-skill-smith
48kआपके एजेंट को AI tools बनाने या उन्हें बेहतर करने में मदद करता है। यह तय करता है कि tools कैसे काम करेंगे, documentation लिखता है और structure की जांच करता है।
20-andruia-niche-intelligence
48kआपका एजेंट किसी खास industry का summary बनाता है। भरोसेमंद स्रोतों की मदद से यह प्रोजेक्ट का संदर्भ, नियम, इस्तेमाल के तरीके और जोखिम समझने में मदद करता है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।