Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when writing Python functions/classes for Megatron-LM: annotate with `X | None` and builtin generics, Google docstrings, line length 119, never bare except.
.claude/skills/megatron-python-style/SKILL.md| Model | Eval pass | Runs |
|---|---|---|
| gemini-3.6-flash | 100% | 22 |
| gemini-3.1-pro-previewlowest | 80% | 5 |
| Model | Lift | Δ tokens | Δ turns | Cases | Verified |
|---|---|---|---|---|---|
| gemini-3.5-flashbest | +100% | — | 0% | 23 | 86d ago |
| gemini-3.6-flash | +50% | +116% | 0% | 22 | 54d ago |
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | — | — |
| case-03 | ✗→✓ | ▲ Improved | — | — |
| case-06 | ✗→✓ | ▲ Improved | — | — |
| case-11 | ✗→✓ | ▲ Improved | — | — |
| case-01 | ✗→✓ | ▲ Improved | — | — |
Enforce the Megatron-LM Python style on every function, method, and class you emit: modern X | None / builtin-generic annotations, Google-style docstrings, specific exception catches, 119-char lines, and the standard naming casing. Apply to all Python code written for this codebase — these are non-default choices the base model gets wrong.
X | None, never Optional[X]X | None. NEVER Optional[X] and NEVER Union[X, None].| None must appear at the end of the annotation: dict[str, int] | None, notNone | dict[str, int].
None default still gets the full annotation: tags: set[str] | None = None.A | B, never Union[A, B]A | B | C. NEVER Union[A, B].A | B | None.typing aliaseslist[int], dict[str, int], tuple[int, ...], set[str],type[Foo], frozenset[str].
List, Dict, Tuple, Set, Type, FrozenSet from typing.list[list[int]], dict[str, list[int]], list[dict[str, int]].tuple[int, ...]; a fixed-shape tuple names eachslot: tuple[int, int], tuple[str, float, bool].
typing names must not appearfrom typing import Optional, Union, List, Dict, Tuple, Set, Type.typing is still fine for things with no builtin form (Any, Callable, Protocol,TypeVar, Iterable); only the six aliases above are banned.
return. A function that returns nothing is annotated -> None.
self and cls are not annotated.Args: section listing each parameter by name.Returns: section describing the return value (omit only when the function returns Noneand that is obvious; prefer including it).
Raises: section listing each exception type the body can raise — present if and onlyif the body can raise.
except:.except Exception: as the normal catch-all.except KeyError:, except (ValueError, TypeError):,except FileNotFoundError:.
snake_case for functions and variables, PascalCase for classes, UPPER_SNAKE formodule-level constants.
BEFORE (base default):
pythonfrom typing import Optional def find_checkpoint(run_dir: str, step: int) -> Optional[str]: ...
AFTER (conforming):
pythondef find_checkpoint(run_dir: str, step: int) -> str | None: ...
BEFORE:
pythonfrom typing import Union def coerce(x: Union[int, float]) -> Union[int, None]: ...
AFTER:
pythondef coerce(x: int | float) -> int | None: ...
BEFORE:
pythonfrom typing import List, Dict def merge_shards(shards: List[int]) -> Dict[str, object]: ...
AFTER:
pythondef merge_shards(shards: list[int]) -> dict[str, object]: ...
BEFORE:
pythonfrom typing import Optional, List, Dict, Tuple
AFTER (the line is simply gone; annotations use | None, list, dict, tuple):
python# no typing import of the aliased names at all
BEFORE:
pythondef batch_tokenize(texts, max_len): """Tokenize texts.""" ...
AFTER:
pythondef batch_tokenize(texts: list[str], max_len: int) -> list[list[int]]: """Tokenize a batch of strings into token-id lists. Args: texts: Input strings to tokenize. max_len: Maximum number of tokens per sequence. Returns: One token-id list per input string. """ ...
Raises: when the body can raiseBEFORE:
pythondef validate_shape(shape: tuple[int, ...]) -> tuple[int, ...]: """Validate a shape.""" if any(d <= 0 for d in shape): raise ValueError("dimensions must be positive") return shape
AFTER:
pythondef validate_shape(shape: tuple[int, ...]) -> tuple[int, ...]: """Validate that every dimension of a shape is positive. Args: shape: The tensor shape to validate. Returns: The shape unchanged when valid. Raises: ValueError: If any dimension is non-positive. """ if any(d <= 0 for d in shape): raise ValueError("dimensions must be positive") return shape
BEFORE:
pythondef parse_config(path: str): try: return json.load(open(path)) except: return None
AFTER:
pythondef parse_config(path: str) -> dict | None: """Read and parse a JSON config file. Args: path: Path to the config file. Returns: The parsed config, or None if the file is missing. """ try: with open(path) as fh: return json.load(fh) except FileNotFoundError: return None
None default, optional type: annotate as set[str] | None = None. The defaultvalue None does not let you drop the annotation.
tuple[int, int] (exactly two ints) is different fromtuple[int, ...] (any number). Pick the one the function actually produces.
| None inside the quoted form,e.g. def next(self) -> "Node | None":.
typing.Any, Callable, Protocol, TypeVar are still imported from typing —only the six collection/optional aliases are banned.
except SpecificError: raise is fine; the ban is on catching broadly,not on re-raising a specific type.
(e.g. except OSError:) over except Exception:. A bare except: is never allowed.
strongest for public API but the typing/exception rules apply everywhere.
from typing import Optional; ALWAYS write X | None inline.Dict[str, int]; ALWAYS write dict[str, int].except: or except Exception:; ALWAYS name the exact exception type.the return.
Raises: section for a function that cannot raise; ALWAYS add one when it can.camelCase methods or lowercase class names; ALWAYS snake_case /PascalCase / UPPER_SNAKE.
Optional[...] / Union[...] out of habit — the single most common miss.List[int] / Dict[...] with a from typing import ... line.except: or except Exception: pass to "be safe."Args: / Returns:.-> None).Raises: section out of habit when the function never raises, or omitting itwhen the function clearly does.
Optional[ / Union[ anywhere — X | None, A | B.list/dict/tuple/set/type[...], never the typing aliases; no banned imports.-> None when nothing is returned.Args:, Returns:, Raises: (iff it raises).except; never bare or except Exception:.snake_case / PascalCase / UPPER_SNAKE.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.5-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 +50 percentage points is the difference between those two pass rates over the 22 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
| Model | Method | Date | Lift |
|---|---|---|---|
| gemini-3.5-flash | verified | 6/27/2026 | +100% |
Other measured skills in the registry, with their headline benchmark lift.