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

lsp-format-code

blackwell-systems
업데이트됨 5 days ago
1 조회
53
2
53
GitHub에서 보기
메타general

정보

이 스킬은 언어 서버의 포매터를 사용하여 코드 파일이나 선택 영역을 gofmt나 Prettier처럼 일관된 스타일로 정리합니다. 생성된 코드를 정리하거나 커밋 전 파일을 준비하는 데 이상적이며, 전체 파일과 범위 기반 포매팅을 모두 지원합니다. 에디터의 포매팅 엔진과 연동하려면 agent-lsp MCP 서버가 필요합니다.

빠른 설치

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-format-code

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

문서

Requires the agent-lsp MCP server.

lsp-format-code

Format a file or selection using the language server's formatter — the same formatting engine your IDE uses. Applies language-specific rules (gofmt, prettier, rustfmt, black) without requiring those tools to be on PATH separately.

When to use

  • Before committing: ensure consistent style across edited files
  • After generating code: clean up AI-generated indentation and spacing
  • After a refactor that shifted indentation levels
  • When a linter flags style violations fixable by the formatter

Use /lsp-safe-edit instead when you are making a logic change and want before/after diagnostic comparison alongside the edit.


Workflow

Step 1 — Check formatting is supported (optional)

If unsure whether the language server supports formatting for this file, check capabilities first:

mcp__lsp__get_server_capabilities({ "file_path": "<file>" })

Look for documentFormattingProvider (full-file) and documentRangeFormattingProvider (range). If neither is present, the server does not support formatting — stop and report.

Skip this step if you know the language supports formatting (Go, TypeScript, Rust, Python all do via their standard servers).

Step 2 — Open the file

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

Step 3 — Request formatting edits

Full file:

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

Selection only:

mcp__lsp__format_range({
  "file_path": "/abs/path/to/file.go",
  "start_line": <N>,
  "end_line": <M>
})

Both return TextEdit[] — a list of replacements to apply. They do not write to disk. If the list is empty, the file is already correctly formatted.

Step 4 — Apply the edits

Pass the TextEdit[] from Step 3 to apply_edit:

mcp__lsp__apply_edit({ "workspace_edit": <TextEdit[] from Step 3> })

This writes the formatting changes to disk.

Step 5 — Verify (optional but recommended)

Call get_diagnostics to confirm formatting did not introduce any errors:

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

Formatting should never introduce errors — if it does, report immediately without committing.


Output format

## Format result: <filename>

Changes applied: N edits
Lines affected: <range or "whole file">
Formatter: <gopls | typescript-language-server | rust-analyzer | ...>

Status: FORMATTED ✓

If no edits were returned:

Status: ALREADY FORMATTED — no changes needed

If formatting is not supported:

Status: NOT SUPPORTED — <server> does not expose documentFormattingProvider
Fallback: run the formatter directly (gofmt, prettier, rustfmt, etc.)

Multi-file formatting

For formatting multiple files (e.g. all files changed in a PR):

  1. Call format_document for each file — these can run in parallel.
  2. Collect all TextEdit[] responses.
  3. Apply each file's edits via apply_edit sequentially.
  4. Report total edits across all files.

Do not apply edits from multiple files in a single apply_edit call — apply per-file to keep changes scoped and reversible.


Decision guide

SituationAction
Formatting a whole file before commitformat_documentapply_edit
Formatting only generated code in a functionformat_range with the function's line range
Empty TextEdit[] returnedFile is already formatted — no action needed
Server doesn't support formattingReport and suggest running CLI formatter directly
Formatting introduces diagnosticsDo not commit — report immediately
Formatting a Go file in a workspace repoEnsure GOWORK=off is set if running via shell fallback

Language notes

LanguageFormatterServer
Gogofmt (via gopls)gopls
TypeScript / JavaScriptprettier or built-in (via typescript-language-server)typescript-language-server
Rustrustfmt (via rust-analyzer)rust-analyzer
Pythonblack or autopep8 (via pyright/pylsp)pyright-langserver or pylsp
C / C++clang-format (via clangd)clangd

The language server delegates to the language's standard formatter — results match what your IDE would produce.

GitHub 저장소

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

연관 스킬

content-collections

메타

이 스킬은 콘텐츠 콜렉션(Content Collections)을 위한 프로덕션 검증된 설정을 제공합니다. 콘텐츠 콜렉션은 Markdown/MDX 파일을 Zod 검증이 포함된 타입 안전한 데이터 콜렉션으로 변환해주는 TypeScript 최우선 도구입니다. 블로그, 문서 사이트 또는 콘텐츠 중심의 Vite + React 애플리케이션을 구축할 때 타입 안전성과 자동 콘텐츠 검증을 보장하기 위해 사용하세요. Vite 플러그인 구성과 MDX 컴파일부터 배포 최적화 및 스키마 검증에 이르기까지 모든 것을 다룹니다.

스킬 보기

polymarket

메타

이 스킬은 개발자들이 Polymarket 예측 시장 플랫폼을 활용한 애플리케이션을 구축할 수 있도록 지원하며, 거래 및 시장 데이터를 위한 API 통합 기능을 포함합니다. 또한 WebSocket을 통한 실시간 데이터 스트리밍을 제공하여 실시간 거래와 시장 활동을 모니터링할 수 있습니다. 이를 통해 거래 전략을 구현하거나 실시간 시장 업데이트를 처리하는 도구를 생성하는 데 활용할 수 있습니다.

스킬 보기

creating-opencode-plugins

메타

이 스킬은 개발자들이 명령어, 파일, LSP 작업 등 25개 이상의 이벤트 유형에 연결되는 OpenCode 플러그인을 만들 수 있도록 돕습니다. JavaScript/TypeScript 모듈을 위한 플러그인 구조, 이벤트 API 명세, 구현 패턴을 제공합니다. OpenCode AI 어시스턴트의 라이프사이클을 사용자 정의 이벤트 기반 로직으로 가로채거나, 모니터링하거나, 확장해야 할 때 사용하세요.

스킬 보기

sglang

메타

SGLang은 RadixAttention 프리픽스 캐싱을 활용하여 JSON, 정규식, 에이전트 워크플로우를 위한 고속 구조화 생성에 특화된 고성능 LLM 서빙 프레임워크입니다. 특히 반복되는 프리픽스가 있는 작업에서 상당히 빠른 추론 속도를 제공하여 복잡한 구조화 출력 및 다중 턴 대화에 이상적입니다. 제약 디코딩이 필요하거나 광범위한 프리픽스 공유가 있는 애플리케이션을 구축할 때는 vLLM과 같은 대안보다 SGLang을 선택하십시오.

스킬 보기