code-ratchets

Count deprecated Python code patterns across git repositories with pre-commit workflows.

74|12|Updated Nov 1, 2024
One-click install
npx skills add https://github.com/AD-SDL/MADSci --skill code-ratchets
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-ratchets
Source: https://github.com/AD-SDL/MADSci/tree/main/skills/code-ratchets
Command: npx skills add https://github.com/AD-SDL/MADSci --skill code-ratchets

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires rich.

What problem does it solve?

Counts deprecated code patterns across a repository to prevent uncontrolled proliferation and ensure team-wide code health.

Core Features & Use Cases

  • Flexible pattern definitions and per-directory glob matching for Python projects.
  • Integrated with pre-commit workflows to enforce standards during commits and migrations.
  • Use case: when migrating away from legacy code, this ratchet helps keep the codebase clean by failing commits that introduce too many deprecated patterns.

Quick Start

Run the pre-commit hook to enforce the code ratchet rules on every commit.

Frequently Asked Questions about code-ratchets

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

FAQPage Schema
How do I prevent deprecated code patterns from increasing in a Python git repository?

Prevent deprecated code patterns from proliferating by using code ratchets to count existing instances and fail commits that introduce new occurrences. This enforces consistent code quality during development, migrations, and refactoring via pre-commit workflows.

What is a code ratchet and how does it work with pre-commit?

A code ratchet is a mechanism that counts specific deprecated patterns across your repository and fails pre-commit hooks if counts exceed expected values. It guides updates to ratchet configuration when actual counts fall below thresholds.

How do I configure pattern definitions and exclusions for static analysis in Python?

Configure pattern definitions for static analysis by setting up per-path glob matching and specifying exclusion directories. The ratchet tool applies these rules to Python projects to report when deprecated pattern counts exceed or fall below expected values.

Can I use code ratchets for legacy code migration and refactoring?

Yes, you can use code ratchets for legacy code migration and refactoring to keep the codebase clean. The ratchet fails commits that introduce too many deprecated patterns, ensuring consistent code health throughout the migration process.

Does the code ratchets tool require any specific dependencies to run?

The code ratchets tool requires the rich Python library as a dependency to run. It is designed for Python projects using git and pre-commit workflows to enforce code quality standards during commits.

Why does my pre-commit hook fail when refactoring deprecated patterns?

Your pre-commit hook fails during refactoring because the code ratchet detected actual deprecated pattern counts exceeding expected values. You must update the ratchet configuration to match the reduced counts after successfully removing legacy patterns.