Home / Market / repo native refactor

repo native refactor

Review diffs without editing, or perform evidence-based cleanup while preserving authorized behavior, public contracts, and domain ownership.

skill★ 508090 dlgithubCC-BY-4.0 content; MIT code; upstream exceptions applyInstall in CosmosUpstream Source

Documentation & Preview

--- name: repo-native-refactor description: "Review diffs without editing, or perform evidence-based cleanup while preserving authorized behavior, public contracts, and domain ownership." category: development risk: critical source: https://github.com/Natchannnn/repository-engineering-skills source_repo: Natchannnn/repository-engineering-skills source_type: community date_added: "2026-09-30" author: Natchannnn tags: [repository-engineering, code-review, refactoring, public-contracts] tools: [codex] license: MIT license_source: https://github.com/Natchannnn/repository-engineering-skills/blob/e55b378158d5134a77af3b8dace4a2a1b17e41e2/LICENSE metadata: version: "0.3.0" license: "MIT"

---

Repo-native refactor

When to Use

Produce the smallest coherent change that belongs naturally in the target repository.

Prioritize in order:

  1. Correctness and security: prevent regressions, avoid new security vulnerabilities, handle boundary conditions.
  2. Semantic integrity: preserve existing invariants, state transitions, validation, and error boundaries.
  3. Contracts stay as declared: the rule lives in references/shared-contracts.md §1. Preserve the authorized target contract; otherwise keep exact declared types. Internal helpers are fine when exposed contracts stay exact.
  4. Repository conformity: match surrounding naming, domain conventions, and architectural precedents.
  5. Economy and simplicity: minimal intervention. Delete dead weight, avoid premature abstractions.

This is a post-implementation audit and small cleanup skill. It is not permission to redesign the repository. Establish a concrete consequence such as inconsistent behavior, duplicated policy that must change together, unclear ownership, avoidable resource cost, or a demonstrated maintenance obstacle. Leave healthy code unchanged when the benefit is speculative.

---

Minimal intervention and evidence gate

---

Operating modes

---

Evidence hierarchy

Use the evidence hierarchy to guide investigation, not to resolve material contradictions automatically. Reconcile conflicting requirements, documentation, callers, and tests before changing the affected contract. When repository patterns conflict, resolve in order:

  1. User requirements and explicitly authorized scope.
  2. Documented architecture and repository guidelines.
  3. Observable public contracts and persisted schemas.
  4. Healthy sibling code within the same domain and runtime boundary.
  5. Relevant tests, schemas, callers, and dependencies.
  6. Dominant local conventions.
  7. Language and runtime idioms.
  8. Conservative, idiomatic defaults.

Never treat a temporary workaround, buggy sibling, or accidental pattern as precedent.

---

Workflow

1. Establish scope and baseline

Before mutating code, identify:

Differentiate pre-existing failures from regressions introduced by this pass. Never claim a check ran when it did not.

2. Establish intent, ownership, and preservation

Refactoring is behavior-preserving by default. Protect:

If a bug requires an observable change, classify and report it as an intentional behavioral correction rather than routine cleanup.

3. Inventory findings before rewriting

Inspect the authorized scope for:

Read finding taxonomy for complex cases. Establish the smallest adequate correction before editing.

4. Classify risk and refactor

Risk bands:

Read semantic risk for R2+ changes. Never mass-rewrite R3 or R4 behavior without explicit instructions and verified tests.

5. Audit code prose

6. Verify and review

---

Reference routing

Read supporting references only when the corresponding trigger occurs:

---

Hard stops

Do not force a refactor where intent, ownership, public-contract consequences, migration semantics, or concurrency behavior cannot be established. Do not guess between conflicting architectural patterns without evidence.

---

Completion Report

Scale the completion report to the change. Omit empty sections. Format completion concisely:

Result

Use one: Verified, Verified with caveats, Needs review, or Failed verification.

For review-only requests, an empty findings list is a complete result, not an embarrassing one. Never manufacture findings to fill a report: each reported finding needs a producer, a consumer, and an observed consequence, or it is not reported.

Changed

Summarize material corrections by file and function.

Preserved intentionally

Note specific patterns or contracts deliberately retained to avoid breaking downstream consumers.

Verification

List exact verification commands executed and their outcomes.

Residual uncertainty

Document unresolved limitations or high-risk boundaries intentionally deferred.

---

Examples

Review without editing

Use repo-native-refactor to review this branch against main for public-contract
breaks and retry failures. Do not edit source files. Report only findings with
a concrete producer, consumer, and observable consequence.

Inspect the comparison base and relevant callers, run proportionate verification, and report evidence-backed findings. An empty findings list is a valid result.

Consolidate one owned policy

Use repo-native-refactor to consolidate the duplicated eligibility checks owned
by this billing module. Preserve the current accepted inputs, error types, and
return values. Leave similar checks in other domains alone and run the module's tests.

Confirm that the copies share an owner, invariant, and reason to change before extracting anything. Keep the correction bounded and verify the final behavior.

Limitations

Security & Safety Notes

Review-only mode permits inspection and verification without source edits. The authorized cleanup mode can modify source files, so the declared risk is critical under this collection's state-modification classification. Keep edits within the user's authorized scope, preserve unrelated user changes, and apply the R3/R4 verification and stop conditions before changing sensitive behavior. Clea