# pytorch-lightning

Helps Claude Code structure PyTorch code into LightningModules and configure multi-GPU or TPU training. It removes boilerplate loops and organizes data pipelines.

- skill · `type=skill` · Claude Code · 53 installs
- Author: davila7
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/scientific/pytorch-lightning
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/pytorch-lightning

## What it does

This skill guides Claude Code in refactoring raw PyTorch code into structured Lightning projects. Model logic resides inside `LightningModule`, while dataset preparation lives in `LightningDataModule`. The skill provides starter scripts like `template_lightning_module.py` and `template_datamodule.py`.

For model execution, the skill guides `Trainer` configuration. It sets up mixed precision and gradient clipping. Metric tracking connects directly to WandbLogger or TensorBoard. Built-in hooks include `EarlyStopping` and `ModelCheckpoint`. Running `fast_dev_run=True` tests pipeline integrity on a single batch.

Device distribution rules depend on weight count: DDP handles networks below 500M parameters, while FSDP or DeepSpeed fit larger models. The resulting code will fail without `torch` and `lightning` installed in your environment.

## Install

### Claude Code (native platform)

1. **claude-code-templates**
```bash
npx claude-code-templates@latest --skill scientific/pytorch-lightning
```

2. **Skills CLI (Vercel)**
```bash
npx skills add davila7/claude-code-templates --skill pytorch-lightning -a claude-code
```

3. **Manually: put the files in place**
- File: `~/.claude/skills/pytorch-lightning/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/pytorch-lightning/

### Codex

**Manually: put the files in place**
- File: `.agents/skills/pytorch-lightning/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/pytorch-lightning/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install davila7/claude-code-templates pytorch-lightning
```

2. **Manually: put the files in place**
- File: `.github/skills/pytorch-lightning/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/scientific/pytorch-lightning
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/pytorch-lightning/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/scientific/pytorch-lightning

## When to use it
- convert raw PyTorch training scripts into a modular `LightningModule`
- isolate dataset preparation and data loaders inside a `LightningDataModule`
- configure multi-GPU training with DDP, FSDP, or DeepSpeed
- add automated checkpointing and early stopping callbacks

## Example prompts
- Convert the PyTorch network in `model.py` into a LightningModule with Adam optimizer
- Write a LightningDataModule that loads training and validation datasets with batch size 32
- Configure a Trainer for 4 GPUs using FSDP distributed strategy

## Similar
- [skill-creator](https://affpapa.org/en/nevibecode/skills/skill-creator.md) — skill · 414180 installs
- [writing-for-agents](https://affpapa.org/en/nevibecode/skills/writing-for-agents.md) — skill · 466719 installs
- [media-use](https://affpapa.org/en/nevibecode/skills/media-use.md) — skill · 1100000 installs
- [mcp-builder](https://affpapa.org/en/nevibecode/skills/mcp-builder.md) — skill · 130949 installs
- [subagent-driven-development](https://affpapa.org/en/nevibecode/skills/subagent-driven-development.md) — skill · 237746 installs
- [orchestration](https://affpapa.org/en/nevibecode/skills/orchestration.md) — skill · 350300 installs

## Other versions with the same name
- [pytorch-lightning · k-dense-ai](https://affpapa.org/en/nevibecode/skills/k-dense-ai-pytorch-lightning.md) — 2000 installs

From the same set: [davila7/claude-code-templates](https://affpapa.org/en/nevibecode/by/davila7/claude-code-templates.md) — 804 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
