一键导入
refactor-large-function
Pick one large function flagged by ESLint max-lines-per-function and refactor it into smaller, focused helpers without breaking tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Pick one large function flagged by ESLint max-lines-per-function and refactor it into smaller, focused helpers without breaking tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Find all hardcoded path-to-editor-name mappings in the CLI (cli/src/analysis.ts::getEditorSourceFromPath) and VS Code extension (src/workspaceHelpers.ts::getEditorTypeFromPath), verify they return matching friendly display names for the same path patterns, and confirm every CLI-returned name appears in the EDITOR_ICON_MAP in formatUtils.ts. Use after adding a new editor adapter, after CLI changes, or if JetBrains/other CLI-based consumers show raw editor keys instead of friendly names.
Validate that ~/.copilot/data.db has the required schema for session hierarchy (workspace_parent_links, workspaces, sessions tables and columns). Runs an actual today's-data query so schema regressions are caught early. Use when data.db schema changes may have broken hierarchy enrichment, or on a periodic schedule to detect breaking changes.
Find all hardcoded path-to-editor-name mappings in the CLI (cli/src/analysis.ts::getEditorSourceFromPath) and VS Code extension (src/workspaceHelpers.ts::getEditorTypeFromPath), verify they return matching friendly display names for the same path patterns, and confirm every CLI-returned name appears in the EDITOR_ICON_MAP in formatUtils.ts. Use after adding a new editor adapter, after CLI changes, or if JetBrains/other CLI-based consumers show raw editor keys instead of friendly names.
Find all model IDs referenced in local AI-coding session log files and debug logs, then compare them against the keys in src/modelPricing.json. Reports models found in logs that have no pricing entry (unknown — informational only) and pricing entries never observed locally (unused). Use after adding a new model to modelPricing.json, after seeing unexpected cost attributions, or to discover which new models have appeared in recent sessions. Depends on file discovery patterns from the validate-session-schemas skill.
Loop over recent local AI-coding session log files for every supported file-based platform (Copilot Chat, Copilot CLI, JetBrains, Claude Code, Gemini CLI, Antigravity, OpenCode) and validate they still match the documented schema, while surfacing newly-discovered fields we could start using. Use after an editor/CLI update, when adding a parser, or on a schedule to catch schema drift early.
Validate that ~/.copilot/data.db has the required schema for session hierarchy (workspace_parent_links, workspaces, sessions tables and columns). Runs an actual today's-data query so schema regressions are caught early. Use when data.db schema changes may have broken hierarchy enrichment, or on a periodic schedule to detect breaking changes.
| name | refactor-large-function |
| description | Pick one large function flagged by ESLint max-lines-per-function and refactor it into smaller, focused helpers without breaking tests. |
An ESLint complexity or max-lines-per-function rule is producing warnings for functions that are too long. Pick one of those functions (not from extension.ts, which is intentionally monolithic) and refactor it into smaller, focused private helpers.
Run ESLint with the complexity rules to get the current list of violations:
cd vscode-extension && node_modules/.bin/eslint src --rule '{"max-lines-per-function": ["warn", 80]}' --format stylish 2>&1 | grep "Lines/Fn\|max-lines-per-function" | head -20
Or, if the project already has the rule configured, just run:
cd vscode-extension && node_modules/.bin/eslint src 2>&1 | grep "max-lines-per-function\|Lines/Fn" | head -20
Choose one function to refactor, following these priorities:
src/extension.ts - it is intentionally large and hard to test in isolation.test/unit/ for a matching test file).Before touching any code, read the relevant sub-project instructions file. For vscode-extension/ work, read .github/instructions/vscode-extension.instructions.md.
Read the full function body and identify natural decomposition boundaries:
null on cancellation.Introduce small result interfaces or types at the top of the file (not exported) to carry data between steps cleanly, rather than long parameter lists.
Before changing anything, compile and run the existing unit tests to establish a green baseline:
cd vscode-extension
node_modules/.bin/tsc.cmd --noEmit # type-check
npm run test:node # unit tests
Record which tests cover the target file so you know what to watch.
Apply the extraction. Rules:
_ prefix to signal they are internal helpers.null (not undefined) from a helper to signal user cancellation or an unrecoverable error; the caller does an early if (!result) { return; } guard.cd vscode-extension && node_modules/.bin/eslint src/path/to/changed-file.ts
All new warnings introduced by your changes must be resolved before proceeding. Pre-existing warnings on other functions in the same file are acceptable - do not fix unrelated code.
cd vscode-extension
node_modules/.bin/tsc.cmd --noEmit # type-check
npm run test:node # unit tests
node esbuild.js --production # production bundle
All tests must pass and the build must succeed. If a test fails, fix the refactoring - do not modify the tests unless the test itself was wrong before your change.
Write a commit in this format:
refactor: extract <FunctionName> into focused private methods
<One or two sentences describing which logical sections were extracted
and why the split makes sense.>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Open a pull request to main. The PR description should:
tsc or unit tests fail after your change, revert and choose a different decomposition strategy rather than patching around the failure.