MCP HubMCP Hub
스킬 목록으로 돌아가기

lsp-dead-code

blackwell-systems
업데이트됨 5 days ago
53
2
53
GitHub에서 보기
개발api

정보

lsp-dead-code 스킬은 파일 내에서 사용되지 않는 익스포트를 식별합니다. 심볼을 열거하고 작업 공간 전체에서 참조 횟수가 0인지 확인하는 방식으로 작동합니다. 이 스킬은 개발자가 데드 코드를 감사하고, API를 정리하며, 어떤 익스포트를 안전하게 제거할 수 있는지 판단하는 데 도움을 줍니다. 이 스킬을 사용하려면 agent-lsp MCP 서버가 필요하며, list_symbols 및 find_references와 같은 LSP 작업을 활용합니다.

빠른 설치

Claude Code

추천
기본
npx skills add blackwell-systems/agent-lsp -a claude-code
플러그인 명령대체
/plugin add https://github.com/blackwell-systems/agent-lsp
Git 클론대체
git clone https://github.com/blackwell-systems/agent-lsp.git ~/.claude/skills/lsp-dead-code

Claude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요

문서

Requires the agent-lsp MCP server.

lsp-dead-code

Audit an exported symbol list for zero-reference candidates. Calls list_symbols to enumerate symbols, then checks each exported symbol with find_references to find callers. Produces a classified report.

When to Use

Use this skill when you want to identify dead code in a file — exported symbols that are defined but never called anywhere in the workspace. Common use cases:

  • Cleaning up APIs before a release
  • Identifying legacy exports that can be safely removed
  • Auditing a package for unused public surface area

Important: This skill surfaces candidates. Always review results manually before deleting anything. See the Caveats section below.

What counts as "exported"

LanguageExported means...
GoIdentifier starts with an uppercase letter (e.g. MyFunc, MyType)
TypeScriptHas export keyword; or is a public class member (no private)
PythonNot prefixed with _; or explicitly listed in __all__
Java/C#Has public or protected visibility modifier
RustHas pub keyword

Prerequisites

If LSP is not yet initialized, call mcp__lsp__start_lsp with the workspace root first:

mcp__lsp__start_lsp({ "root_dir": "/your/workspace" })

agent-lsp supports auto-inference from file paths, so explicit start is only required when switching workspaces or on a cold session.

Step 0 — Verify indexing is complete (mandatory)

Do not skip this step. An under-indexed workspace returns [] for symbols that ARE referenced, producing false dead-code candidates.

Pick one symbol you know is actively used (e.g. the primary constructor, a widely-called utility function). Call find_references on it:

mcp__lsp__find_references({
  "file_path": "/abs/path/to/file.go",
  "line": <known-active symbol line>,
  "column": <known-active symbol column>,
  "include_declaration": false
})

If this returns []: the workspace is not indexed. Wait 3–5 seconds and retry. Do not proceed until a known-active symbol returns ≥1 reference. If it never returns results after 15 seconds, restart the LSP server with mcp__lsp__restart_lsp_server and re-open the target file.

Step 1 — Open the file and enumerate symbols

Open the file so the language server tracks it, then fetch all symbols:

mcp__lsp__open_document({ "file_path": "/abs/path/to/file.go" })

mcp__lsp__list_symbols({ "file_path": "/abs/path/to/file.go" })

Collect the full symbol list. Filter to exported symbols only using the language-appropriate rule from the table above.

Coordinate note: list_symbols returns 1-based coordinates. Pass selectionRange.start.line and selectionRange.start.character directly to find_references — no conversion needed.

"no identifier found" error: This means the column points to whitespace or a keyword rather than the identifier name. This happens with methods whose receiver prefix shifts the name rightward (e.g. func (c *Client) MethodName — the name starts at column 21, not column 1). Fix: grep the declaration line for the symbol name to find its exact column:

grep -n "MethodName" file.go
# count characters to find the 1-based column of the name

Then retry find_references with the corrected column.

Step 2 — Check references for each exported symbol

For each exported symbol, call find_references with include_declaration: false so the definition site itself is excluded from the count. A count of 0 means no callers, not no occurrences.

mcp__lsp__find_references({
  "file_path": "/abs/path/to/file.go",
  "line": <selectionRange.start.line>,
  "column": <selectionRange.start.character>,
  "include_declaration": false
})

Record the result for each symbol:

{ symbol_name, kind, line, reference_count, locations[] }

Batching note: For files with many exported symbols (>20), process in batches of 5–10 to avoid overwhelming the LSP server.

Zero-reference cross-check (required before classifying as dead): When find_references returns [] for a symbol that looks foundational (a handler, a constructor, a type used as a field), do not trust LSP alone. LSP can miss references made through value-passing, interface satisfaction, or function registration patterns (e.g. server.AddResource(HandleFoo)). Before classifying as dead, run a text search in the primary wiring files:

grep -r "SymbolName" main.go server.go cmd/ internal/

If grep finds the name in a registration or assignment context, the symbol is active — LSP just couldn't resolve the indirect reference. Update your classification accordingly.

Step 3 — Classify and report

Classify each exported symbol by reference count:

  • Zero references (LSP + grep) — confirmed dead candidate. Flag with WARNING.
  • Zero LSP, found by grep — active via registration/value pattern. Mark as ACTIVE.
  • 1–2 references — review manually. May be test-only usage.
  • 3+ references — active symbol. Not dead code.

