Agent skill

Lsp Format Code

by blackwell-systems in blackwell-systems/agent-lsp

Format a file or selection using the language server's formatter.

MITAuto-check passedDevelopment

Install Lsp Format Code

skills CLI
$ npx skills add blackwell-systems/agent-lsp --skill lsp-format-code -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install blackwell-systems/agent-lsp lsp-format-code --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/blackwell-systems/agent-lsp.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/lsp-format-code .claude/skills/lsp-format-code && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
lsp-format-code
GitHub stars
157
Token cost
~1.3k tokens
SKILL.md length
445 words
Files
1
Skills in repo
24
Repo updated
First seen
Licence
MIT

At a glance

Format a file or selection using the language server's formatter.

  • Works in 5 steps: Check formatting is supported (optional) → Open the file → Request formatting edits → …
  • Tasks that involve Linting and formatting
  • SKILL.md covers When to use, Workflow, Output format and Multi-file formatting, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Lsp Format Code is an agent skill from blackwell-systems/agent-lsp. Format a file or selection using the language server's formatter. Use before committing to apply consistent style, or after generating code to clean up indentation and spacing. Supports full-file and range-based formatting.

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts. Compatibility notes: Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp)

It sits in Development, covering Linting and formatting. The repository describes itself as: MCP server that orchestrates language servers into agent-native workflows. 65 tools, 30 CI-verified languages. The licence is MIT.

When your agent uses it

  • Tasks that involve Linting and formatting

Example prompts

  • “/lsp-format-code”

Requirements

  • Python 3
  • Compatibility (from SKILL.md): Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp)
  • Pre-approved tools (allowed-tools): mcp__lsp__open_document, mcp__lsp__format_document, mcp__lsp__format_range, mcp__lsp__apply_edit, mcp__lsp__get_diagnostics, mcp__lsp__get_server_capabilities

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Check formatting is supported (optional)
  2. Open the file
  3. Request formatting edits
  4. Apply the edits
  5. Verify (optional but recommended)

What it can do on your machine

Read from SKILL.md and the folder at commit 09ea99e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • mcp__lsp__open_document
    • mcp__lsp__format_document
    • mcp__lsp__format_range
    • mcp__lsp__apply_edit
    • mcp__lsp__get_diagnostics
    • mcp__lsp__get_server_capabilities

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp)

    From compatibility in the SKILL.md frontmatter.

Context cost

Lsp Format Code loads about 1.3k tokens when it runs. Until then it costs about 60 tokens; SKILL.md has 445 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~60
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from blackwell-systems/agent-lsp at commit 09ea99e, republished under its MIT licence (© blackwell-systems). 445 words, ~1,273 tokens.

Download SKILL.mdSave it as .claude/skills/lsp-format-code/SKILL.md (or your agent's skills folder).
name
lsp-format-code
description
Format a file or selection using the language server's formatter. Use before committing to apply consistent style, or after generating code to clean up indentation and spacing. Supports full-file and range-based formatting.
allowed-tools
mcp__lsp__open_document, mcp__lsp__format_document, mcp__lsp__format_range, mcp__lsp__apply_edit, mcp__lsp__get_diagnostics, mcp__lsp__get_server_capabilities
compatibility
Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp)
argument-hint
[file-path] [optional: start_line-end_line]
user-invocable
true
license
MIT
metadata.required-capabilities
documentFormattingProvider
metadata.optional-capabilities
documentRangeFormattingProvider

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.

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.)

Show full SKILL.md (189 more words)Show less

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_document → apply_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.

© blackwell-systems, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/lsp-format-code of blackwell-systems/agent-lsp.

Open the folder on GitHubat commit 09ea99e

Compare with similar skills

Lsp Format Code next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Lsp Format Code compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Lsp Format Code this skillblackwell-systems/agent-lsp157—~1.3kAutomated safety check: PassMIT
Install Anti-Slop Oxlint Rulesdmmulroy/anti-slop5.2k—~2.2kAutomated safety check: PassMIT
Babysit PR To Pass CIsgl-project/sglang37k2 repos~3kAutomated safety check: PassApache-2.0
Rust Best Practicesfarm-fe/farm5.6k3 repos~1.1kAutomated safety check: PassMIT
Go Pedantrychromedp/chromedp13k—~3.7kAutomated safety check: PassMIT
Kedro Babysitkedro-org/kedro11k—~4kAutomated safety check: PassCustom licence

