mcpField
L
ln-831-oss-replacer

ln-831-oss-replacer

github.com/levnikolaevichDevelopment584220 installsUpdated 2d ago
Repository

About ln-831-oss-replacer

ln-831-oss-replacer is a skill for applying planned replacements of custom modules with open-source packages. It updates imports, verifies each change with tests, and reverts failed candidates atomically.

Key features

  1. 01Prioritizes candidates by confidence and code size
  2. 02Installs packages and rewrites imports
  3. 03Verifies replacements with tests
  4. 04Atomically reverts failed changes
  5. 05Produces a modernization summary

Use cases

  1. 01Apply viable replacements from an audit plan
  2. 02Evaluate an individual module for replacement
  3. 03Reduce custom code while preserving tested behavior

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/levnikolaevich/claude-code-skills --skill ln-831-oss-replacer

After installing, type/ln-831-oss-replacerin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
ci_tool_detection.md
coordinator_summary_contract.md
epistemic_protocol.md
mcp_integration_patterns.md
mcp_tool_preferences.md
research_tool_fallback.md

Details

From the project README

Paths: File paths (references/, ../ln-*) are relative to this skill directory.

ln-831-oss-replacer

Type: L3 Worker Category: 8XX Optimization

Executes OSS replacement plans from ln-645-architecture-modernization-auditor. For each custom module with a viable OSS alternative: install package, rewrite imports, run verification, then keep or discard atomically.


Overview

AspectDetails
InputMigration plan from audit output or a target module
OutputReplaced modules plus a machine-readable modernization summary
Companionln-645-architecture-modernization-auditor identifies candidates, ln-831 executes them

Workflow

Phases: Pre-flight -> Load Plan -> Prioritize -> Replace Loop -> Report


Phase 0: Pre-flight Checks

CheckRequiredAction if Missing
Migration plan or target moduleYesBlock replacement
Test infrastructureYesBlock replacement
Package manager availableYesBlock replacement
Workspace baseline safeYesIn managed runs coordinator already prepared it; in standalone runs protect rollback locally

MANDATORY READ: Load references/ci_tool_detection.md for test detection. Tool policy: follow host AGENTS.md MCP preferences; load references/mcp_tool_preferences.md and references/mcp_integration_patterns.md only when host policy is absent or MCP behavior is unclear.

Use hex-line first for local code edits and reads when available, and use hex-graph first when cross-file reference checks materially improve replacement safety. If MCP is unavailable, unsupported, or not indexed, continue with built-in Read/Grep/Glob/Bash and state the fallback in the summary.

Runtime Coordination

Managed runs receive deterministic runId and exact summaryArtifactPath from ln-830. Standalone runs remain supported; if runtime arguments are omitted, generate a standalone run-scoped artifact before returning.


Phase 1: Load Migration Plan

From audit report, extract:

FieldDescription
custom_modulePath to the custom implementation
locLines of code in the custom module
oss_packageRecommended OSS replacement
confidenceHIGH, MEDIUM, or LOW
api_mappingCustom function to OSS equivalent

If no audit report exists, analyze the target module and search Context7 or Ref for viable OSS alternatives.

MANDATORY READ: Load references/research_tool_fallback.md


Phase 2: Prioritize Replacements

PriorityCriteria
1HIGH confidence and >200 LOC
2HIGH confidence and 100-200 LOC
3MEDIUM confidence and >200 LOC
4MEDIUM confidence and 100-200 LOC
SkipLOW confidence

Phase 3: Replace Loop (Keep/Discard)

Per-module cycle:

FOR each replacement candidate:
  1. INSTALL: add the OSS package
  2. REWRITE: update imports and call sites using api_mapping
  3. VERIFY: run tests
     IF tests fail -> DISCARD and revert all changes for this candidate
  4. KEEP: only after verification passes
  5. DELETE: remove old custom module after keep
  6. LOG: record result for the final report

Stop conditions:

ConditionAction
All candidates processedStop and report
3 consecutive discardsWarn and stop for manual review
Test infrastructure itself breaksStop and revert to last known good state
No candidates above confidence thresholdStop and report no viable replacements

Atomic revert on discard:

StepRevert Action
Package installedUninstall it
Files modifiedRestore module files
Lock file changedRestore lock file

Safety rules:

RuleDescription
One module at a timeNever replace multiple modules simultaneously
No API signature driftPublic interfaces must stay compatible
Tests requiredSkip modules with no coverage when risk is unclear
Confidence gateSkip LOW-confidence replacements

Phase 4: Report Results

FieldDescription
sourceAudit report path or target module
candidates_totalTotal replacement candidates
replacements_appliedSuccessfully replaced modules
replacements_discardedFailed replacements with reasons
replacements_skippedSkipped due to low confidence or missing tests
loc_removedTotal lines of custom code removed
packages_addedNew OSS packages installed
details[]Per replacement summary
artifact_pathDurable worker report path, if written

Configuration

Options:
  audit_report: "docs/project/codebase_audit.md"
  target_module: ""
  min_confidence: "MEDIUM"
  run_tests: true
  require_test_coverage: true
  delete_old_module: true

Error Handling

ErrorCauseSolution
Package not foundOSS package name changedSearch current docs for the new package name
API mismatchMapping differs from real library APIQuery docs and retry only if fix is clear
Circular dependencyNew package conflicts with current architectureSkip and report manual follow-up
No test coverageToo risky for automated replacementSkip and report

References

  • ../ln-645-architecture-modernization-auditor/SKILL.md
  • references/ci_tool_detection.md
  • references/research_tool_fallback.md
  • references/epistemic_protocol.md

Runtime Summary Artifact

MANDATORY READ: Load references/coordinator_summary_contract.md

Emit a modernization-worker summary envelope.

Managed mode:

  • ln-830 passes deterministic runId and exact summaryArtifactPath
  • write the summary to the provided summaryArtifactPath

Standalone mode:

  • omit runId and summaryArtifactPath
  • write .hex-skills/runtime-artifacts/runs/{run_id}/modernization-worker/ln-831--{identifier}.json

Monitor (2.1.98+): For install + test verification loops expected >30s, use Monitor. Fallback: Bash(run_in_background=true).

Definition of Done

  • Migration plan loaded or target module analyzed
  • Candidates prioritized by confidence and code-reduction value
  • Each replacement executed atomically with keep/discard verification
  • Discarded replacements fully reverted
  • Kept replacements remove old custom code only after verification passes
  • Report captures applied, discarded, skipped replacements, and LOC removed
  • modernization-worker summary artifact written to the managed or standalone path

Version: 1.0.0 Last Updated: 2026-03-08

Comments

Markdown supported