К основному содержанию
скилл CX Codex

lsp-concurrency-audit — скилл для Claude Code: аудит и установка

Скилл проверяет поля типа или файла на доступ из конкурентных контекстов и выдаёт отчёт по безопасности. Пригодится перед рефакторингом или при разборе потенциальных гонок данных.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add blackwell-systems/agent-lsp --skill lsp-concurrency-audit -a claude-code
Открыть на GitHub

Что делает lsp-concurrency-audit

Скилл собирает типы и поля через LSP, проверяет вызывающие методы и ищет переходы через конкурентные границы. Для каждого поля он отмечает синхронизацию, конкурентных читателей и писателей, затем присваивает статус и уровень серьёзности. Можно проверить весь файл или указать тип через --type <TypeName>.

Для работы нужен MCP-сервер agent-lsp. Проверка конкурентных границ эвристическая: косвенные вызовы через callback могут не обнаружиться, а наличие мьютекса не подтверждает, что каждый метод берёт блокировку. Внешнюю синхронизацию скилл тоже может не увидеть, поэтому отчёт стоит сверить с кодом.

Какие задачи решает

  • найти поля, к которым обращаются из конкурентных контекстов
  • выявить потенциальные гонки при записи в поля
  • проверить, какие методы вызываются из горутин или потоков
  • составить отчёт о синхронизации полей перед рефакторингом

Примеры запросов агенту

  • Проверь конкурентный доступ к типам в internal/server.go командой /lsp-concurrency-audit internal/server.go.
  • Проведи аудит только типа Session в server.go: /lsp-concurrency-audit server.go --type Session.
  • Найди потенциальные гонки в cache.go и перечисли конкурентных читателей и писателей: /lsp-concurrency-audit cache.go.

Как установить lsp-concurrency-audit

1Через Skills CLI (Vercel)

npx skills add blackwell-systems/agent-lsp --skill lsp-concurrency-audit -a claude-code

2Вручную: положить файлы

~/.claude/skills/lsp-concurrency-audit/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/lsp-concurrency-audit/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о lsp-concurrency-audit

Как установить lsp-concurrency-audit в Claude Code?

Выполните npx skills add blackwell-systems/agent-lsp --skill lsp-concurrency-audit -a claude-code. Файл скилла находится по пути ~/.claude/skills/lsp-concurrency-audit/SKILL.md.

Что делает lsp-concurrency-audit?

Он проверяет поля типа или файла на доступ из конкурентных контекстов и формирует отчёт с читателями, писателями и статусом синхронизации.

Насколько точно скилл проверяет блокировки?

Он проверяет наличие примитива синхронизации, но не подтверждает, что каждый метод берёт блокировку перед доступом к полю. Границы конкурентного выполнения и чтение или запись определяются эвристически.

Исходный текст

SKILL.md · MIT
---
name: lsp-concurrency-audit
description: Concurrency safety audit for a type or file. Maps all fields, traces which are accessed from concurrent contexts (goroutines, threads, async tasks), and flags fields that lack synchronization. Produces a field-level safety report. Language-agnostic across 4 concurrency families.
argument-hint: "<file-path> [--type <TypeName>]"
user-invocable: true
allowed-tools: mcp__lsp__start_lsp mcp__lsp__open_document mcp__lsp__blast_radius mcp__lsp__find_callers mcp__lsp__list_symbols mcp__lsp__get_symbol_source mcp__lsp__find_references
license: MIT
compatibility: Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp)
metadata:
  required-capabilities: documentSymbolProvider referencesProvider
  optional-capabilities: callHierarchyProvider
---

> 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/false` from the response
- Record `non_test_callers` count (blast radius)
- Record `test_callers` count

## 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 boundaries
- `pattern`: 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

```markdown
## 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

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

2. **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.

3. **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.

4. **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.

© blackwell-systems · MIT · blackwell-systems/agent-lsp

Похожие скиллы

Все скиллы по теме «Код-ревью и рефакторинг» →
improve-codebase-architecture Matt Pocock Скилл ищет архитектурные узкие места в кодовой базе и показывает варианты углубления модулей в HTML-отчёте. Подойдёт для ревью перед рефакторингом. 1 163 035установок tdd Matt Pocock Скилл управляет циклом красный-зелёный в TDD: проверяет, что тесты пишутся до кода, держит их на уровне публичных интерфейсов и не завязывает на внутреннюю структуру. 1 141 062установок triage Matt Pocock Скилл проводит issue и внешние PR через роли триажа, проверку и подготовку брифа для агента. Подойдёт мейнтейнеру, который разбирает очередь задач. 990 453установок codebase-design Matt Pocock Скилл помогает проектировать модули с небольшим интерфейсом и скрытой внутри сложностью. Подходит для рефакторинга, тестируемости и поиска чистого seam. 850 344установок code-review Matt Pocock Проверяет изменения от выбранной точки по стандартам репозитория и требованиям задачи. Нужен для ревью ветки, PR или незавершённой работы. 789 521установок implement Matt Pocock Выполняет задачу по спецификации или тикетам, ведёт работу через тесты и завершает её ревью с коммитом. Подходит для задач, где нужен дисциплинированный цикл разработки. 774 700установок

Из того же набора25

lsp-explore Собирает сведения о символе: определение, тип, реализации, вызывающие функции и ссылки. Пригодится, когда нужно разобраться в незнакомом коде. CX Codex +1 ★ 165звёзд репо lsp-edit-symbol Меняет функцию, тип или переменную по имени, когда точный файл и позиция неизвестны. Работает через MCP-сервер agent-lsp. CX Codex +1 ★ 165звёзд репо lsp-edit-export Пошаговый сценарий безопасного изменения публичных функций, типов и API. Сначала находит все вызовы через LSP, запрашивает подтверждение и проверяет сборку. CX Codex +1 ★ 165звёзд репо lsp-docs Скилл ищет сведения о символе через LSP, документацию локального toolchain и исходное определение. Выручает, когда hover пустой или зависимость не индексируется. CX Codex +1 ★ 165звёзд репо lsp-dead-code Скилл перечисляет экспортируемые символы файла и проверяет каждый на ссылки по всему проекту. Помогает понять, какие экспорты можно удалять. CX Codex +1 ★ 165звёзд репо lsp-cross-repo Находит вызовы символов общей библиотеки во всех зависимых репозиториях через LSP. Помогает оценить последствия рефакторинга до внесения ломающих правок. CX Codex +1 ★ 165звёзд репо lsp-architecture Собирает структурный обзор кодовой базы: языки, пакеты, точки входа, зависимости и горячие файлы. Один вызов вместо ручного обхода репозитория. CX Codex +1 ★ 165звёзд репо agent-lsp Координирует языковые серверы и предоставляет агенту 65 инструментов для работы с кодом на 32 языках без постоянного повторного сканирования. CX Codex +1 ★ 165звёзд репо

Спонсоры проекта

Компании, которые помогают держать аналитику открытой