agentleFS
LuisaGroupLuisaGroup/LuisaCompute/.agents/skills/lsp/SKILL.md

lsp

Skill1.1k starsChanged 35 days agoApache-2.0View on GitHub

clangd LSP over HTTP for C++ syntax checks and symbol navigation in LuisaCompute sources.

3 other projects use a version of this.

Trending

Quiet since July.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the LuisaGroup/LuisaCompute repository that our weekly crawl found: only 5 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Start the server in the background: before any C++ editing session (the command blocks until stopped — run it as a background job):

    line 20
  2. Very specific:

    Every clangd call is serialized behind one asyncio.Lock, and each endpoint sleeps first (0.5 s before diagnostics, 0.3 s before a symbol …

    line 96

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

C++ LSP

Provides clangd-powered syntax checks and symbol queries over an HTTP bridge.

Architecture

  • Server (scripts/cpp_lsp_server.py): FastAPI + uvicorn wrapper around one clangd subprocess driven over raw JSON-RPC/stdio (no pygls). Requires compile_commands.json.
    • GET /health → {"status": "ok", "clangd_running": bool}
    • POST /check_syntax → {file_path, content?, verbose, timeout}
    • POST /symbol → {file_path, line, character, content?, action, timeout}
  • Client (scripts/cpp_lsp_client.py): httpx CLI with check / symbol subcommands that talks to the server.

Workflow

  1. Start the server in the background before any C++ editing session (the command blocks until stopped — run it as a background job):
python scripts/cpp_lsp_server.py --project-root . --port 8000

The server auto-discovers compile_commands.json in .vscode/, build/, or project root (first hit wins — .vscode/ is checked before build/), and unlike scripts/check_cpp_syntax.py it does not scan other build* directories. If none is found it falls back to the project root, i.e. clangd runs without per-TU flags.

  1. Use the client to query information. Common commands:

Check Syntax

python scripts/cpp_lsp_client.py check src/core/logging.cpp -v
# Override content ad-hoc:
python scripts/cpp_lsp_client.py check src/core/logging.cpp --content "int main() { return 0; }"

Symbol Navigation

# Go to definition at line 10, character 5 (0-based)
python scripts/cpp_lsp_client.py symbol src/core/logging.cpp 10 5 --action definition

# Hover info
python scripts/cpp_lsp_client.py symbol src/core/logging.cpp 10 5 --action hover

# Document-level symbols
python scripts/cpp_lsp_client.py symbol src/core/logging.cpp --action documentSymbol

Available actions: definition, declaration, typeDefinition, implementation, references, hover, documentSymbol.

--content exists only on check; the symbol subcommand has no --content flag (the /symbol endpoint accepts an optional content field, reachable only via a direct HTTP POST). symbol's line/character positionals are optional (default 0) and ignored by documentSymbol.

Server Health

curl http://127.0.0.1:8000/health

Parameters

Client flagScopeDefaultDescription
--serverglobalhttp://127.0.0.1:8000Server base URL
--timeoutglobal3.0HTTP request timeout (s)
--lsp-timeoutsubcommand10.0clangd wait time (s), sent as the body timeout
-v, --verbosecheckoffAlso print Info/Hint diagnostics
--contentcheckunsetCheck this text instead of the file on disk
line charactersymbol0 00-based position (optional; omit for documentSymbol)
--actionsymboldefinitionOne of the 7 actions listed above

--server/--timeout belong to the top-level parser and must come before the subcommand; --lsp-timeout, -v, --content, --action come after it.

Server flagDefaultDescription
--host127.0.0.1Bind address
--port8000Bind port
--project-root.Where to search for compile_commands.json
--clangdclangdPath to clangd executable (no pre-check, no settings.json lookup)
--compile-commands-dirautoDirectory containing compile_commands.json — a directory, not a file path
--verboseoffPrint LSP traffic and raise uvicorn log level to info

Exit Codes

  • check subcommand: 0 (no errors — warnings alone still exit 0), 1 (at least one error), 2 (connection/HTTP/server error: unreachable server, missing file without --content → HTTP 404).
  • symbol subcommand: 0 (result returned), 1 (no result: clangd returned null or the LSP call timed out), 2 (connection/server error). An action outside the 7 above is rejected by the client's argparse; a direct HTTP call gets 400.
  • Same 0/1/2 semantics as scripts/check_cpp_syntax.py (0 clean, 1 errors, 2 tool failure).

Requirements

  • clangd resolvable through PATH. The server passes --clangd verbatim to subprocess.Popen; it does not read clangd.path from .vscode/settings.json the way scripts/check_cpp_syntax.py does, and does not verify the binary first — give --clangd <path> explicitly when clangd is not on PATH.
  • compile_commands.json generated, e.g.:
    • XMake: xmake project -k compile_commands --lsp=clangd .vscode (.vscode is the server's first search dir)
    • CMake: already forced by the root CMakeLists.txt (set(CMAKE_EXPORT_COMPILE_COMMANDS ON)), so a normal CMake configure writes build/compile_commands.json
  • Python packages: fastapi, uvicorn, httpx, pydantic (the scripts' only third-party imports; not declared in pyproject.toml, install them separately)

Notes

  • The server holds a single clangd process. Restart it if compile_commands.json changes — there is no idle timeout and no hot-reload; stop it with Ctrl+C (the lifespan hook sends LSP shutdown/exit and kills clangd after a 2 s grace).
  • Every clangd call is serialized behind one asyncio.Lock, and each endpoint sleeps first (0.5 s before diagnostics, 0.3 s before a symbol query), so concurrent client calls queue instead of running in parallel.
  • The server always starts clangd with --clang-tidy=true (plus --log=error --completion-style=bundled --pch-storage=memory), unlike check_cpp_syntax.py, where clang-tidy is off unless --clang-tidy.
  • line and character in symbol requests are 0-based, matching the LSP protocol; the diagnostic positions check prints are converted to 1-based line/col.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.