codex/skills/simplify-and-refactor-code-isomorphically/SKILL.md
Run a proof-heavy simplification campaign that factors code, classifies duplication, quotients proven-equivalent distinctions, ablates redundant surface, and normalizes the survivors. Use when simplification must preserve a declared observation set or exact structure. This skill treats isomorphism as an optional strict preservation relation, not as the reduction objective. Route intentional contractions of obsolete, invalid, or legacy behavior to `reduce` or `resolve` under a refinement-preserving contract.
npx skillsauth add tkersey/dotfiles simplify-and-refactor-code-isomorphicallyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Shrink and unify code under an explicit preservation relation.
FACTORING
-> QUOTIENTING
-> ABLATIVE
-> NORMALIZING
The reduction operators decide what disappears. The preservation relation decides what must remain.
Choose before editing:
isomorphic: reversible structure-preserving correspondence.observationally-equivalent: all declared external observations remain equal.refinement-preserving: all required behavior remains while invalid, obsolete, duplicated, or unrequired behavior may disappear.intentional-contract-change: approved behavior change.Default this skill to observationally-equivalent. Use isomorphic only when reversible structure matters. If the goal intentionally contracts behavior, route to reduce or resolve.
Select the reduction candidate.
Declare the preservation relation.
Prove it.
Then remove surface.
No proof -> no reduction.
1. BASELINE -> tests, typecheck/lints, representative observations, surface snapshot
2. FACTOR -> obligations, owners, callsites, state/effect factors
3. CLASSIFY -> clone type, live obligation, dominance, risk
4. QUOTIENT -> equivalence relation and congruence checks
5. PROVE -> preservation card before editing
6. ABLATE -> one certified lever per patch group
7. NORMALIZE -> canonical owner/representation/path
8. VERIFY -> declared observations, tests, types, lints, surface delta
9. RECOMPOSE -> prove every live obligation remains covered
10. LEDGER -> RC-v1 and rejection log
11. REPEAT -> rescan only if new candidates appear
Each phase must leave an artifact. A “cleaner” claim without evidence is not a simplification result.
Before editing:
Do not require bit-identical output when the declared contract is weaker. Do not claim equivalence outside the declared observation set.
Use exactly one:
exact-cloneparametric-clonegapped-clonesemantic-cloneaccidental-rhymeRules:
0 copy-paste
1 local function
2 parameterized function
3 enum/strategy over bounded variance
4 interface/trait for open implementors
5 generic abstraction
6 DSL/macro
Do not skip rungs. One case is unique; two may be coincidence; three may be a pattern. One axis of variance per rung. If variance exceeds shape, keep the factors separate.
Reduction Score =
(semantic_surface_removed × confidence × ownership_clarity)
/ risk
Do not chase reductions whose coupling or proof cost exceeds the removed surface.
preservation_card:
candidate_id: "..."
reduction_operator: factor | quotient | ablate | normalize
preservation_relation: isomorphic | observationally-equivalent
inputs_and_callsites: []
observation_set: []
ordering_preserved:
tie_breaking_preserved:
error_semantics_preserved:
laziness_and_short_circuit_preserved:
floating_point_rng_hash_order_preserved:
side_effect_order_and_payload_preserved:
type_narrowing_preserved:
UI_rerender_or_lifecycle_preserved:
quotient_congruence_checks: []
proof_commands: []
status: pass | validate-first | fail | blocked
For non-applicable axes, say not-applicable; do not silently omit material axes.
Every implemented patch group emits RC-v1 from reduction-certificate.md.
Required:
_v2, _new, _old, or _improved surfaces;Examples:
delete dead branch
collapse wrapper chain
quotient duplicate state variants
canonicalize one owner
retire flag
replace repeated boilerplate
Do not combine unrelated reductions unless they are one factorization/recomposition move.
Run:
A green test suite alone does not prove isomorphism or observational equivalence.
Route to:
complexity-mitigator for read-only local comprehension;reduce for broad architectural winnowing or refinement-preserving contraction;review-compression-compiler / resolve for behavioral quotienting driven by review observations;fixed-point-driver to realize an already-certified normal form;universalist when reduction reveals missing essential structure.End with:
Reduction Bottom Line:
- factors:
- quotient:
- ablation:
- normal form:
- preservation relation:
- proof:
- recomposition:
- surface delta:
- next:
tools
Invokes Apple's macOS 27 fm command-line tool from a local Mac to use the on-device system model or Private Cloud Compute, including instructions, image prompts, schema-constrained JSON, and noninteractive automation. Use when the user asks to run Apple Foundation Models through fm, compare system versus pcc, generate structured output, or automate fm without Swift or an app.
development
Compile historical Codex sessions into governed counterfactual evidence, evaluate an existing owner-applied candidate through blinded paired HCTP trials, and fold observable evidence into RUN, OBSERVE, or STOP. Use for `$hylo`, CRF extraction, counterfactual replay, source-governed direct or historical trials, sealed evidence, paired baseline/candidate evaluation, causal frontiers, or evidence-governed improvement.
testing
Ensure a `ledger` command is available on PATH; materialize, validate, record, replay, and project requested Actuating artifacts without taking semantic or execution authority; coordinate the shared Learnings/Synesthesia/Negative Ledger lifecycle checkpoint and repo-local source-memory reconciliation; address Universalist plans and receipts; and perform pure artifact validation.
testing
Classify and quotient review findings, failing tests, incidents, bug reports, migration failures, and other witnessed falsifiers against accepted intent and the current Construction. Author counterexample-set/v1 without selecting repairs, counting review credit, or granting mutation.