lsp-fix-all
关于
The lsp-fix-all skill automatically applies all available quick-fix code actions for diagnostics in a file, processing them sequentially while re-collecting diagnostics between fixes to account for line number shifts. It's designed to bulk-resolve errors and warnings that the language server can fix automatically, distinguishing it from edit-based skills. This requires the agent-lsp MCP server with codeActionProvider capability.
快速安装
Claude Code
推荐npx skills add blackwell-systems/agent-lsp -a claude-code/plugin add https://github.com/blackwell-systems/agent-lspgit clone https://github.com/blackwell-systems/agent-lsp.git ~/.claude/skills/lsp-fix-all在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Requires the agent-lsp MCP server.
lsp-fix-all
Apply available quick-fix code actions for all current diagnostics in a file, one at a time, re-collecting diagnostics between each fix because line numbers shift after each application.
Important distinction from /lsp-safe-edit: This skill fixes pre-existing
diagnostics in a file — errors and warnings that already exist before any edit
session begins. /lsp-safe-edit has a code-action step (Step 7) for fixing errors
introduced by a specific edit you just made. Use this skill for systematic
bulk-fixing of existing issues, independent of any edit session.
When to use / not use
Use this skill when:
- A file has accumulated errors or warnings you want to resolve automatically
- You want to clean up a file before starting new work
- You want to apply all available language-server quick-fixes in bulk
Do NOT use this skill when:
- You just made an edit and want to fix newly introduced errors — use
/lsp-safe-edit - You want to apply structural refactors — this skill applies quick-fixes only (see filtering below)
- The file has zero diagnostics (the skill will report clean and stop)
Input
- file_path: Absolute path to the file to fix.
Workflow
Step 1 — Open and collect initial diagnostics
Call mcp__lsp__open_document with the target file path to ensure it is loaded
in the language server. Then call mcp__lsp__get_diagnostics to retrieve all
current diagnostics.
If zero diagnostics are returned: report "No diagnostics found — file is clean." and stop. No further steps are needed.
Record the initial count of errors and warnings for the summary output.
Step 2 — Classify and filter code actions
For EACH diagnostic (process one at a time, not in batch):
- Call
mcp__lsp__suggest_fixesat the diagnostic's position/range. - Filter the returned actions to quick-fix kind only.
- Skip any diagnostic for which no applicable quick-fix exists — note it in the summary.
Decision gate — which code actions to apply:
| Action kind | Apply? |
|---|---|
quickfix | YES |
quickfix.* | YES |
refactor | NO — structural change |
refactor.extract | NO — structural change |
refactor.inline | NO — structural change |
source.organizeImports | YES — safe formatting |
source.* (others) | NO — skip unless organizeImports |
| (no kind / empty) | NO — unknown, skip |
A code action qualifies if: kind == "quickfix", OR kind starts with "quickfix.",
OR kind == "source.organizeImports".
Reject actions whose kind is "refactor", starts with "refactor.", or has no
kind field at all.
Step 3 — Apply one fix and re-collect (the core loop)
This is the critical correctness constraint: never apply more than one fix per
iteration. After each apply_edit call, line numbers in the file shift. Always
re-call get_diagnostics before processing the next diagnostic.
Loop:
iteration = 0
max_iterations = 50
while iteration < max_iterations:
diagnostics = mcp__lsp__get_diagnostics(file_path)
if diagnostics is empty: break
for each diagnostic in diagnostics:
actions = mcp__lsp__suggest_fixes(diagnostic.range)
applicable = filter to quickfix / source.organizeImports kinds (see Step 2)
if applicable is not empty:
apply the first applicable action via mcp__lsp__apply_edit
record: (line, message, action title) in "Fixed" list
iteration += 1
break # restart the outer loop — line numbers have shifted
if no diagnostic in this pass had an applicable quick-fix:
break # no progress possible — exit loop
Exit the loop when:
- The diagnostics list is empty, OR
- No remaining diagnostic has an applicable quick-fix action, OR
- The iteration counter reaches 50 (safety guard against edge cases where a fix introduces a new fixable diagnostic, preventing infinite loops)
If apply_edit returns an error: stop the loop immediately and report the
failure in the summary. Do not attempt further fixes.
Step 4 — Verify and format
After the loop exits:
- Call
mcp__lsp__get_diagnosticsone final time to capture the post-fix state. - For any remaining diagnostics that had no applicable quick-fix, list them in the "Skipped" section with explanation.
- Call
mcp__lsp__format_documentto clean up any indentation drift introduced by the applied edits.
Output format
## lsp-fix-all Summary
File: /path/to/file.go
Initial diagnostics: N errors, M warnings
Fixes applied: K
Remaining (no auto-fix available): J
### Fixed
- line X: <message> → applied: <action title>
### Skipped (no quick-fix available)
- line Y: <message>
If apply_edit failed mid-loop, append:
### Loop stopped
- apply_edit returned error on line Z: <error message>
- Fixes applied before failure: K
Safety rules
- Never apply more than one code action per loop iteration
- Always re-collect diagnostics after each
apply_editbefore the next fix - Never apply refactor or structural code actions — quick-fix and source.organizeImports only
- If
apply_editreturns an error, stop the loop and report the failure; do not continue - Maximum iterations: 50 (safety guard against infinite loops in edge cases where a fix introduces a new fixable diagnostic)
- Do not use
execute_command—apply_editis sufficient for all quick-fixes
Prerequisites
LSP must be running for the target workspace. If not yet initialized, call
mcp__lsp__start_lsp with the workspace root before proceeding.
Auto-init note: agent-lsp supports workspace auto-inference from file paths.
Explicit start_lsp is only needed when switching workspace roots.
GitHub 仓库
相关推荐技能
executing-plans
设计该Skill用于当开发者提供完整实施计划时,以受控批次方式执行代码实现。它会先审阅计划并提出疑问,然后分批次执行任务(默认每批3个任务),并在批次间暂停等待审查。关键特性包括分批次执行、内置检查点和架构师审查机制,确保复杂系统实现的可控性。
requesting-code-review
设计该Skill可在完成任务、实现主要功能或合并代码前自动调度代码审查子代理,确保实现符合需求和计划。它支持通过指定git SHA范围进行精准的代码变更审查,帮助开发者在关键节点及时发现潜在问题。核心原则是"早审查、勤审查",适用于开发流程的各个关键阶段。
connect-mcp-server
设计这个Skill指导开发者如何将MCP服务器连接到Claude Code,支持HTTP、stdio和SSE三种传输协议。它涵盖了从安装配置到认证安全的完整流程,适用于集成GitHub、Notion、数据库等外部服务。当开发者需要添加集成、配置外部工具或提及MCP相关功能时,这个Skill能提供实用的操作指南。
web-cli-teleport
设计该Skill帮助开发者根据任务特性选择Claude Code的Web或CLI界面,并指导如何在两种环境间无缝迁移会话。它能分析任务复杂度、迭代需求等要素,推荐最优工作界面和工作流。关键特性包括会话状态管理、环境切换指导和上下文优化建议。