For test-only references: if all locations are in _test.go files (Go) or files named *.test.* / *.spec.*, mark the symbol as "test-only" in the report rather than "zero-reference".

Produce the Dead Code Report using the format in references/patterns.md.

Caveats

The following cases produce zero LSP references even though the symbol IS used at runtime. Do not delete any zero-reference candidate without manual review:

  1. Incomplete indexing. find_references only searches files open or indexed by the language server. If the workspace is partially indexed, results may be incomplete. The Step 0 warm-up check catches this.

  2. Registration patterns. Symbols passed as values to registration functions (e.g. server.AddTool(HandleFoo), http.HandleFunc("/", handler)) appear as zero LSP references from the definition site because gopls tracks the call to the registrar, not the handler name. Always grep wiring files for zero-reference handlers before classifying as dead.

  3. Reflection and dynamic dispatch. Symbols used via reflection (reflect.TypeOf in Go, Class.forName in Java) or dynamic dispatch have no static call sites visible to the LSP.

  4. //go:linkname and assembly. Go symbols linked via //go:linkname or referenced from assembly files will show zero LSP references.

  5. Library public API. Exported symbols called from external packages not present in the workspace will show zero references even if consumers exist.

  6. Declaration excluded from count. The definition site is not counted (include_declaration: false). A count of 0 means no callers found, not that the symbol never appears in the source tree.

  7. Always review before deleting. Zero LSP references is a signal to investigate, not a guarantee the symbol is unused.

Step 4 — Next steps

After generating the report:

  • For each zero-reference symbol (confirmed by grep): Run lsp-impact on the symbol to confirm. If lsp-impact also finds zero references, it is safe to consider for removal. Still check the Caveats section above.

  • For symbols with only test-file references: Mark as "test-only" in the report. These may be candidates for removal if the tests themselves are redundant, but should not be deleted without reviewing whether the tests serve a documentation or contract purpose.

  • For symbols with 1–2 references in production code: These are likely active but lightly used. Do not remove without checking whether they are part of a committed public API.

Step 5 — Optional cleanup with safe_delete_symbol

After reviewing the dead code report and confirming candidates with the user, you may offer to remove confirmed zero-reference symbols using safe_delete_symbol:

mcp__lsp__safe_delete_symbol({
  "file_path": "/abs/path/to/file.go",
  "symbol_path": "DeadFunction"
})

This tool performs its own reference check before deleting. If any references exist (even ones missed in the initial scan), the deletion is refused.

Requirements before using this step:

  1. The user has explicitly confirmed they want the symbol removed.
  2. The symbol was classified as a confirmed dead candidate (zero LSP + zero grep references).
  3. You have reviewed the Caveats section above and communicated relevant risks.

Do NOT auto-delete symbols without user confirmation. Present the dead code report first, let the user select which symbols to remove, then execute safe_delete_symbol for each approved removal.

GitHub 저장소

blackwell-systems/agent-lsp
경로: skills/lsp-dead-code
0
agentskillsai-agentsai-toolingclaudeclaude-codecode-intelligence

연관 스킬

qmd

개발

qmd는 BM25, 벡터 임베딩, 재순위화를 결합한 하이브리드 검색을 통해 로컬 파일을 색인화하고 검색할 수 있는 로컬 검색 및 색인화 CLI 도구입니다. 명령줄 사용과 Claude 통합을 위한 MCP(Model Context Protocol) 모드를 모두 지원합니다. 이 도구는 임베딩에 Ollama를 사용하고 색인을 로컬에 저장하여 터미널에서 직접 문서나 코드베이스를 검색하는 데 이상적입니다.

스킬 보기

subagent-driven-development

개발

이 스킬은 각 독립적인 작업마다 새로운 하위 에이전트를 배치하고 작업 사이에 코드 리뷰를 진행하여 구현 계획을 실행합니다. 이 리뷰 프로세스를 통해 품질 게이트를 유지하면서 빠른 반복 작업을 가능하게 합니다. 동일한 세션 내에서 대부분 독립적인 작업을 진행할 때 내장된 품질 검증과 함께 지속적인 진행을 보장하기 위해 사용하세요.

스킬 보기

mcporter

개발

mcporter 스킬은 개발자가 Claude에서 직접 Model Context Protocol(MCP) 서버를 관리하고 호출할 수 있도록 합니다. 이 스킬은 사용 가능한 서버를 나열하고, 인수를 사용해 해당 서버의 도구를 호출하며, 인증 및 데몬 생명주기를 처리하는 명령어를 제공합니다. 개발 워크플로우에서 MCP 서버 기능을 통합하고 테스트할 때 이 스킬을 사용하세요.

스킬 보기

adk-deployment-specialist

개발

이 스킬은 A2A 프로토콜을 사용하여 Vertex AI ADK 에이전트를 배포하고 오케스트레이션하며, AgentCard 검색, 작업 제출, 코드 실행 샌드박스 및 메모리 뱅크와 같은 지원 도구를 관리합니다. Python, Java 또는 Go 언어로 순차, 병렬 또는 루프 오케스트레이션 패턴을 갖춘 다중 에이전트 시스템 구축을 가능하게 합니다. Google Cloud에서 ADK 에이전트 배포 또는 에이전트 워크플로우 오케스트레이션을 요청받았을 때 사용하세요.

스킬 보기