ln-831-oss-replacer

Replaces custom modules with OSS packages using atomic keep/discard testing. Use when migrating custom code to established libraries.

310 stars

Best use case

ln-831-oss-replacer is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Replaces custom modules with OSS packages using atomic keep/discard testing. Use when migrating custom code to established libraries.

Teams using ln-831-oss-replacer should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/ln-831-oss-replacer/SKILL.md --create-dirs "https://raw.githubusercontent.com/levnikolaevich/claude-code-skills/main/skills-catalog/ln-831-oss-replacer/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/ln-831-oss-replacer/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How ln-831-oss-replacer Compares

Feature / Agentln-831-oss-replacerStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Replaces custom modules with OSS packages using atomic keep/discard testing. Use when migrating custom code to established libraries.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

> **Paths:** File paths (`shared/`, `references/`, `../ln-*`) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root. If `shared/` is missing, fetch files via WebFetch from `https://raw.githubusercontent.com/levnikolaevich/claude-code-skills/master/skills/{path}`.

# ln-831-oss-replacer

**Type:** L3 Worker
**Category:** 8XX Optimization

Executes OSS replacement plans from ln-645-open-source-replacer auditor. For each custom module with an OSS alternative: install package, rewrite imports, run tests, keep or discard atomically.

---

## Overview

| Aspect | Details |
|--------|---------|
| **Input** | Migration plan from `docs/project/codebase_audit.md` (ln-645 section) OR target module |
| **Output** | Replaced modules, migration report |
| **Companion** | ln-645-open-source-replacer (finds candidates) → ln-831 (executes replacement) |

---

## Workflow

**Phases:** Pre-flight → Load Plan → Prioritize → Replace Loop → Report

---

## Phase 0: Pre-flight Checks

| Check | Required | Action if Missing |
|-------|----------|-------------------|
| Migration plan OR target module | Yes | Block replacement |
| Test infrastructure | Yes | Block (need tests for verification) |
| Package manager available | Yes | Block (need to install OSS packages) |
| Git clean state | Yes | Block (need clean baseline for revert) |

**MANDATORY READ:** Load `shared/references/ci_tool_detection.md` — use Test Frameworks section for test detection.

### Worktree & Branch Isolation

**MANDATORY READ:** Load `shared/references/git_worktree_fallback.md` — use ln-831 row.

---

## Phase 1: Load Migration Plan

### From Audit Report

Read `docs/project/codebase_audit.md`, extract ln-645 findings:

| Field | Description |
|-------|-------------|
| custom_module | Path to custom implementation |
| loc | Lines of code in custom module |
| oss_package | Recommended OSS replacement |
| confidence | How well OSS covers functionality (HIGH/MEDIUM/LOW) |
| api_mapping | Custom function → OSS equivalent |

### From Target Module

If no audit report: analyze target module, search Context7/Ref for OSS alternatives.

**MANDATORY READ:** Load `shared/references/research_tool_fallback.md` for MCP tool chain.

---

## Phase 2: Prioritize Replacements

| Priority | Criteria |
|----------|----------|
| 1 (highest) | HIGH confidence + >200 LOC (max code reduction) |
| 2 | HIGH confidence + 100-200 LOC |
| 3 | MEDIUM confidence + >200 LOC |
| 4 | MEDIUM confidence + 100-200 LOC |
| Skip | LOW confidence (too risky for automated replacement) |

---

## Phase 3: Replace Loop (Keep/Discard)

### Per-Module Cycle

```
FOR each replacement candidate (R1..RN):
  1. INSTALL: Add OSS package
     npm install {package} / dotnet add package / pip install
  2. REWRITE: Update imports + call sites using api_mapping
  3. VERIFY: Run tests
     IF tests FAIL → DISCARD (revert ALL: uninstall package, restore files) → next
  4. TESTS PASS → KEEP
  5. DELETE: Remove old custom module (only after keep)
  6. LOG: Record replacement for report
```

### Stop Conditions (Replace Loop)

| Condition | Action |
|-----------|--------|
| All candidates processed | STOP — proceed to Report |
| 3 consecutive DISCARDs | WARN — "3 replacements failed in a row. Continue?" |
| Test infrastructure breaks (suite itself fails) | STOP — revert all, report last known good state |
| No candidates above confidence threshold | STOP — report "no viable replacements found" |

### Atomic Revert on Discard

| Step | Revert Action |
|------|---------------|
| Package installed | Uninstall: `npm uninstall` / `dotnet remove package` / `pip uninstall` |
| Files modified | `git checkout -- {modified_files}` |
| Lock file changed | `git checkout -- {lock_file}` |

