lsp-format-code

lsp-format-code is a skill for Claude Code, Codex from blackwell-systems/agent-lsp. It costs 44 tokens per session (1,243 once invoked), scanned A, original, MIT.

A file or selection formatter that uses the language server, the same kind of code-formatting engine commonly used by an editor.

In plain words
What is it for?
Use it before committing code, after generating or refactoring code, or when a linter reports style problems that automatic formatting can fix.
Why use it?
It applies consistent indentation and spacing without requiring each formatter program to be installed separately on the command line.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/blackwell-systems/agent-lsp/lsp-format-code
Any agent
npx skills add blackwell-systems/agent-lsp --skill lsp-format-code
Clone the repo
git clone --depth 1 https://github.com/blackwell-systems/agent-lsp

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for lsp-format-code

README.md
[![agentmods](https://agentmods.dev/badge/skills/blackwell-systems/agent-lsp/lsp-format-code.svg)](https://agentmods.dev/skills/blackwell-systems/agent-lsp/lsp-format-code)
Your own site
<a href="https://agentmods.dev/skills/blackwell-systems/agent-lsp/lsp-format-code"><img src="https://agentmods.dev/badge/skills/blackwell-systems/agent-lsp/lsp-format-code.svg" alt="Measured on agentmods" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,243 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00044 $0.01243
Opus 5 $0.00022 $0.00622
Sonnet 5 $0.00009 $0.00249
Haiku 4.5 $0.00004 $0.00124

Measured 4d ago against content hash 4b042a42fcb5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

lsp-format-code scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/lsp-format-code/SKILL.md · 164 lines

How it starts

The opening of the file, as written. The whole thing — 164 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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)

Read the full file on GitHub · 164 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 164 lines · 44 tokens per session scan A 4b042a42fcb5

Subscribe to this mod's changes

lsp-format-code is a skill published in the GitHub repository blackwell-systems/agent-lsp (117 stars, last pushed 4d ago), licensed MIT. It adds 44 tokens to every session and 1,243 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

authoring-schemas

Author a mache projection schema (Topology→Node→Leaf) that maps structured data or source code into a filesystem/graph. Use when creating or debugging a -schema.json for a new data source (SQLite/JSON) or a new source language. Covers both dialects — tree-sitter S-expression selectors for code, and JSONPath selectors…

agentic-research/mache · 111 tokens

authoring-smell-rules

Add a findsmells rule to mache — a SQL query over the projected code graph that surfaces a code smell (duplication, complexity, dead code, drift). Use when adding or debugging a SmellRule in cmd/smellrules.go or an external $MACHESMELLRULESDIR rule. Covers the SmellRule struct, the standalone-vs-ast table capability…

agentic-research/mache · 102 tokens

mache-explore

Mount a mache FUSE filesystem inside the project directory so agents can explore structured data without per-file permission prompts.

agentic-research/mache · 27 tokens

analyze-usage

Use when asked to analyze codescout tool usage, check for error patterns, audit tool health, generate a usage report, spot anti-patterns, or clear usage statistics to start fresh.

mareurs/codescout · 42 tokens

code-intelligence

Universal, safe, and professional code modification and refactoring environment for 50+ languages. Use when editing source files to prevent syntax breakage, perform project-wide type-aware renames (LSP), or distill large command output to save context window tokens.

naranor/code-intelligence-skill · 58 tokens

claude

Skill "claude" from paladini/locus-mcp, covering claude code skill (stub), when to use locus, when to use grep, mcp registration and status.

paladini/locus-mcp · 0 tokens