
Indexion Refactor
Run indexion-backed duplication and single-source-of-truth cleanup after feature work or messy multi-file fixes.
Install
npx skills add https://github.com/trkbt10/indexion-skills --skill indexion-refactorWhat is this skill?
- Three duplication levels: textual copy-paste, structural wrappers/extracts, conceptual SoT violations
- indexion commands: plan refactor, plan solid, plan unwrap, plus explore for conceptual analysis
- Trigger heuristics: new abstraction, 3+ files touched for one reason, guard/skip workarounds, cross-package extraction
- End state verifies single source of truth is enforced after fixes
- Periodic SoT health check workflow for ongoing codebase hygiene
Adoption & trust: 509 installs on skills.sh; 1 GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Improve Codebase Architecturemattpocock/skills
Zoom Outmattpocock/skills
Caveman Reviewjuliusbrussee/caveman
Requesting Code Reviewobra/superpowers
Receiving Code Reviewobra/superpowers
Request Refactor Planmattpocock/skills
Journey fit
Primary fit
Refactor-and-verify passes belong on the Ship shelf as structured review before you call a change done or merge it. Duplication at textual, structural, and conceptual levels is a code-quality review problem detected then fixed with verification.
Common Questions / FAQ
Is Indexion Refactor safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Indexion Refactor
# indexion refactor — Codebase Refactoring Detect and eliminate duplication at three levels — textual, structural, and conceptual — using indexion's analysis commands, then verify SoT is enforced. ## When to Use - After adding a new abstraction (type, module, API layer) - After introducing a new file format or I/O boundary - When a fix required touching 3+ files for the same reason - When a "guard" or "skip" was added to work around a structural problem - When `opendir`, `ENOENT`, or similar filesystem errors appear from unexpected paths - When extracting shared code across packages - When cleaning up after a refactor (removing trivial wrapper functions) - Periodic SoT health check on a codebase ## Three Levels of Duplication | Level | What it is | Tool | Example | |-------|-----------|------|---------| | **Textual** | Copy-pasted code blocks, identical functions | `plan refactor` | `is_whitespace` copied across 5 modules | | **Structural** | Same logic structure with different names | `plan solid`, `plan unwrap` | cross-package extraction candidates, trivial wrappers | | **Conceptual** | Same domain concept implemented independently | `explore` + manual analysis | Three modules each deciding "is this file an archive?" | Textual duplication is easy to find and fix. Conceptual duplication is the hardest and most dangerous — it produces no copy-paste matches but means changing one concept requires updating every scattered implementation. ## Workflow ### Phase 1: Clear textual duplication (`plan refactor`) Start with high-confidence matches and work down. ```bash # Step 1: Find 90%+ duplicates (high confidence) indexion plan refactor --threshold=0.9 \ --include='*.mbt' --exclude='*_wbtest.mbt' \ --exclude='*moon.pkg*' --exclude='*pkg.generated*' \ cmd/indexion/ indexion plan refactor --threshold=0.9 \ --include='*.mbt' --exclude='*_wbtest.mbt' \ --exclude='*moon.pkg*' --exclude='*pkg.generated*' \ src/ ``` **Read the output in three sections:** | Section | What it finds | Action | |---------|--------------|--------| | Similar Files | Files with high overall similarity | Investigate for structural consolidation | | Duplicate Code Blocks | Line-level identical code between files | Extract to `@common` or shared module | | Function-Level Duplicates | Structurally similar functions (TF-IDF on bodies) | Unify into single SoT function | **Same-file duplicates** (functions within one file at 90%+) are the highest-value targets — easiest to fix, clearest wins. Example: `get_global_data_dir` and `get_global_cache_dir` share 95% structure, extracted into `resolve_os_dir`. ```bash # Step 2: Use grep to trace references before consolidating indexion grep "TypeIdent:TfidfEmbeddingProvider" src/ indexion grep --semantic=name:is_whitespace src/ # Step 3: Fix, then re-run to confirm duplicates are gone indexion plan refactor --threshold=0.9 --include='*.mbt' ... # Step 4: Lower threshold and iterate indexion plan refactor --threshold=0.85 --include='*.mbt' ... ``` **`plan refactor` options:** | Option | Default | Description | |--------|---------|-------------| | `--threshold=FLOAT` | 0.7 | Minimum similarity threshold | | `--strategy=NAME` | hybrid | Similarity: hybrid, tfidf, bm25, jsd, ncd | | `--fdr=FLOAT` | 0 | FDR correction (0=disabled) | | `--style=STYLE` | raw | Output: raw, structured | | `--format=FORMAT` | md | Output: md, json, text, github-issue | | `--name=NAME` | -- | Project name (for structured style) | | `--include=PATTERN` | -- | Include pattern (repeatable) | | `--exclude=PATTERN` | -- | Exclude pattern (repeatable) | | `-o, --output=FILE` | stdout | Output file path | | `--specs-dir=DIR` | kgfs | KGF specs directory | **What remains after c