lsp-test-correlation
关于
This skill identifies and runs only the specific tests that cover a modified source file, avoiding full test suite execution. It's ideal for post-edit validation or pre-commit checks to get fast, targeted feedback. It requires the agent-lsp MCP server and uses LSP capabilities to map source files to their corresponding tests.
快速安装
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-test-correlation在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Requires the agent-lsp MCP server.
lsp-test-correlation
Discover which tests cover a source file, then run only those tests. Faster than running the full suite when you've changed one or two files and want targeted feedback.
When to use
- After editing a source file: "Which tests do I need to run for this change?"
- Before committing: run only the tests that cover what you touched
- Debugging a failure: find which test file corresponds to a broken source file
- Code review: understand what test coverage exists for a file before merging
Use /lsp-verify instead when you want to run the full suite and check all
three layers (diagnostics + build + tests). Use this skill when you want fast,
scoped test execution.
Workflow
Step 1 — Find correlated test files
Call get_tests_for_file for each edited source file:
mcp__lsp__get_tests_for_file({ "file_path": "/abs/path/to/source.go" })
Returns the test files that correspond to the source file. For multiple edited files, call once per file.
If no test files are returned: the source file may have no dedicated test file, or the mapping is not resolvable (e.g. integration tests in a separate directory). See Step 2 for fallback.
Step 2 — Enumerate test functions (fallback or enrichment)
If get_tests_for_file returns test files, use find_symbol to list
the test functions defined in those files:
mcp__lsp__find_symbol({ "query": "Test" })
Filter results to the correlated test files from Step 1. This gives you the specific test function names to run rather than the whole test file.
Fallback (no test files found): query find_symbol for test
functions that contain the changed symbol's name:
mcp__lsp__find_symbol({ "query": "Test<ChangedFunctionName>" })
This catches cases where get_tests_for_file misses indirect coverage.
Step 3 — Report the correlation map
Before running, report what was found:
## Test correlation for <file>
Source file: internal/tools/analysis.go
Test files:
→ internal/tools/analysis_test.go
Tests: TestHandleGetCodeActions, TestHandleGetCompletions, TestHandleGetDocumentSymbols
No correlated test files found for: internal/lsp/normalize.go
→ Fallback: TestNormalizeCompletion, TestNormalizeDocumentSymbols (from workspace symbol search)
If the user provided run=true or asks to run, proceed to Step 4. Otherwise
stop here and let the user decide.
Step 4 — Run correlated tests
Run only the correlated test files or functions. Scope as tightly as possible:
Go — run specific package:
mcp__lsp__run_tests({ "workspace_dir": "<root>", "test_filter": "TestHandleGetCodeActions|TestHandleGetCompletions" })
If run_tests does not support test_filter, pass the package path instead of
the workspace root to narrow scope. The test output will be smaller and faster
than running ./....
Output handling: If test output is large, do not read it in full. Search for failures:
grep -E "^(FAIL|--- FAIL)" <output_file>
Step 5 — Report results
## Test Results
Ran 3 tests in internal/tools/analysis_test.go
PASSED (2):
TestHandleGetCodeActions
TestHandleGetCompletions
FAILED (1):
TestHandleGetDocumentSymbols — expected 3 symbols, got 2 (analysis_test.go:87)
Recommendation: Fix TestHandleGetDocumentSymbols before committing.
Multi-file workflow
For changes spanning multiple source files:
- Call
get_tests_for_filefor each changed file in parallel. - Deduplicate the resulting test files (the same test file may cover multiple source files).
- Report the full correlation map before running.
- Run the deduplicated test set once.
## Test correlation for 3 changed files
internal/tools/analysis.go → internal/tools/analysis_test.go
internal/lsp/client.go → internal/lsp/client_test.go, internal/lsp/client_completion_test.go
internal/resources/resources.go → (no dedicated test file)
Deduplicated test files to run: 3
Decision guide
| Situation | Action |
|---|---|
get_tests_for_file returns test files | Use those; enumerate functions via find_symbol |
| No test files returned | Fallback to find_symbol with changed symbol names |
| Test files found but no matching test functions | Report gap — this source file may lack unit test coverage |
| More than 10 test files returned | Don't run all; use /lsp-verify for full suite instead |
| Test fails | Run /lsp-verify for full diagnostic picture |
Example
# "I edited internal/tools/symbol_source.go — which tests should I run?"
get_tests_for_file(file_path="/repo/internal/tools/symbol_source.go")
→ internal/tools/symbol_source_test.go
find_symbol(query="TestGetSymbolSource")
→ TestGetSymbolSource_ContainsPosition (line 12)
→ TestGetSymbolSource_FindInnermost (line 34)
→ TestGetSymbolSource_PositionPattern (line 67)
# Report correlation, then run:
run_tests(workspace_dir="/repo", test_filter="TestGetSymbolSource")
→ 3 passed in 0.4s
GitHub 仓库
相关推荐技能
evaluating-llms-harness
测试该Skill通过60+个学术基准测试(如MMLU、GSM8K等)评估大语言模型质量,适用于模型对比、学术研究及训练进度追踪。它支持HuggingFace、vLLM和API接口,被EleutherAI等行业领先机构广泛采用。开发者可通过简单命令行快速对模型进行多任务批量评估。
cloudflare-cron-triggers
测试这个Claude Skill提供了关于Cloudflare Cron Triggers的完整知识库,用于通过cron表达式定时执行Workers。它支持配置周期性任务、维护作业和自动化工作流,并能处理常见的cron触发错误。开发者可以用它来设置定时任务、测试cron处理器,并集成Workflows和Green Compute功能。
webapp-testing
测试该Skill为开发者提供了基于Playwright的本地Web应用测试工具集,支持自动化测试前端功能、调试UI行为、捕获屏幕截图和查看浏览器日志。它包含管理服务器生命周期的辅助脚本,可直接作为黑盒工具运行而无需阅读源码。适用于需要快速验证本地Web应用界面和交互功能的开发场景。
finishing-a-development-branch
测试这个Skill用于开发分支完成后的集成决策,当代码实现完成且测试通过时,它会引导开发者选择合适的工作流。它首先验证测试状态,然后提供合并、创建PR或清理等结构化选项。核心价值在于确保代码质量的同时,标准化分支收尾流程。
