scripts-tooling-refactor

Refactor a repo's scripts directory into tested Python modules with byte-identical behavior.

2|Updated Jul 18, 2026
One-click install
npx skills add https://github.com/Arasz/ai-badger --skill scripts-tooling-refactor-arasz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: scripts-tooling-refactor
Source: https://github.com/Arasz/ai-badger/tree/main/features/common/skills/scripts-tooling-refactor
Command: npx skills add https://github.com/Arasz/ai-badger --skill scripts-tooling-refactor-arasz

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Refactoring a repository's scripts/ directory is risky: dead scripts are hard to distinguish from load-bearing ones, shell-to-Python ports silently change output and exit codes, and golden artifacts consumed by other test suites break when logic moves. This Skill provides an evidence-driven workflow that converts scripts to the repo's tooling language, moves logic into src/ with TDD tests, and proves behavior parity with diffs instead of eyeballing. ## Core Features & Use Cases - Usage-evidence inventory: Classify every script as LIVE or HISTORICAL using git ls-files and ripgrep-backed reference tracing, so removal candidates carry a written evidence trail. - Thin-wrapper layout with TDD: Preserve existing call sites via thin entrypoints that import logic from scripts/src/, with pytest tests written first and expected values derived by executing the legacy code. - Byte-identical port verification: Run old-vs-new CLI parity harnesses that diff stdout, stderr, exit codes, and output artifacts, using PATH shims for external tools like dotnet. - Use Case: Converting a verify-tool-package.sh script to Python while a CI gate requires identical messages and exit codes — the Skill's checklist preserves stream splitting, print ordering, and exit-code propagation, and the parity harness proves the contract. ## Quick Start Refactor this repository's scripts directory by converting shell scripts to Python, moving logic into src with tests written first, and pruning unused scripts based on usage evidence.

Frequently Asked Questions about scripts-tooling-refactor

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

FAQPage Schema
How do I safely refactor a repo's scripts directory?

Start with git ls-files scripts/ to get the tracked refactor surface, then trace references repo-wide with a ripgrep-backed search to classify each script as LIVE or HISTORICAL. Keep thin wrappers at the original paths, move logic into scripts/src/, and write pytest tests before moving any code.

How to convert a shell script to Python without changing behavior?

Preserve the exact message, stream, and exit-code contract: FAIL lines go to stderr, OK lines to stdout, and subprocess failures propagate the child's exit code via CalledProcessError. Then run an old-vs-new parity harness that diffs stdout, stderr, exit codes, and output artifacts on identical fixtures.

How do I tell if a script is dead or still used?

Trace references across the repo: CI workflow run lines, current tests, and READMEs are LIVE evidence, while docs/plans and findings files are HISTORICAL. A script referenced only in historical docs is a removal candidate, but first verify its live gate moved elsewhere and record a one-line evidence trail.

Why do byte-identical ports fail tests after moving code to src?

Moving a module shifts __file__-derived path constants one level deeper, so paths like HASH_MAP_PATH need an extra .parent to resolve correctly. Also derive expected test values by executing the original code rather than reading it, since reading misses dead branches and quirks that are part of the contract.

Can unit tests verify SHA-pin comparisons in ported scripts?

No fake content can hash to a fixed pin, so the green equality branch is untestable with fabricated data. Cover the hash function against a hashlib reference, test the mismatch branch asserting the pin text, pin the constant in a bundle-contract test, and prove the green path with an end-to-end smoke.