Similar skills

  • Installs, updates or migrates the vendored anti-slop Oxlint plugin in a repository, keeping local rule changes and the plugin's license and provenance files.

    5.2k GitHub stars~2.2k tokensUpdated 27 days ago
    DevelopmentAuto-check passed
  • Babysit PR To Pass CI

    sgl-project/sglang

    Start and persistently pursue a goal to babysit an SGLang pull request until selected GitHub Actions workflows pass on the latest PR head.

    37k GitHub starsUsed in 2 repos~3k tokens
    DevelopmentAuto-check passed
  • Guide for writing idiomatic Rust code based on Apollo GraphQL's best practices handbook.

    5.6k GitHub starsUsed in 3 repos~1.1k tokens
    DevelopmentAuto-check passed
  • Go Pedantry

    chromedp/chromedp

    This skill should be used when the user is writing Go code and needs guidance on Go-specific pedantry: error wrapping with fmt.Errorf and %w, interface design (accept interfaces return structs)…

    13k GitHub stars~3.7k tokensUpdated 2 days ago
    DevelopmentAuto-check passed
  • Kedro Babysit

    kedro-org/kedro

    Run Kedro's local lint / format / type-check / tests on changed files (uses the project's pre-commit hooks, ruff, mypy, pytest, lint-imports, detect-secrets, Make targets — in the right venv), or…

    11k GitHub stars~4k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • WooCommerce Markdown Guidelines

    woocommerce/woocommerce

    Rules for writing and editing markdown in the WooCommerce repository, with the project's markdownlint settings for headings, lists and code blocks.

    11k GitHub starsUsed in 1 repo~1.7k tokens
    DevelopmentAuto-check passed

More from blackwell-systems/agent-lsp

All 24 skills in this repo
  • Lsp Dead Code

    blackwell-systems/agent-lsp

    Enumerate exported symbols in a file and surface those with zero references across the workspace.

    157 GitHub stars~2.4k tokensUpdated today
    Auto-check passed
  • Lsp Edit Export

    blackwell-systems/agent-lsp

    Safe workflow for editing exported symbols or public APIs. An agent skill from blackwell-systems/agent-lsp.

    157 GitHub stars~1.9k tokensUpdated today
    Auto-check passed
  • Lsp Fix All

    blackwell-systems/agent-lsp

    Apply available quick-fix code actions for all current diagnostics in a file, one at a time with re-collection between each fix.

    157 GitHub stars~1.6k tokensUpdated today
    Auto-check passed
  • Lsp Generate

    blackwell-systems/agent-lsp

    Trigger language server code generation — implement interface stubs, generate test skeletons, add missing methods, generate mock types.

    157 GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • Lsp Impact

    blackwell-systems/agent-lsp

    Blast-radius analysis for a symbol or file — shows all callers, type supertypes/subtypes, and reference count before you change it.

    157 GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Lsp Rename

    blackwell-systems/agent-lsp

    Two-phase safe rename across the entire workspace. An agent skill from blackwell-systems/agent-lsp.

    157 GitHub stars~1.9k tokensUpdated today
    Auto-check passed

Categories

Questions about Lsp Format Code

What does Lsp Format Code do?

Format a file or selection using the language server's formatter. Lsp Format Code is an agent skill from blackwell-systems/agent-lsp. Format a file or selection using the language server's formatter.

When should I use Lsp Format Code?

Lsp Format Code fits situations like: tasks that involve Linting and formatting.

How do I install Lsp Format Code in Claude Code?

Run `npx skills add blackwell-systems/agent-lsp --skill lsp-format-code -a claude-code`. Or copy the skill folder (skills/lsp-format-code in blackwell-systems/agent-lsp) into .claude/skills/lsp-format-code in your project. Claude Code loads it when a task matches its description.

How do I install Lsp Format Code in Codex?

Run `npx skills add blackwell-systems/agent-lsp --skill lsp-format-code -a codex`. Or copy the skill folder (skills/lsp-format-code in blackwell-systems/agent-lsp) into .agents/skills/lsp-format-code in your project. Codex loads it when a task matches its description.

Can I use Lsp Format Code in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add blackwell-systems/agent-lsp --skill lsp-format-code -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/lsp-format-code, .gemini/skills/lsp-format-code, .github/skills/lsp-format-code and .opencode/skills/lsp-format-code in your project.

What does Lsp Format Code need to run?

SKILL.md names no scripts, command-line tools or credentials: Lsp Format Code is instructions for the agent only. Our summary lists: Python 3. Its frontmatter pre-approves these tools: mcp__lsp__open_document, mcp__lsp__format_document, mcp__lsp__format_range, mcp__lsp__apply_edit, mcp__lsp__get_diagnostics, mcp__lsp__get_server_capabilities. Compatibility (from SKILL.md): Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp).

Does Lsp Format Code access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Lsp Format Code safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Lsp Format Code use?

Lsp Format Code is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Lsp Format Code use?

About 1.3k tokens (SKILL.md is roughly 5.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Lsp Format Code?

Skills that share tags, products or a category with Lsp Format Code: Install Anti-Slop Oxlint Rules (dmmulroy/anti-slop, 5.2k stars), Babysit PR To Pass CI (sgl-project/sglang, 37k stars), Rust Best Practices (farm-fe/farm, 5.6k stars) and Go Pedantry (chromedp/chromedp, 13k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Lsp Format Code?

blackwell-systems (a GitHub user) maintains it in blackwell-systems/agent-lsp, which has 157 GitHub stars. The repository holds 24 skills in this directory. The repository was last updated on October 7, 2026.

Source: blackwell-systems/agent-lsp on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.