Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Language-specific super-code guidelines for python.
.claude/skills/lingxling-python/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 116% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 59% | 0% |
| case-07 | ✓→✗ | ▼ Worse | 389% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 146% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 123% | 0% |
python# ❌ Imperative accumulation result = [] for item in items: if item.active: result.append(item.name.upper()) # ✅ result = [item.name.upper() for item in items if item.active]
python# ❌ Dict built in a loop d = {} for k, v in pairs: d[k] = v # ✅ d = dict(pairs) # or d = {k: v for k, v in pairs}
python# ❌ Generator converted to list unnecessarily total = sum(list(x * 2 for x in nums)) # ✅ — generator expression works directly in sum() total = sum(x * 2 for x in nums)
Use generator expressions (not list comprehensions) when the result is consumed once and not stored.
python# ❌ Index access first = items[0] rest = items[1:] # ✅ first, *rest = items
python# ❌ Temporary variable for swap tmp = a a = b b = tmp # ✅ a, b = b, a
python# ❌ items() with separate indexing for i in range(len(items)): print(i, items[i]) # ✅ for i, item in enumerate(items): print(i, item)
python# ❌ zip with separate index for i in range(len(a)): process(a[i], b[i]) # ✅ for x, y in zip(a, b): process(x, y)
python# ❌ Manual max search max_val = items[0] for item in items[1:]: if item > max_val: max_val = item # ✅ max_val = max(items)
python# ❌ Manual grouping from collections import defaultdict groups = defaultdict(list) for item in items: groups[item.category].append(item) # ✅ — same thing, just be explicit about defaultdict; it IS the right tool # (this example is already correct — don't replace defaultdict with a loop)
python# ❌ Manual sentinel for dict default if key in d: val = d[key] else: val = default # ✅ val = d.get(key, default)
python# ❌ Rolling your own counter counts = {} for item in items: counts[item] = counts.get(item, 0) + 1 # ✅ from collections import Counter counts = Counter(items)
Use itertools (chain, islice, groupby, product) before writing nested loops for combinatorial or streaming logic.
python# ❌ Mutable default argument (bug, not just style) def append_to(item, lst=[]): lst.append(item) return lst # ✅ def append_to(item, lst=None): if lst is None: lst = [] lst.append(item) return lst
python# ❌ Positional args for everything when keyword clarity helps create_user("Alice", True, False, 30) # ✅ — use keyword args at call site for boolean/ambiguous params create_user("Alice", is_admin=True, is_active=False, age=30)
python# ❌ Long function doing multiple things def process_and_save(data): # 40 lines of transform # 20 lines of DB write ... # ✅ — split only if each part is reused OR independently testable def _transform(data): ... def _save(record): ... def process_and_save(data): _save(_transform(data))
python# ❌ Manual __init__ for data holders class Point: def __init__(self, x, y): self.x = x self.y = y # ✅ from dataclasses import dataclass @dataclass class Point: x: float y: float
python# ❌ Class just to hold a namespace of functions class MathUtils: @staticmethod def add(a, b): return a + b # ✅ — module-level functions; classes for state + behavior def add(a, b): return a + b
python# ❌ __repr__ written manually when dataclass gives it free # (see above — use @dataclass)
Use @dataclass(frozen=True) for immutable value objects. Use NamedTuple when you need tuple unpacking.
python# ❌ Bare except try: risky() except: pass # ✅ — catch the specific exception; don't swallow silently try: risky() except ValueError as e: logger.warning("Invalid value: %s", e)
python# ❌ LBYL (look before you leap) when EAFP is cleaner if os.path.exists(path): with open(path) as f: data = f.read() # ✅ (EAFP) try: with open(path) as f: data = f.read() except FileNotFoundError: data = None
python# ❌ Re-raising with raise e (loses traceback) except Exception as e: raise e # ✅ except Exception: raise # bare raise preserves original traceback
python# ❌ Overly verbose Union syntax (Python <3.10 style in new code) from typing import Optional, Union def f(x: Optional[int]) -> Union[str, None]: ... # ✅ (Python 3.10+) def f(x: int | None) -> str | None: ...
python# ❌ Any where a TypeVar or Protocol would be informative from typing import Any def first(lst: list[Any]) -> Any: ... # ✅ from typing import TypeVar T = TypeVar("T") def first(lst: list[T]) -> T: ...
Don't add type hints to every local variable — annotate function signatures and class fields; leave obvious locals inferred.
| Anti-pattern | Preferred | |---|---| | len(lst) == 0 | not lst | | if x == True: | if x: | | if x == None: | if x is None: | | range(len(lst)) for iteration | enumerate(lst) | | String concatenation in a loop | "".join(parts) | | import * | explicit imports | | Catching Exception to log and re-raise | bare raise or let it propagate | | print() for debug output | logging.debug() | | os.path.join (Python 3.4+) | pathlib.Path / "subpath" | | Manual __eq__ + __hash__ on value objects | @dataclass(eq=True, frozen=True) |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 16,087 | 9,494 | -41% | 1 | 1 | 0% | 2,492 | 3,756 | +51% | 0 | 0 | — |
case-02 | pass→pass | 8,240 | 7,486 | -9% | 1 | 1 | 0% | 1,221 | 3,002 | +146% | 0 | 0 | — |
case-03 | pass→pass | 7,489 | 5,082 | -32% | 1 | 1 | 0% | 1,177 | 2,626 | +123% | 0 | 0 | — |
case-04 | fail→pass | 8,727 | 5,219 | -40% | 1 | 1 | 0% | 1,234 | 2,661 | +116% | 0 | 0 | — |
case-14 | pass→pass | 7,113 | 4,014 | -44% | 1 | 1 | 0% | 828 | 2,509 | +203% | 0 | 0 | — |
case-05 | pass→pass | 4,311 | 5,174 | +20% | 1 | 1 | 0% | 812 | 2,779 | +242% | 0 | 0 | — |
case-06 | pass→pass | 5,278 | 7,124 | +35% | 1 | 1 | 0% | 947 | 2,926 | +209% | 0 | 0 | — |
case-07 | pass→fail | 2,827 | 2,413 | -15% | 1 | 1 | 0% | 471 | 2,305 | +389% | 0 | 0 | — |
case-08 | pass→pass | 5,556 | 2,302 | -59% | 1 | 1 | 0% | 684 | 2,212 | +223% | 0 | 0 | — |
case-09 | pass→pass | 4,102 | 2,311 | -44% | 1 | 1 | 0% | 492 | 2,239 | +355% | 0 | 0 | — |
case-10 | pass→pass | 4,222 | 4,016 | -5% | 1 | 1 | 0% | 721 | 2,523 | +250% | 0 | 0 | — |
case-11 | pass→pass | 3,677 | 4,063 | +10% | 1 | 1 | 0% | 604 | 2,421 | +301% | 0 | 0 | — |
case-12 | pass→pass | 11,409 | 4,315 | -62% | 1 | 1 | 0% | 1,087 | 2,713 | +150% | 0 | 0 | — |
case-13 | pass→pass | 5,325 | 4,445 | -17% | 1 | 1 | 0% | 954 | 2,689 | +182% | 0 | 0 | — |
case-15 | pass→pass | 10,212 | 6,771 | -34% | 1 | 1 | 0% | 1,495 | 2,909 | +95% | 0 | 0 | — |
case-16 | pass→pass | 3,305 | 2,764 | -16% | 1 | 1 | 0% | 473 | 2,296 | +385% | 0 | 0 | — |
case-17 | pass→pass | 3,242 | 3,337 | +3% | 1 | 1 | 0% | 358 | 2,358 | +559% | 0 | 0 | — |
case-18 | fail→pass | 8,472 | 3,960 | -53% | 1 | 1 | 0% | 1,669 | 2,655 | +59% | 0 | 0 | — |
case-19 | pass→pass | 10,583 | 4,370 | -59% | 1 | 1 | 0% | 1,344 | 2,678 | +99% | 0 | 0 | — |
case-20 | pass→pass | 15,027 | 15,667 | +4% | 1 | 1 | 0% | 3,014 | 4,340 | +44% | 0 | 0 | — |
case-21 | fail→fail | 16,885 | 13,276 | -21% | 1 | 1 | 0% | 2,181 | 3,744 | +72% | 0 | 0 | — |
case-22 | pass→pass | 5,440 | 5,579 | +3% | 1 | 1 | 0% | 950 | 2,683 | +182% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +5 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.