From refactor
Execute recursive, dependency-aware context modularization and traversal for any code or document corpus. Use when you need to atomize context, classify and interconnect concepts, infer constraints and dependencies, create bridge files/symlinks/hyperedges, and produce a refined directed acyclic dependency model with progressive confidence gating.
How this skill is triggered — by the user, by Claude, or both
Slash command
/refactor:refactorThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill provides a standalone best-practice pipeline for turning an undifferentiated context surface into a compact modular graph. It is designed for context-engineering workflows, repo rewrites, architecture consolidation, and knowledge-base triage where semantic structure and dependency correctness matter more than cosmetic refactoring.
This skill provides a standalone best-practice pipeline for turning an undifferentiated context surface into a compact modular graph. It is designed for context-engineering workflows, repo rewrites, architecture consolidation, and knowledge-base triage where semantic structure and dependency correctness matter more than cosmetic refactoring.
The process is recursive. It keeps extracting structure, decomposing modules, creating bridges between distant but constrained dependencies, and re-running until a quality threshold is reached.
Use this skill in two modes:
analysis to map and score the current state of context.orchestration to map, refactor, and emit the final index.In both modes, the same primitives apply:
Use when the request contains any of:
0.95).The orchestrated output defaults to:
index.md main entry point and formal traversal order.state.json run state, thresholds, and convergence summary.modules/<module-id>/README.md module boundaries and local interfaces.modules/<module-id>/atoms.json canonical atoms for that module.modules/<module-id>/files.md linked source members.bridges/<a>__<b>.md cross-module bridge files.bridges/symlinks/<module-id>/ optional symlink views.graph.json full graph dump and computed metrics.atlas.jsonl serialized thoughtbox states per recursion epoch.If a repo style requires a different layout, mirror these artifacts with equivalent semantic roles.
The bundled script is intended to be copied/adapted into any workspace:
/Users/mikhail/Projects/Context-Engineering/Distil/refactor/scripts/rlm_orchestrator.pyUse this as the default execution engine. It has zero mandatory third-party dependencies.
For every file/segment:
Maintain a persistent per-pass state object:
observations: discovered constraints, naming conventions, domain-specific terms.assumptions: inferred links without high confidence.decisions: hard commitments and rationale.risks: cycle candidates, overloaded modules, low-confidence merges.open_questions: unresolved semantic ambiguity requiring explicit arbitration.The thoughtbox object is always written to disk each recursion iteration so the process is auditable.
Build two edge sets:
Store edge strength as floating scores in [0,1].
Use these rules recursively for each module:
For distanced but important edges:
Do not convert every weak edge to bridge. Reserve bridges for semantically dense relations that are:
Run a Markov-chain traversal where probability mass moves along dependency direction. Converge on a confidence measure across nodes and modules.
Stop when:
global_confidence >= configured target (default 0.95), ormax_iterations reached,Emit index.md with:
Default:
python3 scripts/rlm_orchestrator.py \
--input /path/to/context \
--output .rlm-out \
--max-depth 4 \
--min-similarity 0.05 \
--target-confidence 0.95 \
--include-dot-git false
For audit-only pass:
python3 scripts/rlm_orchestrator.py --input . --output .rlm-out --mode analysis
Important:
analysis before destructive file moves.Abort and revise if any of these are true:
manual_decision_required flag./Users/mikhail/Projects/Context-Engineering/Distil/refactor/scripts/rlm_orchestrator.py is the implementation core./Users/mikhail/Projects/Context-Engineering/Distil/refactor/references/process-model.md explains the conceptual mapping./Users/mikhail/Projects/Context-Engineering/Distil/refactor/references/ulcb1-tree-search.md explains recursive stopping criteria.The skill run is complete when the agent can answer:
Only then should the pipeline emit its final index and confidence summary.
graph.json carries a strict contract: schema_version, run, modules, bridges, cycles, graph, topological_order, epochs, confidence, target_confidence, selected_epoch, status, thoughtbox.run is a compact machine control surface: thresholds, recursion limits, and bridge policy.epochs is the closed-loop audit trail for recursive refinement (with epoch state and transition status).module_id, label, members, members_countcohesion, atom_densityoutgoing_dependencies, incoming_dependenciesontology with core_terms, properties, cardinalitybridge_refsbridge_id, source_module, target_module, strengthnotes, justification, bridge_fileanalysis mode first, then orchestration.graph.json, index.md, state.json, atlas.jsonl, modules/*, bridges/*.epochs[].min_similarity should show adjustment when target is not met),selected_epoch is selected by confidence progression and structural stability.core_terms[].member_coverage and properties[].supporting_members,support and bridge_file coherence.analysis mode,max_bridges,selected_epoch >= 1confidence should monotonically improve or stabilize across final statemodules entries satisfy required keys and typesbridges entries include pathable bridge_filetopological_order only contains known module identifiersno-source status/Users/mikhail/Projects/Context-Engineering/Distil/refactor/references/ontology-schema.md for schema details./Users/mikhail/Projects/Context-Engineering/Distil/refactor/references/process-model.md for the conceptual model./Users/mikhail/Projects/Context-Engineering/Distil/refactor/references/ulcb1-tree-search.md for recursive control and stopping conditions.npx claudepluginhub zpankz/refactor --plugin refactorDecompose projects or tracks into modules with dependency mapping. Updates architecture.md and generates HLD/LLD artifacts to drive implement, deploy-checklist, and upload sign-off workflows.
Renames, extracts, splits, moves, or restructures code safely using graph-aware impact analysis and automated rename tools. Covers checklists for each refactoring type.
Scans codebase and generates high-level architecture graph as interlinked markdown files in docs/professor/architecture/. Use for new project analysis or significant changes.