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.
npx skills add NVIDIA/skills --skill mcore-linting-and-formatting -a claude-codeWhat 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.shbefore 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-code2Manually: put the files in place
~/.claude/skills/mcore-linting-and-formatting/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/mcore-linting-and-formatting/
1Skills CLI (Vercel)
npx skills add NVIDIA/skills --skill mcore-linting-and-formatting -a codex2Manually: put the files in place
.agents/skills/mcore-linting-and-formatting/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add NVIDIA/skills --skill mcore-linting-and-formatting -a cursor2Manually: put the files in place
.cursor/skills/mcore-linting-and-formatting/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install NVIDIA/skills mcore-linting-and-formatting2Manually: put the files in place
.github/skills/mcore-linting-and-formatting/SKILL.md1Skills CLI (Vercel)
npx skills add NVIDIA/skills --skill mcore-linting-and-formatting -a gemini-cli2Platform CLI
gemini skills install https://github.com/NVIDIA/skills --path skills/mcore-linting-and-formattingManually: put the files in place
.devin/skills/mcore-linting-and-formatting/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add NVIDIA/skills --skill mcore-linting-and-formatting -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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