py-refactor
Skill52 starsChanged 12 months agoMITView on GitHub
Orchestrate comprehensive Python refactoring - coordinates security, complexity, testing, code health, and modernization skills to systematically improve code quality.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- vndee/engineering-skillstheir own version, first seen Mar 22, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- vndee/engineering-skills★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository8 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- py-code-healthSkill
- py-complexitySkill
- py-git-hooksSkill
- py-modernizeSkill
- py-quality-setupSkill
- py-securitySkill
- py-test-qualitySkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 27
Follow this impact-based prioritization:
- Distinctive: line 53
Run all automated scanners to get baseline:
- Distinctive: line 155
Don't use orchestrated refactoring when:
- Distinctive: line 157
Single focused task: Use specific skill directly (e.g., just py-security for CVE fix)
- Distinctive: line 158
No tests exist: Write tests first (py-test-quality), then refactor
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Refactoring Orchestrator
Comprehensive refactoring workflow coordinating specialized skills to improve Python code quality.
Overview
This skill orchestrates multiple focused skills to perform systematic refactoring:
| Skill | Purpose | Status |
py-security | Vulnerability detection and remediation | stable |
py-code-health | Dead code and duplication removal | stable |
py-complexity | Reduce cyclomatic/cognitive complexity | stable |
py-test-quality | Coverage analysis and mutation testing | stable |
py-modernize | Upgrade tooling and syntax | stable |
py-quality-setup | Configure linters and type checkers | stable |
py-git-hooks | Set up pre-commit hooks | stable |
Refactoring Priorities
Follow this impact-based prioritization:
- Critical: Security vulnerabilities (use
py-security) - High: Code duplication, untested code (<80% coverage)
- Medium: Complexity reduction, dead code removal
- Low: Syntax modernization, style improvements
Standard Refactoring Workflow
Phase 1: Setup (if needed)
1. If quality tools not configured (pyproject.toml):
→ Invoke: py-quality-setup
(also configures .claude/settings.local.json permissions for all tools)
2. Add analysis tools to [dependency-groups] dev in pyproject.toml:
"radon", "vulture", "pylint", "bandit", "lizard",
"pytest-cov", "mutmut", "wily", "ruff", "mypy", "basedpyright"
3. Install and activate:
uv sync && source .venv/bin/activatePhase 2: Comprehensive Analysis
Run all automated scanners to get baseline:
mkdir -p reports
# Security
ruff check . --select S > reports/security.txt
bandit -r . -f json -o reports/security.json
# Code health
vulture . --min-confidence 80 > reports/dead_code.txt
pylint --disable=all --enable=duplicate-code --recursive=y . > reports/duplication.txt
# Complexity
radon cc . -n C -s > reports/complexity.txt
lizard -l python -w > reports/cognitive_complexity.txt
radon mi . -n B > reports/maintainability.txt
# Test quality
pytest --cov=. --cov-report=html --cov-report=term > reports/coverage.txt
# Initialize complexity tracking
wily build .Phase 3: Prioritized Remediation
Step 1: Security (Critical)
If security.txt shows issues:
→ Invoke: py-security
- Fix SQL injection, hardcoded secrets, weak crypto
- Verify: ruff check . --select S (clean)
- Run tests to ensure no regressionsStep 2: Test Quality (High - enables safe refactoring)
If coverage < 80%:
→ Invoke: py-test-quality
- Write tests for untested code
- Run mutation testing to verify test quality
- Target: ≥80% coverage, ≥75% mutation scoreStep 3: Code Health (High)
If duplication.txt or dead_code.txt show issues:
→ Invoke: py-code-health
- Remove dead code (vulture findings)
- Consolidate duplicates (pylint findings)
- Verify: Tests still pass, coverage maintainedStep 4: Complexity Reduction (Medium)
If complexity.txt shows C+ functions or maintainability < 65:
→ Invoke: py-complexity
- Extract functions, simplify conditionals
- Use guard clauses, lookup tables
- Track improvement with wily
- Verify: radon cc . -n C (clean)Step 5: Modernization (Optional)
If project uses old patterns or pip:
→ Invoke: py-modernize
- Migrate pip → uv
- Upgrade syntax to Python 3.13+
- Consolidate to pyproject.toml
- Verify: Tests pass, type checking worksPhase 4: Automation
Set up git hooks to prevent regressions:
→ Invoke: py-git-hooks
- Pre-commit hooks run ruff, mypy, basedpyright
- Optionally add security checks (bandit)
- Test hook works correctlyPhase 5: Final Validation
# Run complete validation suite
ruff check .
mypy . && basedpyright .
ruff check . --select S
radon cc . -n C
vulture . --min-confidence 80
pytest --cov=. --cov-fail-under=80
# Track overall improvement
wily diff HEAD~1
wily report .When NOT to Use This Skill
Don't use orchestrated refactoring when:
- Single focused task: Use specific skill directly (e.g., just py-security for CVE fix)
- No tests exist: Write tests first (py-test-quality), then refactor
- Active development: Coordinate with team to avoid merge conflicts
- Production incident: Fix incident first, refactor later
Additional Resources
- WORKFLOWS.md: Quick workflows for specific scenarios (security sweep, complexity sprint, legacy modernization)
- METRICS.md: Success metrics, tool reference, Engineering Charter alignment
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

