Skip to main content
skill CX Codex

mcore-linting-and-formatting — Claude Code skill: how to install

Sets up linting and code formatting for Megatron-LM projects. It helps fix ruff and mypy violations and sort imports before opening a pull request.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add NVIDIA/skills --skill mcore-linting-and-formatting -a claude-code
Open on GitHub

What mcore-linting-and-formatting does

This skill guides linting and formatting for the Megatron-LM codebase. It details running tools/autoformat.sh in check mode with CHECK_ONLY=true or fix mode with CHECK_ONLY=false, invoking black, isort, pylint, ruff, and mypy.

Inside the container, run uv sync --locked --only-group linting to get the linting tools. When editing Python files individually, sort imports by running uv run isort <file1>.py <file2>.py before committing.

Code conventions require Google-style docstrings, 119-character lines from pyproject.toml, and explicit exception types instead of bare except statements. Public functions must use X | None rather than Optional[X]. Running tools/autoformat.sh will fail if the container dependencies are not installed first.

What it helps with

  • run style checks with tools/autoformat.sh before opening a PR
  • set up linting dependencies inside the container using uv sync
  • reorder Python imports with uv run isort
  • verify Google-style docstrings and 119-character line limits

Example prompts for the agent

  • How do I run autoformat.sh in check mode before opening a PR?
  • Help me fix ruff and mypy violations in my Megatron-LM changes
  • How should I format imports using uv and isort?

How to install mcore-linting-and-formatting

1Skills CLI (Vercel)

npx skills add NVIDIA/skills --skill mcore-linting-and-formatting -a claude-code

2Manually: put the files in place

~/.claude/skills/mcore-linting-and-formatting/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/mcore-linting-and-formatting/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about mcore-linting-and-formatting

How do I install mcore-linting-and-formatting in Claude Code?

Run npx skills add NVIDIA/skills --skill mcore-linting-and-formatting -a claude-code.

What rules does mcore-linting-and-formatting enforce?

It enforces Megatron-LM conventions using black, isort, pylint, ruff, and mypy. Key rules include a 119-character line limit, Google-style docstrings, and X | None type hints.

How do I install the required linting tools in the container?

Run uv sync --locked --only-group linting inside the project container. This installs the exact toolset used by tools/autoformat.sh and CI.

Source text

SKILL.md · Apache-2.0
---
name: mcore-linting-and-formatting
description: Linting and formatting for Megatron-LM. Covers running autoformat.sh, tools (ruff, black, isort, pylint, mypy), and code style rules.
license: Apache-2.0
when_to_use: Running linting or autoformat; fixing style violations before a PR; 'pre-commit fails', 'ruff error', 'isort', 'mypy', 'style violation', 'how do I format', 'autoformat.sh'.
metadata:
  author: Philip Petrakian <[email protected]>
---

# Linting and Formatting

---

## Running the Formatter

Run before opening a PR:

```bash
# Check mode (no changes applied)
BASE_REF=main CHECK_ONLY=true SKIP_DOCS=false bash tools/autoformat.sh

# Fix mode
BASE_REF=main CHECK_ONLY=false bash tools/autoformat.sh
```

Tools invoked: `black`, `isort`, `pylint`, `ruff`, `mypy`.

---

## Import Ordering

After editing imports in any Python files, always run `uv run isort` on those
files before committing:

```bash
uv run isort <file1>.py <file2>.py
```

---

## Setting Up the Linting Group

Inside the container:

```bash
uv sync --locked --only-group linting
```

This installs `ruff`, `black`, `isort`, `pylint` — the same tools used by
`tools/autoformat.sh` and CI's `linting` job.

---

## Code Style Rules

- **Type hints**: required on all public API functions. Use `X | None`, not `Optional[X]`.
- **Docstrings**: Google-style on all public classes and functions.
- **Naming**: follow Python conventions — `snake_case` for functions and variables, `PascalCase` for classes.
- **Line length**: 119 characters (configured in `pyproject.toml`).
- **No bare `except`**: always catch specific exception types.

© Philip Petrakian · Apache-2.0 · NVIDIA/skills

Similar skills

Everything for AI and ML →

From the same set178

mcore-testing A skill that maps out the Megatron-LM test system: test layout, recipe YAML, golden values, and how to run unit tests locally. CX Codex +1 1,800installs mcore-create-issue Investigates failing GitHub Actions runs for NVIDIA/Megatron-LM, extracts the error cause, and files a structured bug report. CX Codex +1 1,800installs mcore-run-on-slurm Prepare a SLURM launch for distributed Megatron-LM training, from an sbatch skeleton to rank-level failure checks. Useful when configuring or debugging a multi-node job. CX Codex +1 1,800installs nemo-rl-brev-etiquette A skill that tells the agent where files belong on a Brev box: code stays in the repo, heavy run output goes to /ephemeral. CX Codex +1 1,800installs nemo-mbridge-perf-tp-dp-comm-overlap A skill that walks through enabling TP, DP and PP communication overlap in Megatron-Bridge: which knobs to turn, where the code gates it, how to verify. CX Codex +1 1,800installs nemo-mbridge-perf-moe-dispatcher-selection Picks between alltoall, DeepEP and HybridEP for MoE token dispatch based on your hardware, EP degree and optimization stage. CX Codex +1 1,800installs nemo-mbridge-perf-megatron-fsdp Configures Megatron FSDP in Megatron-Bridge to replace standard DDP, helping resolve out-of-memory errors and verify training checkpoints. CX Codex +1 1,800installs nemo-rl-docs This skill hands your agent the documentation rules for NeMo-RL: keeping docs/index.md current and writing docstrings in Google style. Useful when you touch the docs. CX Codex +1 1,800installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor