From armory
Simplifies recently modified files via git diff: analyzes cyclomatic complexity, detects duplicates/nesting, reduces conditionals, extracts helpers, verifies tests.
npx claudepluginhub mathews-tom/armory --plugin armoryrefactor/# Refactor Clean — Code Simplification Workflow When the user invokes `/refactor [path]`, execute this workflow exactly. ## Step 1: Identify Targets 1. If a path is provided, scope to that file or directory. 2. If no path is provided, use `git diff --name-only HEAD~3` to find recently modified files. Fall back to `git diff --name-only main` if fewer than 3 commits on the branch. 3. Filter to source files only (exclude tests, configs, lockfiles, generated files). 4. Sort by modification recency — most recently changed first. 5. Present the file list to the user: 6. Proceed with all ...
/COMMANDSurfaces and validates Claude's hidden assumptions about project context, tech stack, and standards interactively. Supports --list, --check, --graph modes.
/COMMANDRuns full diagnostic investigation on WordPress site: intake questioning, reconnaissance, skill planning, parallel execution, findings verification.
/COMMANDRuns diagnostic suite on a WordPress site with full (default), security-only, code-only, or performance modes, producing structured reports with health grades.
/COMMANDStarts interactive modification session for WordPress directory: iterate on NL or visual changes conversationally with git commits per step, produces versioned zip on completion.
/COMMANDLists connected WordPress sites with sync status, diagnostic health summaries, and manages profiles (remove, set default, rename).
/COMMANDRuns diagnostics on multiple saved site profiles sequentially via /diagnose, producing per-site status lines and a health-grade-sorted comparison matrix.
When the user invokes /refactor [path], execute this workflow exactly.
git diff --name-only HEAD~3 to find recently modified files.
Fall back to git diff --name-only main if fewer than 3 commits on the branch.## Files to clean
| # | File | Lines changed | Last modified |
| --- | ------------- | ------------- | ------------- |
| 1 | src/parser.py | +42 / -18 | 2 commits ago |
For each target file:
Report:
### {filename} — Complexity
| Function | Cyclomatic | Max depth | Lines | Params | Action needed |
| ---------- | ---------- | --------- | ----- | ------ | ------------- |
| parse() | 14 | 5 | 62 | 3 | yes |
| validate() | 6 | 2 | 18 | 2 | no |
Report each duplicate group with file locations and line ranges.
Apply these transformations where applicable:
if condition: <long block> else: <short return> to early
return pattern.not (a and b) to not a or not b when it
improves readability.if/elif/elif/else chains (>= 4 branches) with dictionary
dispatch or match/case.if x: return True else: return False with
return x (or return bool(x)).if x is not None: y = x else: y = default with
y = x if x is not None else default or language-specific null coalescing.For each transformation:
Extract a helper function only when ALL of these conditions hold:
do_stuff, process_data, handle_thing).Do NOT extract when:
For each proposed extraction, state which conditions are met and justify.
## Refactor Clean Summary
**Scope:** `{path_or_git_diff_range}`
**Files analyzed:** {count}
**Files modified:** {count}
### Changes applied
| File | Transformation | Lines before | Lines after | Complexity delta |
| --------- | -------------------------- | ------------ | ----------- | ---------------- |
| parser.py | Guard clauses (3x) | 62 | 48 | -4 |
| parser.py | Extract validate_header() | — | +12 | -3 |
| utils.py | Deduplicate error handling | 28 | 16 | -2 |
### Skipped (justified)
| File | Candidate | Reason skipped |
| ------ | ------------------ | --------------------------------- |
| api.py | Extract auth block | Single use, 8 lines, name unclear |
### Test verification
- Tests run: {count}
- Tests passed: {count}
- Characterization tests added: {count}
### Net impact
- Total lines: {before} -> {after} ({delta})
- Avg cyclomatic complexity: {before} -> {after}
- Functions simplified: {count}
- Helpers extracted: {count}