cursorrules

A set of Cursor rules for Python artificial-intelligence and machine-learning projects using PyTorch. It describes project structure, typed and tested code, validated data pipelines, experiment tracking, and reproducible development.

In plain words
What is it for?
Use it to organise datasets, models, training, evaluation, inference, and deployment-related Python code.
Why use it?
It gives the coding agent project conventions to follow when building or changing machine-learning code.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/survivorforge/cursor-rules/cursorrules
Clone the repo
git clone --depth 1 https://github.com/survivorforge/cursor-rules

Made for: Cursor.

Per session 2,136 This file is loaded in full into every session.
When invoked 2,136 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02136 $0.02136
Opus 5 $0.01068 $0.01068
Sonnet 5 $0.00427 $0.00427
Haiku 4.5 $0.00214 $0.00214

Measured yesterday against content hash 74d2526303a0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cursorrules scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

3 near-identical copies found in the catalogue:

  • cursorrules — 100% identical, 0 lines differ
  • rule — 91% identical, 6 lines differ
  • rule — 91% identical, 6 lines differ
rules/ai-ml-python/.cursorrules · 244 lines

How it starts

The opening of the file, as written. The whole thing — 244 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AI/ML Python Projects — Cursor Rules

Production ML: PyTorch, data pipelines, experiment tracking, and deployment

Project Context

You are building an AI/ML project with Python. The project uses PyTorch for model training, handles data pipelines with proper validation, tracks experiments systematically, and follows production ML engineering practices. Code is type-hinted, tested, and reproducible.

Project Structure

project/
  src/
    data/
      datasets.py           # PyTorch Dataset classes
      transforms.py         # Data augmentation and preprocessing
      loaders.py            # DataLoader configurations
      validation.py         # Data quality checks
    models/
      architectures/        # Model definitions
        resnet.py
        transformer.py
      losses.py             # Custom loss functions
      metrics.py            # Evaluation metrics
    training/
      trainer.py            # Training loop
      callbacks.py          # Training callbacks (early stopping, checkpointing)
      optimizers.py         # Optimizer configurations
    inference/
      predictor.py          # Inference pipeline
      postprocess.py        # Output postprocessing
    utils/
      config.py             # Configuration management
      logging.py            # Experiment logging
      reproducibility.py    # Seed setting, deterministic mode
  configs/
    train_config.yaml       # Training hyperparameters
    model_config.yaml       # Model architecture config
  scripts/
    train.py                # Training entry point
    evaluate.py             # Evaluation script
    export.py               # Model export (ONNX, TorchScript)
  notebooks/
    exploration.ipynb       # Data exploration (not production code)
  tests/
    test_data.py
    test_models.py
    test_training.py

PyTorch Model Patterns

  • Inherit from nn.Module. Always call super().__init__().
  • Type hint all method signatures:
    class ClassificationHead(nn.Module):
        def __init__(self, in_features: int, num_classes: int, dropout: float = 0.1) -> None:
            super().__init__()
            self.dropout = nn.Dropout(dropout)
            self.fc = nn.Linear(in_features, num_classes)
    
        def forward(self, x: torch.Tensor) -> torch.Tensor:
            x = self.dropout(x)
            return self.fc(x)
    
  • Use nn.Sequential or nn.ModuleList for dynamic layer construction — never regular Python lists.
  • Register buffers for non-parameter tensors: self.register_buffer('mean', torch.zeros(3)).
  • Use @torch.no_grad() for inference methods.
  • DON'T: Use numpy operations inside forward() — they break autograd.
  • DON'T: Create tensors in forward() without sending to the correct device.

Read the full file on GitHub · 244 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 244 lines · 2,136 tokens per session scan A 74d2526303a0

Subscribe to this mod's changes

cursorrules is a cursor rule published in the GitHub repository survivorforge/cursor-rules (18 stars, last pushed 4mo ago), licensed MIT. It adds 2,136 tokens to every session, about $0.0107 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.