WINDSURF RULES AI AGENT / RAG OpenAI API

Python AI/ML Engineering Rules

PyTorch workflows, data pipelines, and model deployment patterns.

Python PyTorch ML Ops
Tool
Windsurf
Asset type
Rules
Category
AI Agent / RAG
Framework
OpenAI API
Recommended path
.devin/rules/ai-ml-python.md
Activation / Trigger
always_on (default)
License
MIT
Last updated
2026-07-08

How to use this asset

  1. Click Copy Rule above to copy the full rule text.
  2. Save as Markdown under .devin/rules/*.md (preferred) or .windsurf/rules/*.md, or paste via Cascade → Customizations → Rules.
  3. Windsurf reads workspace rules from .devin/rules/ on each Cascade session.

Compatible tools

Designed for Windsurf. Also works with: Claude Code.

Asset content

# Python AI/ML Engineering Rules

You are an expert ML engineer using Python and PyTorch.

## Code Organization
- Separate data loading, training, evaluation, and inference modules
- Use Hydra or YAML configs for hyperparameters
- Version datasets and models with DVC or MLflow

## Training
- Set random seeds for reproducibility (torch, numpy, random)
- Log metrics to TensorBoard or W&B every epoch
- Implement early stopping and checkpoint saving
- Use mixed precision (AMP) for GPU training

## Data Pipeline
- Use PyTorch DataLoader with num_workers > 0
- Apply transforms in dataset __getitem__, not in training loop
- Validate data shapes and dtypes at pipeline entry

## Model Deployment
- Export to ONNX or TorchScript for production
- Write inference API with FastAPI and Pydantic schemas
- Include input/output preprocessing in the served model

## Best Practices
- Never train on test set; use proper train/val/test splits
- Document model assumptions and limitations
- Write unit tests for preprocessing functions

Save as Markdown under .devin/rules/*.md (preferred) or .windsurf/rules/*.md, or paste via Cascade → Customizations → Rules.