# pytorch

pytorch is a Claude Code rule for structuring and writing PyTorch code. It applies to Python files matched by **/*.py.

- rule · `type=rule` · Claude Code, Cline, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop) · ★ 1054 repo stars
- Author: Bhartendu-Kumar
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/Bhartendu-Kumar/rules_template/tree/HEAD/specific_rule_files/pytorch.mdc
- Updated: 2025-07-17
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/bhartendu-kumar-pytorch

## What it does

pytorch gives the agent guidelines for organizing PyTorch projects. It covers directories and modules, model components built with `nn.Module`, data loading, and reusable code.

The guidance also addresses testing, security, performance, and common coding mistakes. It describes splitting complex networks into smaller parts and mentions `DataParallel` and `DistributedDataParallel` for multi-GPU training. The rule targets files matching `**/*.py`.

## Install

### Cursor (native platform)

**Manually: put the files in place**
- File: `.cursor/rules/pytorch.mdc` — Frontmatter: description, globs, alwaysApply

### Claude Code

**Manually: put the files in place**
- File: `.claude/rules/pytorch.md` — The paths frontmatter field limits the files: move globs from the source into paths

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/pytorch.instructions.md` — The applyTo field sets which files it applies to: move globs from the source into applyTo

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/pytorch.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/pytorch.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Bhartendu-Kumar/rules_template/tree/HEAD/specific_rule_files/pytorch.mdc

## When to use it
- organize a PyTorch project into modules and directories
- split a network into reusable `nn.Module` components
- load batches through `Dataset` and `DataLoader`
- choose a multi-GPU training approach

## Example prompts
- Organize this PyTorch project into clear modules and directories.
- Break this network into reusable `nn.Module` components.
- Set up data loading with `Dataset` and `DataLoader`.

## Similar
- [pytorch-lightning](https://affpapa.org/en/nevibecode/skills/k-dense-ai-pytorch-lightning.md) — skill · 2300 installs
- [pytorch-scikit-learn-cursorrules-prompt-file](https://affpapa.org/en/nevibecode/rules/pytorch-scikit-learn-cursorrules-prompt-file.md) — rule · ★ 41178 repo stars
- [pytorch-expert](https://affpapa.org/en/nevibecode/agents/pytorch-expert.md) — subagent · ★ 1029 repo stars
- [torchcode-pytorch-interview-practice](https://affpapa.org/en/nevibecode/skills/torchcode-pytorch-interview-practice.md) — skill · 806 installs
- [paper2code-arxiv-implementation](https://affpapa.org/en/nevibecode/skills/paper2code-arxiv-implementation.md) — skill · 643 installs
- [pytorch-patterns](https://affpapa.org/en/nevibecode/skills/pytorch-patterns.md) — skill · 6600 installs

## Other versions with the same name
- [pytorch · sanjeed5](https://affpapa.org/en/nevibecode/rules/pytorch.md) — ★ 3589 repo stars

From the same set: [bhartendu-kumar/rules_template](https://affpapa.org/en/nevibecode/by/bhartendu-kumar/rules_template.md) — 11 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
