Research Code Skill

    by SaltGardenia

    1

    Enforce strict ML research engineering standards, Hydra configurations, and PyTorch Lightning architecture.

    Free

    4 usesSecurity scanned

    Works with the AI Agents you already use

    research-code-skill

    Example session with this skill installed

    Refactor my current model training script. It has hardcoded learning rates and the model architecture is mixed with the training loop. Move it to the Lightning-Hydra structure.

    • Read your context and instructions
    • Compiled the research-code-

    I have restructured the training script to follow the lab's architecture. The model backbone is now separated from the `LightningModule`, and all hyperparameters are moved to Hydra configs. ## Convention applied: Refactor to Lightning-Hydra in src/models/mnist_module.py ## Decision - Extracted the CNN architecture into `src/models/components/simple_cnn.py`. - Wrapped the backbone in a `LightningModule` with explicit `torchmetrics` and `configure_optimizers`. - Created `configs/model/mnist.yaml` to handle the `_target_` and `lr` parameters. ## Code ```python import torch from lightning import LightningModule from torchmetrics import MaxMetric, MeanMetric from torchmetrics.classification import MulticlassAccuracy class MNISTLitModule(LightningModule): def __init__( self, net: torch.nn.Module, optimizer: torch.optim.Optimizer, scheduler: torch.optim.lr_scheduler.LRScheduler, compile: bool = False, ) -> None: super().__init__() self.save_hyperparameters(logger=False) self.net = net self.criterion = torch.nn.CrossEntropyLoss() self.train_acc = MulticlassAccuracy(num_classes=10) self.val_acc = MulticlassAccuracy(num_classes=10) def forward(self, x: torch.Tensor) -> torch.Tensor: return self.net(x) def training_step(self, batch: tuple[torch.Tensor, torch.Tensor], batch_idx: int): x, y = batch logits = self.forward(x) loss = self.criterion(logits, y) self.train_acc(logits, y) self.log("train/loss", loss, on_step=False, on_epoch=True, prog_bar=True) self.log("train/acc", self.train_acc, on_step=False, on_epoch=True, prog_bar=True) return loss def configure_optimizers(self): optimizer = self.hparams.optimizer(params=self.trainer.model.parameters()) if self.hparams.scheduler is not None: scheduler = self.hparams.scheduler(optimizer=optimizer) return { "optimizer": optimizer, "lr_scheduler": {"scheduler": scheduler, "monitor": "val/loss", "interval": "epoch"}, } return {"optimizer": optimizer} ``` **Next steps** 1. Run `python scripts/run_gate.sh` to verify the new structure passes linting and tests. 2. Update `configs/experiment/mnist_base.yaml` to reference the new model config. 3. Delete the legacy training script once the new entrypoint is verified.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Research codebases often devolve into a mess of hardcoded paths, inconsistent naming, and rigid architectures that break reproducibility. This skill enforces a strict engineering charter for ML and DL projects. It ensures every file, model, and configuration follows a unified standard derived from industry authorities like Google, Meta, and PyTorch Lightning. ## What it does - **Enforces Architecture** preserves the Lightning-Hydra-Template structure, ensuring data, models, and configs stay in their designated directories. - **Validates Model Design** separates model backbones from LightningModule systems and enforces OpenMMLab registry patterns. - **Standardizes Configs** replaces hardcoded literals with Hydra-based configuration groups for experiment reproducibility. - **Ensures Code Quality** applies Google Python Style naming conventions and type annotations across the entire source package. - **Automates Quality Gates** runs a mandatory sequence of Black, Isort, Ruff, Mypy, and Pytest to verify every change. ## How it works 1. **Scenario Selection** determines if the task is building a new project from a skeleton or tidying an existing repository. 2. **Cluster Loading** reads specific reference files for the current concern, such as model design or experiment reproducibility. 3. **Execution** writes or refactors code using Karpathy-inspired discipline: think first, stay simple, and use surgical edits. 4. **Validation** runs the five-tool quality gate to confirm the codebase remains conformant and functional. ## Frameworks & tools This skill is built for Python research environments using PyTorch Lightning, Hydra, and Timi. It integrates with Black, Isort, Ruff, Mypy, and Pytest for static analysis and testing. ## Why this beats prompting it yourself Generic prompts often ignore the complex interplay between experiment configs and model registries. This skill uses a fused rule-code registry (RC-*) to ensure conventions are machine-checkable and consistent across the entire project lifecycle. ## Use cases - **Scaffolding** initializing a new deep learning project with a reproducible directory tree and config system. - **Refactoring** migrating a messy research script into a structured, installable Python package. - **Standardization** enforcing uniform naming and docstring standards across a multi-member research team. ## Known limitations Does not support non-Python projects or frontend-only applications. Requires a Python 3.8+ interpreter for running quality gate scripts.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    4 uses

    Times used to date

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 1 month ago

    • Free with an Agensi account

    Software
    Python

    Permissions

    Terminal / Shell
    Listed1 month ago

    What's inside

    Creator

    SaltGardenia

    SaltGardenia

    2 skills on Agensi

    Frequently Asked Questions

    This skill enforces a rigid structure based on the Lightning-Hydra-Template, separating data modules, model backbones, and experiment configurations into a unified, reproducible system that eliminates hardcoded paths.

    The skill is specifically designed for Python 3.8+ environments using PyTorch Lightning and Hydra; it is not compatible with other frameworks like TensorFlow or JAX at this time.

    It automates a professional-grade quality gate using Black, Isort, Ruff, Mypy, and Pytest, ensuring every line of code meets strict industry standards for type safety and formatting.

    Unlike generic prompts, this skill uses a specialized registry of engineering rules to manage the complex relationship between Hydra configuration groups and PyTorch registries, preventing the 'configuration drift' common in large projects.

    You receive the full suite of engineering logic, the automated quality gate sequence, and a set of template skeletons for scaffolding new projects or refactoring legacy repositories.

    New in Code Quality & Review

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Code Quality & Review.

    Free