重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
ln-831-oss-replacer by levnikolaevich/claude-code-skills
npx skills add https://github.com/levnikolaevich/claude-code-skills --skill ln-831-oss-replacer路径说明: 文件路径(
shared/、references/、../ln-*)是相对于技能仓库根目录的。如果在当前工作目录未找到,请定位此 SKILL.md 文件所在目录并向上返回一级以找到仓库根目录。如果缺少shared/目录,请通过 WebFetch 从https://raw.githubusercontent.com/levnikolaevich/claude-code-skills/master/skills/{path}获取文件。
类型: L3 工作者 类别: 8XX 优化 父级: ln-830-code-modernization-coordinator
执行来自 ln-645-open-source-replacer 审计器的 OSS 替换计划。对于每个具有 OSS 替代方案的自定义模块:安装包、重写导入、运行测试、以原子方式保留或丢弃。
| 方面 | 详情 |
|---|---|
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 输入 |
来自 docs/project/codebase_audit.md(ln-645 部分)的迁移计划 或 目标模块 |
| 输出 | 已替换的模块、迁移报告 |
| 伴随技能 | ln-645-open-source-replacer(寻找候选) → ln-831(执行替换) |
阶段: 预检 → 加载计划 → 优先级排序 → 替换循环 → 报告
| 检查项 | 是否必需 | 缺失时的操作 |
|---|---|---|
| 迁移计划 或 目标模块 | 是 | 阻止替换 |
| 测试基础设施 | 是 | 阻止(需要测试进行验证) |
| 包管理器可用 | 是 | 阻止(需要安装 OSS 包) |
| Git 状态干净 | 是 | 阻止(需要干净的基线用于回滚) |
必读: 加载 shared/references/ci_tool_detection.md — 使用“测试框架”部分进行测试检测。
必读: 加载 shared/references/git_worktree_fallback.md — 使用 ln-831 行。
读取 docs/project/codebase_audit.md,提取 ln-645 的发现:
| 字段 | 描述 |
|---|---|
| custom_module | 自定义实现的路径 |
| loc | 自定义模块中的代码行数 |
| oss_package | 推荐的 OSS 替代包 |
| confidence | OSS 覆盖功能的程度(高/中/低) |
| api_mapping | 自定义函数 → OSS 等效函数 |
如果没有审计报告:分析目标模块,在 Context7/Ref 中搜索 OSS 替代方案。
必读: 加载 shared/references/research_tool_fallback.md 以获取 MCP 工具链。
| 优先级 | 标准 |
|---|---|
| 1(最高) | 高置信度 + >200 行代码(最大代码缩减) |
| 2 | 高置信度 + 100-200 行代码 |
| 3 | 中置信度 + >200 行代码 |
| 4 | 中置信度 + 100-200 行代码 |
| 跳过 | 低置信度(自动化替换风险过高) |
FOR each replacement candidate (R1..RN):
1. INSTALL: 添加 OSS 包
npm install {package} / dotnet add package / pip install
2. REWRITE: 使用 api_mapping 更新导入和调用点
3. VERIFY: 运行测试
IF tests FAIL → DISCARD(回滚所有:卸载包,恢复文件)→ 下一个
4. TESTS PASS → KEEP
5. DELETE: 删除旧的自定义模块(仅在保留后执行)
6. LOG: 记录替换以供报告
| 条件 | 操作 |
|---|---|
| 所有候选处理完毕 | 停止 — 进入报告阶段 |
| 连续 3 次丢弃 | 警告 — "连续 3 次替换失败。是否继续?" |
| 测试基础设施中断(测试套件本身失败) | 停止 — 回滚所有更改,报告最后已知的良好状态 |
| 没有高于置信度阈值的候选 | 停止 — 报告"未找到可行的替换方案" |
| 步骤 | 回滚操作 |
|---|---|
| 已安装包 | 卸载:npm uninstall / dotnet remove package / pip uninstall |
| 已修改文件 | git checkout -- {modified_files} |
| 锁定文件已更改 | git checkout -- {lock_file} |
| 规则 | 描述 |
|---|---|
| 一次一个模块 | 切勿同时替换多个模块 |
| 无 API 签名更改 | 被替换模块的公共 API 必须保持兼容 |
| 需要测试 | 如果没有测试覆盖该模块,则跳过(风险过高) |
| 置信度门槛 | 跳过低置信度的替换 |
| 字段 | 描述 |
|---|---|
| source | 审计报告路径或目标模块 |
| candidates_total | 替换候选总数 |
| replacements_applied | 成功替换的模块数 |
| replacements_discarded | 失败的替换及原因 |
| replacements_skipped | 低置信度 / 无测试覆盖 |
| loc_removed | 移除的自定义代码总行数 |
| packages_added | 安装的新 OSS 包 |
| details[] | 每次替换的详情:模块、包、移除的代码行数 |
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
| 错误 | 原因 | 解决方案 |
|---|---|---|
| 包未找到 | OSS 包名称已更改 | 在 Context7/Ref 中搜索当前名称 |
| API 不匹配 | OSS API 与映射不同 | 查询文档以获取正确的 API,尝试修复 |
| 循环依赖 | 新包存在冲突 | 跳过替换,记录为手动操作 |
| 无测试覆盖 | 自定义模块未经测试 | 跳过(自动化替换风险过高) |
../ln-645-open-source-replacer/SKILL.md(伴随技能:寻找候选)shared/references/ci_tool_detection.md(测试检测)shared/references/research_tool_fallback.md(MCP 工具链)版本: 1.0.0 最后更新: 2026-03-08
每周安装数
72
仓库
GitHub 星标数
245
首次出现
2026年3月8日
安全审计
安装于
cursor69
github-copilot68
codex68
gemini-cli68
claude-code68
amp68
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. Ifshared/is missing, fetch files via WebFetch fromhttps://raw.githubusercontent.com/levnikolaevich/claude-code-skills/master/skills/{path}.
Type: L3 Worker Category: 8XX Optimization Parent: ln-830-code-modernization-coordinator
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.
| 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) |
Phases: Pre-flight → Load Plan → Prioritize → Replace Loop → Report
| 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.
MANDATORY READ: Load shared/references/git_worktree_fallback.md — use ln-831 row.
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 |
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.
| 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) |
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
| 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" |
| 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} |
| 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 |
| 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 |
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 | 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) |
../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)Version: 1.0.0 Last Updated: 2026-03-08
Weekly Installs
72
Repository
GitHub Stars
245
First Seen
Mar 8, 2026
Security Audits
Gen Agent Trust HubPassSocketWarnSnykWarn
Installed on
cursor69
github-copilot68
codex68
gemini-cli68
claude-code68
amp68
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
52,700 周安装