返回技能列表

lsp-generate

blackwell-systems
更新于 6 days ago
53
2
53
在 GitHub 上查看
testing

关于

The lsp-generate skill triggers language server code generation features like implementing interface stubs, creating test skeletons, and generating mock types. It surfaces available generation options through suggest_fixes and executes them via execute_command. Use this skill when you need to quickly scaffold new code that doesn't yet exist in your file.

快速安装

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-generate

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

Requires the agent-lsp MCP server.

lsp-generate

lsp-generate creates NEW code that does not yet exist in the file — stubs, mocks, implementations of interfaces, test functions. It is distinct from lsp-extract-function, which restructures code that already exists. Use lsp-generate when you want the language server to write something new; use lsp-extract-function when you want to reorganize existing code.

Input

  • file_path: absolute path to the target file
  • line, column (or position_pattern): position in the file where generation is triggered (e.g., the line with the unimplemented interface, the missing method error, the type declaration)
  • intent: description of what to generate (e.g., "implement io.Reader", "generate test skeleton", "add missing methods", "generate mock for Handler")

Prerequisites

LSP must be running for the target workspace. If not yet initialized, call mcp__lsp__start_lsp with the workspace root before proceeding.

Auto-init note: agent-lsp supports workspace auto-inference from file paths. Explicit start_lsp is only needed when switching workspace roots.


Workflow

Step 1 — Open document and locate position

Call mcp__lsp__open_document for the target file:

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

If using position_pattern, use the @@ marker convention from references/patterns.md to identify the exact cursor position. For example:

"position_pattern": "var _ io.Reade@@r = (*MyType)(nil)"

Step 2 — Get code actions at target position

mcp__lsp__suggest_fixes({
  "file_path": "...",
  "start_line": N,
  "start_column": C,
  "end_line": N,
  "end_column": C
})

Filter for generator actions:

  • Kind "quickfix" with titles matching the intent (e.g., "Implement interface", "Generate", "Add stub", "Create test")
  • Kind "source" for source-level generation

If no matching action is found, report "No generator action available at this position for the given intent" and proceed to the Fallback section below.

Step 3 — Select and confirm action

Display available generator actions to the user. If multiple actions match the intent, list all of them and ask which to apply. Confirm the selected action before executing — do NOT auto-select when multiple candidates exist.

Step 4 — Execute generator

Execute one generator at a time. Do NOT batch multiple execute_command calls.

  • If the action has a command field: run via mcp__lsp__execute_command
  • If the action has an edit field: apply via mcp__lsp__apply_edit
  • If the action has both: apply the edit first, then run the command

Step 5 — Format and verify

mcp__lsp__format_document({ "file_path": "..." })
mcp__lsp__get_diagnostics({ "file_path": "..." })

Report remaining diagnostics. Stub methods typically leave TODO comments or panic("not implemented") bodies — this is expected behavior from the language server. Surface any unexpected errors.


Per-Language Generator Patterns

LanguageGeneratorTrigger locationCode action kind
Go (gopls)Implement interfaceLine with var _ MyInterface = (*MyType)(nil) or type declarationquickfix — "Implement interface"
Go (gopls)Generate test fileAny .go file without _test.go counterpartsource — "Generate unit tests"
Go (gopls)Add missing methodLine with undefined: method errorquickfix
TypeScript (typescript-language-server)Implement interfaceClass declarationquickfix — "Implement interface members"
TypeScript (typescript-language-server)Add missing methodMethod call with no definitionquickfix — "Add missing function declaration"
Python (pyright)Add importName not definedquickfix — "Add import"
Rust (rust-analyzer)Implement traitimpl Trait for Type {}quickfix — "Add missing impl members"

Fallback When No Code Action Is Available

If suggest_fixes returns no generator actions, the language server at this workspace may not support server-side generation for this intent. Explain this to the user and suggest a manual approach specific to the intent:

  • Interface implementation: Look up the interface definition first using mcp__lsp__go_to_symbol to discover all required methods, then implement them manually.
  • Test skeleton: Check mcp__lsp__get_server_capabilities to confirm whether the server advertises code action support; if not, generate the test skeleton manually using standard testing package conventions.
  • Missing methods: Use mcp__lsp__get_diagnostics to enumerate the missing symbols by name, then implement them one at a time.

Constraints

  • Do NOT batch execute_command calls — run one generator at a time
  • Do NOT skip user confirmation when multiple generator actions are available

GitHub 仓库

blackwell-systems/agent-lsp
路径: skills/lsp-generate
0
agentskillsai-agentsai-toolingclaudeclaude-codecode-intelligence

相关推荐技能

content-collections

Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。

查看技能

polymarket

这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。

查看技能

creating-opencode-plugins

该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。

查看技能

sglang

SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。

查看技能