sandi-metz

Refactor object-oriented code using Sandi Metz rules and test-first cycles.

Updated Aug 14, 2012
One-click install
npx skills add https://github.com/dakotahp/dotfiles --skill sandi-metz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sandi-metz
Source: https://github.com/dakotahp/dotfiles/tree/main/dot_config/claude/skills/sandi-metz
Command: npx skills add https://github.com/dakotahp/dotfiles --skill sandi-metz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a disciplined, test-first workflow for designing and refactoring object-oriented code using Sandi Metz principles so teams can change behavior safely, reduce long methods and large classes, and keep codebases easy to extend.

Core Features & Use Cases

  • Build or Refactor Modes: Decide whether to build a new component from tests (Shameless Green) or iteratively refactor existing code based on file/class input or recent git churn.
  • TDD-Driven Rounds: Enforces red → green → refactor cycles, writing minimal tests first, making the smallest change to pass, and then cleaning up with one small refactoring per round.
  • Rule-Guided Assessment: Automatically assess rule violations and code smells (class length, method length, parameter counts), propose a safe refactoring sequence, and summarize each round with metrics.
  • Practical Safety Nets: Requires a green test baseline before refactoring, uses git diffs and greps to scope work, and includes revert guidance if tests break.

Quick Start

Ask the skill to refactor by supplying a file path or class name, or describe a new feature to build from tests.

Frequently Asked Questions about sandi-metz

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor object-oriented code safely using test-driven development?

Test-driven refactoring requires a green test baseline before changing code, then enforces red, green, and refactor cycles to make incremental object-oriented improvements safely.

What is the best way to reduce long methods and large classes in OOP?

Reducing long methods and large classes involves assessing rule violations like parameter counts and method length, then applying small refactoring rounds guided by tests to ensure safe code changes.

How do I build a new feature from tests using Shameless Green?

Building a feature with Shameless Green means writing minimal tests first, making the smallest code change to pass them, and then cleaning up with one small refactoring per round.

Can I refactor code based on recent git churn?

Yes, you can refactor code based on recent git churn by using git diffs and greps to scope work, requiring file access and shell operations to read, edit, and run tests iteratively.

What should I do if tests break during an object-oriented refactoring cycle?

If tests break during refactoring, you should use revert guidance to safely undo changes, as maintaining a green test baseline is required before starting any incremental code improvements.

Do I need a test runner to apply Sandi Metz refactoring rules?

Yes, a test runner and basic shell operations are required to apply Sandi Metz rules, as the workflow relies on running tests iteratively to validate small code changes during refactoring.