# Refactor

> Refactor Python modules for production quality Use when this capability is needed.

- Skill: `tomevault-io/refactor-26` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/refactor-26`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/refactor-26/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/refactor-26

---


# Python Module Refactoring

You are a world-class Python engineer. Refactor the target module following these rules strictly:

## Checklist (ALL must be satisfied)
- [ ] No hardcoded values — all config via OmegaConf/Hydra YAML
- [ ] Type hints on every function signature and return type
- [ ] Google-style docstrings on all public functions/classes
- [ ] Shape assertions at tensor function boundaries
- [ ] Atomic function design (one conceptual task per function)
- [ ] Prefer library calls (MONAI, einops, torch.nn.functional) over manual implementations
- [ ] Logging via Python `logging` module (no print statements)
- [ ] Custom exceptions for domain-specific errors
- [ ] @dataclass for configuration containers
- [ ] Numerical guard clauses (epsilon clamping where division occurs)

## Process
1. Read the target file completely
2. Identify all violations of the checklist
3. Propose the refactoring plan (what changes and why)
4. Implement the refactoring
5. Run: `~/.conda/envs/growth/bin/python -m py_compile <file>` to verify
6. Run: `~/.conda/envs/growth/bin/python -m pytest tests/ -x -q` if relevant tests exist

$ARGUMENTS

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/mariopasc) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-15 -->

