writing-ratchet-tests

Create ratchet tests with RegexPattern checks and inline-snapshot to track code anti-patterns.

401|41|Updated Jan 19, 2026
One-click install
npx skills add https://github.com/imbue-ai/mng --skill writing-ratchet-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-ratchet-tests
Source: https://github.com/imbue-ai/mng/tree/main/.claude/skills/writing-ratchet-tests
Command: npx skills add https://github.com/imbue-ai/mng --skill writing-ratchet-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Ratchet tests prevent the accumulation of common code anti-patterns by tracking their presence in the codebase and enforcing improvements via snapshots.

Core Features & Use Cases

  • Define measurable ratchets for patterns like TODO comments, inline imports, use of eval or exec, and broad exception handling.
  • Generate and compare inline snapshot data to detect increases and allow decreases as improvements.
  • Provide scaffolding and guidance to integrate tests into CI and development workflows.

Quick Start

Create a test_ratchets.py in your project and follow this guide to start tracking a chosen anti-pattern.

Frequently Asked Questions about writing-ratchet-tests

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

FAQPage Schema
How do I prevent Python code anti-patterns from accumulating in my codebase?

Ratchet tests prevent Python code anti-patterns from accumulating by tracking their occurrences and enforcing improvements via inline snapshots. You define measurable ratchets for patterns like TODO comments or eval usage to establish a baseline and drive continuous code quality improvement.

What is the best way to track TODO comments and broad exception handling in Python?

The best way to track broad exception handling and TODO comments is using ratchet tests with RegexPattern checks. This approach snapshots the current count of these anti-patterns, allowing decreases as improvements while actively preventing any new occurrences from being introduced.

How do I set up ratchet tests using inline-snapshot in my project?

To set up ratchet tests, create a test_ratchets.py file in your project, import the ratchet utilities, and use RegexPattern checks alongside inline-snapshot to capture baseline metrics. This scaffolding integrates directly into your CI and development workflows to enforce standards.

Can I use ratchet tests to enforce standards against inline imports and eval statements?

Yes, you can use ratchet tests to enforce standards against inline imports and eval or exec statements. By applying RegexPattern checks across your projects, the test suite detects any increases in these anti-patterns and allows decreases as measurable code improvements.

How does inline-snapshot work with ratchet tests to maintain code quality?

Inline-snapshot works with ratchet tests by generating and comparing snapshot data to detect increases in anti-patterns and allow decreases as improvements. This mechanism tracks specific code patterns continuously, ensuring any new violations fail the tests and prompt immediate remediation.