### Safety Rules

| Rule | Description |
|------|-------------|
| One module at a time | Never replace multiple modules simultaneously |
| No API signature changes | Public API of replaced module must stay compatible |
| Tests required | Skip module if no tests cover it (too risky) |
| Confidence gate | Skip LOW confidence replacements |

---

## Phase 4: Report Results

### Report Schema

| Field | Description |
|-------|-------------|
| source | Audit report path or target module |
| candidates_total | Total replacement candidates |
| replacements_applied | Successfully replaced modules |
| replacements_discarded | Failed replacements with reasons |
| replacements_skipped | LOW confidence / no test coverage |
| loc_removed | Total lines of custom code removed |
| packages_added | New OSS packages installed |
| details[] | Per-replacement: module, package, LOC removed |

---

## Configuration

```yaml
Options:
  # Source
  audit_report: "docs/project/codebase_audit.md"
  target_module: ""

  # Confidence
  min_confidence: "MEDIUM"      # MEDIUM | HIGH

  # Verification
  run_tests: true

  # Safety
  require_test_coverage: true   # Skip modules with no tests
  delete_old_module: true       # Delete custom module after successful replacement
```

---

## Error Handling

| Error | Cause | Solution |
|-------|-------|----------|
| Package not found | OSS package name changed | Search Context7/Ref for current name |
| API mismatch | OSS API differs from mapping | Query docs for correct API, attempt fix |
| Circular dependency | New package conflicts | Skip replacement, log as manual |
| No test coverage | Custom module untested | Skip (too risky for automated replacement) |

---

## References

- `../ln-645-open-source-replacer/SKILL.md` (companion: finds candidates)
- `shared/references/ci_tool_detection.md` (test detection)
- `shared/references/research_tool_fallback.md` (MCP tool chain)

---

## Definition of Done

- [ ] Migration plan loaded from audit report or target module analyzed
- [ ] Candidates prioritized by confidence + LOC
- [ ] Each replacement applied atomically: install → rewrite → test → keep/discard
- [ ] Discarded replacements fully reverted (package + files + lock)
- [ ] Kept replacements: old custom module deleted
- [ ] Report returned with candidates total, applied, discarded, LOC removed

---

**Version:** 1.0.0
**Last Updated:** 2026-03-08

Related Skills

ln-645-open-source-replacer

310
from levnikolaevich/claude-code-skills

Discovers custom modules replaceable by OSS, evaluates alternatives (stars, license, CVE), generates migration plan. Use when reducing custom code.

ln-914-community-responder

310
from levnikolaevich/claude-code-skills

Responds to unanswered GitHub discussions and issues with codebase-informed replies. Use when clearing community question backlog.

ln-913-community-debater

310
from levnikolaevich/claude-code-skills

Launches RFC and debate discussions on GitHub. Use when proposing changes that need community input or voting.

ln-912-community-announcer

310
from levnikolaevich/claude-code-skills

Composes and publishes announcements to GitHub Discussions. Use when sharing releases, updates, or news with the community.

ln-911-github-triager

310
from levnikolaevich/claude-code-skills

Produces prioritized triage report from open GitHub issues, PRs, and discussions. Use when reviewing community backlog.

ln-910-community-engagement

310
from levnikolaevich/claude-code-skills

Analyzes community health and delegates engagement tasks. Use when managing GitHub issues, discussions, and announcements.

ln-840-benchmark-compare

310
from levnikolaevich/claude-code-skills

Runs built-in vs hex-line benchmark with scenario manifests, activation checks, and diff-based correctness. Use when measuring hex-line MCP performance against built-in tools.

ln-832-bundle-optimizer

310
from levnikolaevich/claude-code-skills

Reduces JS/TS bundle size via tree-shaking, code splitting, and unused dependency removal. Use when optimizing frontend bundle size.

ln-830-code-modernization-coordinator

310
from levnikolaevich/claude-code-skills

Modernizes codebase via OSS replacement and bundle optimization. Use when acting on audit findings to reduce custom code.

ln-823-pip-upgrader

310
from levnikolaevich/claude-code-skills

Upgrades Python pip/poetry/pipenv dependencies with breaking change handling. Use when updating Python dependencies.

ln-822-nuget-upgrader

310
from levnikolaevich/claude-code-skills

Upgrades .NET NuGet packages with breaking change handling. Use when updating .NET dependencies.

ln-821-npm-upgrader

310
from levnikolaevich/claude-code-skills

Upgrades npm/yarn/pnpm dependencies with breaking change handling. Use when updating JavaScript/TypeScript dependencies.