通过实际操作产品验证交付内容,记录用户可查看的证据,并发布验收报告。可检查已有验证计划或创建检查项,选择合适的操作界面,并使用 `lh` CLI 发布结果。
- 实际检查更改后的产品行为
- 收集截图或其他验证证据
- 编写验证计划和报告
本技能指导你先为现有行为编写特征测试,再把超过 1200 行的源文件拆成职责清晰的模块,保留原有行为、公开导入路径和导出名称,并通过测试验证。
Refactor a source file over 1200 lines into a directory of cohesive modules without changing behavior, test-first. Use when asked to split, decompose, or shrink a large file (拆分大文件, 拆文件, 重构大文件); with no file given, pick one.
实测评分 未实测
查看安装方法本技能介绍如何以测试优先的方式拆分大型源文件,在不改变行为的前提下整理成职责清晰的模块。首先阅读目标文件及其测试,查找拆分边界和所有引用,并规划目录结构;随后添加用于记录现有行为的测试,再移动文件和测试,逐个提取模块。整个过程要保留公开导入路径和导出名称,使拆分后的每个文件不超过 1200 行,并按场景整理测试,最后验证改动。
已确定要拆分哪个文件时可以使用;如果没有指定文件,也可以让技能从超长文件中选择候选。它适用于依据可观察行为、状态或处理阶段进行重构,而不是单纯按行数切开文件。
先参考 source-layout 了解文件放置和命名规则。拆分时发现的缺陷应作为单独改动处理。
本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。
AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。
不计入评分。 由 AI(OpenAI Codex)于 2026年10月26日 评估。仅供参考,安装前请同时查看原文。
安装前可以查看交给 AI 代理的指令内容。
Split one file into a directory of modules without changing behavior. Where the pieces go, what they are named, and where tests live are owned by source-layout; read it first. This skill owns the procedure: lock behavior with tests, move, extract, then split the tests.
The split changes no behavior. If you find a bug on the way, note it and fix it in a separate commit or PR after the split.
Given a file, use it. Otherwise build a shortlist:
git ls-files -z -- 'src/*.ts' 'src/*.tsx' 'apps/*.ts' 'apps/*.tsx' 'packages/*.ts' 'packages/*.tsx' \
| rg --null-data -v '(^|/)(__tests__|__mocks__|fixtures|locales)/|\.(test|spec)\.|\.d\.ts$' \
| xargs -0 wc -l | awk '$1 > 1200 && $NF != "total"' | sort -rn | head -30
The shortlist still contains data tables and generated code; filter it by reading. Prefer a file with:
testing requires for models), not one that needs a browser session or live third-party calls.Use recent churn (git log --since=3.months --oneline -- <file> | wc -l) only to break ties. State the choice and the reason before starting.
Read the whole file and its tests. Find every reference with rg on the module path and basename across source roots: imports, re-exports, dynamic import(), vi.mock('…/Foo'), explicit extensions, and package entry mappings.
Write a short plan before editing:
react and source-layout §3) and the module each becomes;source-layout §4, with expected line counts;When a boundary or layout decision is unclear, ask an independent reviewer (a different-vendor harness when available) to critique the plan.
Existing tests usually cover the happy path and miss the branches a split is most likely to break. Before editing, record the baseline commit and the original path, then:
source-layout §2): first extract the branch selection into a pure function or hook as a mechanical step that keeps every rendered output, then pin that function in .test.ts; existing component tests must pass before and after the extraction. Name the state or mock that reaches each branch. Prefer one table test (it.each) with expected values written out; inline snapshots do not work inside it.each.git show <baseline>:<path> > <dir>/<Name>Original.ts), point the test import at it, run, then point it back and delete only that copy.if condition false), confirm a named test fails, undo exactly that edit, and confirm the test passes again. One mutation shows the tests are sensitive, not that coverage is complete.Behavior the split moves unchanged and that had no test before stays "uncovered before and after"; say so in the PR instead of claiming it is guarded.
Skip this step when the file is already a directory entry (foo/index.ts); extract siblings beside it instead. Otherwise move the file and its tests together: mkdir -p Foo && git mv Foo.tsx Foo/index.tsx (git mv does not create the directory, and Foo/ may already exist), then move each matching test keeping its extension (Foo.test.tsx → Foo/index.test.tsx, Foo.<scenario>.test.ts → Foo/index.<scenario>.test.ts). Rewrite only relative module specifiers in imports, vi.mock, and dynamic imports; run the tests by explicit path, and commit. Large extraction in the same commit lowers content similarity until Git stops detecting the rename. A separate move commit keeps the extraction diff reviewable on its own; a squash merge folds both commits together.
Extract one boundary at a time and rerun the guard tests by explicit path after each:
utils.ts (or a named module) with explicit parameters instead of closures over component state.useXxx.ts when transitions, side effects, or handlers obscure rendering or form a reusable unit; otherwise keep state in its smallest owner (react). For services, routers, and stores, use the matching row of source-layout §4.constants.ts.Keep the public import path and exported names unchanged so callers do not change. Every resulting file must be at most 1200 lines, and the entry should read as composition, not logic.
When the test file is large or covers distinct scenarios, split it by scenario (index.render.test.ts, index.actions.test.ts, …; keep .tsx when the tests contain JSX) with shared mocks in testUtils.ts, as source-layout §2 describes.
Preserve every observable behavior the old suite asserted. Remove a test or assertion only when it duplicates a named retained test, is coupled to implementation details (testing lists these), or checks an expectation that is demonstrably obsolete; record each removal and its replacement or evidence in the PR. Merge near-identical tests into it.each, and drop mock branches and translation keys nothing renders.
find <dir> -type f -exec wc -l {} + | sort -rn # every file ≤ 800, nested folders included
bun run check <every changed source file> <every guard test file> --lint --test --type
Pass the test files explicitly: related-test discovery finds only <name>.test.* and <name>.<scenario>.test.* of each changed file, so tests that guard an extracted sibling through the entry (index.*.test.ts for usePlanActions.ts) run only when passed. Confirm the reported test count matches the suites you expect.
Then follow the normal task lifecycle: a light deep-review (suggest Deep when the file is on a high-risk surface such as billing or auth), commit, and pr. A pure split needs no product acceptance; state that reason in the PR body together with:
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
通过实际操作产品验证交付内容,记录用户可查看的证据,并发布验收报告。可检查已有验证计划或创建检查项,选择合适的操作界面,并使用 `lh` CLI 发布结果。
本技能指导在 LobeHub 中接入 AI 模型提供商,涵盖运行时、模型信息、设置、品牌展示、文档和验收,并帮助判断新增模型是否需要新的提供商集成。
本技能指导如何用服务器端环境变量设置用户偏好默认值,涵盖变量校验、服务器配置、写入用户状态,以及更新 `.env.example` 和自托管文档。
说明如何在智能体执行步骤、工具调用、人工审批、上下文压缩和子智能体调用时注册钩子。钩子可观察事件、模拟本地工具结果,也可通过 Webhook 按配置策略允许或拒绝工具调用。
此技能用于为智能体设计事件驱动的后台工作流,划分来源、信号、动作和策略的职责,并处理异步交接、去重、执行范围、完成记录与运行观测。
本技能在 macOS 桌面聊天应用中测试机器人频道:打开应用、进入频道或联系人、发送消息、等待回复并截图。支持 Discord、Slack、Telegram、微信、飞书和 QQ;iMessage 使用 BlueBubbles 桥接。