关于
This skill performs concurrency safety audits by analyzing code to identify fields accessed from multiple concurrent contexts (goroutines, threads, etc.) and flagging those lacking proper synchronization. It generates field-level safety reports and works across four concurrency families in a language-agnostic manner. Use it when you need to detect potential data races and synchronization issues in your codebase.
快速安装
Claude Code
推荐npx skills add blackwell-systems/agent-lsp -a claude-code/plugin add https://github.com/blackwell-systems/agent-lspgit clone https://github.com/blackwell-systems/agent-lsp.git ~/.claude/skills/lsp-concurrency-audit在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Requires the agent-lsp MCP server.
lsp-concurrency-audit
Given a type or file, map all fields, identify which are accessed from multiple concurrent contexts, and flag fields that lack synchronization. Produces a field-level concurrency safety report.
When to Use
- Before refactoring a type that is accessed from goroutines/threads
- Auditing a codebase for data race candidates
- Reviewing a PR that adds concurrent access to an existing type
- Understanding which fields in a type need mutex protection
Input
/lsp-concurrency-audit <file-path> [--type <TypeName>]
If --type is provided, audit only that type. Otherwise, audit all types in
the file that have concurrent callers.
Step 1: Discover types and fields
Call list_symbols on the target file to enumerate all types (structs, classes):
mcp__lsp__list_symbols({ "file_path": "<target>" })
For each type (kind=23 struct, kind=5 class), collect:
- Type name
- All fields (children with kind=8 field or kind=7 variable)
- Whether any field's name or detail contains sync primitives ("Mutex", "RWMutex", "Lock", "Semaphore", "atomic", "Atomic", "sync.", "pthread_mutex", "std::mutex")
If --type was specified, filter to that type only.
Step 2: Blast radius and sync-guarded status
Call blast_radius on the file:
mcp__lsp__blast_radius({
"changed_files": ["<target>"],
"scope": "all"
})
From the result, for each method on each target type:
- Record
sync_guarded: true/falsefrom the response - Record
non_test_callerscount (blast radius) - Record
test_callerscount
Step 3: Trace concurrent boundaries
For each method on each target type, call find_callers with
cross_concurrent: true:
mcp__lsp__find_callers({
"file_path": "<target>",
"line": <method_line>,
"column": <method_column>,
"direction": "incoming",
"cross_concurrent": true
})
Record for each method:
concurrent_callers: list of callers that cross concurrent boundariespattern: the concurrent entry pattern detected (e.g., "go func(", "Thread.start(")
Step 4: Classify fields
For each field in each type, determine its safety status:
SAFE: The type is sync-guarded (has a mutex/lock field) AND all methods that access this field acquire the lock before access. Confidence: verified if the type has a sync primitive; suspected if relying on external locking.
UNSAFE (data race candidate): The field is accessed by methods that have
concurrent_callers AND the type has no sync primitive. This is a potential
data race.
WRITE-CONCURRENT: The field is written by a method that has concurrent callers. Higher severity than read-only concurrent access.
READ-ONLY: The field is only read (not written) from concurrent contexts. Lower severity; often safe but worth flagging for review.
Severity assignment:
error: UNSAFE + WRITE-CONCURRENT (probable data race)warning: UNSAFE + READ-ONLY (potential race under high concurrency)info: SAFE (sync-guarded, for documentation)
Step 5: Output
## Concurrency Audit: <TypeName>
**File:** <file_path>
**Fields:** N total, M sync-guarded
**Concurrent methods:** K (methods called from goroutines/threads/tasks)
### Field Safety Report
| Field | Type | Sync | Concurrent Writers | Concurrent Readers | Status |
|-------|------|------|-------------------|-------------------|--------|
| mu | sync.RWMutex | (is sync) | - | - | SYNC PRIMITIVE |
| sender | NotificationSender | guarded | 2 (SetSender, Send) | 3 | SAFE |
| subscribers | []Subscriber | none | 1 (Subscribe) | 2 | UNSAFE (write-concurrent) |
### Concurrent Call Sites
For each UNSAFE field, list the concurrent callers:
- `subscribers` written by `Subscribe` called from:
- `setupNotificationHub` via `go func()` at notifications.go:45
- `handleNewSession` via `go func()` at server.go:312
### Recommendations
- Add `sync.RWMutex` to protect `subscribers` field
- Or: use channel-based access pattern instead of direct field mutation
Caveats
-
Heuristic detection. Concurrent boundary detection relies on source pattern matching, not runtime analysis. False negatives are possible when concurrent entry is indirect (e.g., passed as a callback to a framework).
-
Lock discipline not verified. The audit checks whether a sync primitive exists on the type, not whether every method actually acquires it before field access. A type with a mutex but inconsistent locking will show as SAFE when it may not be.
-
External synchronization invisible. If synchronization is provided by an external lock (e.g., the caller holds a lock before calling the method), the audit will flag the field as UNSAFE. Add a comment or annotation to suppress.
-
Read vs write detection is heuristic. Determining whether a method reads or writes a field requires source code analysis. The skill reads the method body and looks for assignment patterns (
field =,field.Store(),append(field,). False positives are possible for complex access patterns.
GitHub 仓库
常见问题
什么是 lsp-concurrency-audit Skill?
lsp-concurrency-audit 是一个 Claude Skill,作者为 blackwell-systems。Skill 将 Claude 按需加载的说明和资源打包,让 Claude 无需额外提示即可执行与 lsp-concurrency-audit 相关的任务。
如何安装 lsp-concurrency-audit?
使用本页的安装命令:将 lsp-concurrency-audit 作为插件添加到 Claude Code,或将其仓库克隆到 skills 目录,然后重启 Claude 以加载该 Skill。
lsp-concurrency-audit 属于哪个分类?
lsp-concurrency-audit 属于文档分类。
lsp-concurrency-audit 可以免费使用吗?
可以。lsp-concurrency-audit 已收录在 AIMCP,可免费安装。
相关推荐技能
Railway Docs Skill可实时获取最新的Railway官方文档,确保回答的准确性。当开发者询问Railway功能特性、工作原理或分享docs.railway.com链接时,应优先使用此技能。它通过专门的LLM优化文档源提供最新信息,避免依赖过时记忆来回答技术问题。
该Skill为在n8n平台的Python代码节点中编写代码提供专家指导,特别适用于需要使用_input/_json/_node语法、Python标准库或了解n8n中Python限制的场景。它强调JavaScript应作为首选方案,仅当需要特定Python功能或对Python语法更熟悉时才使用Python。Skill提供了快速入门模板和关键注意事项,帮助开发者在n8n中高效编写Python代码。
Archon Skill为开发者提供了基于RAG的语义搜索和项目任务管理功能,可通过REST API访问知识库。它支持文档搜索、网站爬取、文件上传和版本控制,适用于技术文档查询和项目管理场景。首次使用时需要配置Archon主机地址,建议在处理外部文档时优先使用该Skill。
这个Skill为n8n工作流中的JavaScript代码节点提供专业指导,涵盖数据处理、HTTP请求和日期操作等核心场景。它详细解释了如何正确使用n8n特有的`$input`/`$json`语法、`$helpers`工具以及DateTime对象,并包含关键的错误排查和模式选择建议。开发者通过该Skill能快速掌握Code节点的正确返回格式、数据访问方法和常见陷阱解决方案。
