pytest-code-review — скилл для Claude Code: что делает и установка
Скилл pytest-code-review проверяет тесты pytest на корректность асинхронных вызовов, скоуп фикстур, параметризацию и пути для моков. Помогает находить утечки и ошибки патчинга до запуска CI.
Apache-2.0 239 установок ★ 89 обновлён 2026-09-15
npx skills add existential-birds/beagle --skill pytest-code-review -a claude-codeЧто делает pytest-code-review
Скилл заставляет ИИ-агента анализировать файлы test_*.py и conftest.py по строгому пятиэтапному регламенту. Сначала модель фиксирует список проверяемых файлов, затем проверяет асинхронные тесты и структуру фикстур. Только после прохождения всех предварительных гейтов агент формирует список замечаний с конкретными строками или идентификаторами тестовых узлов.
Инструкция фокусируется на частых ошибках в тестах на Python: подмене AsyncMock на синхронный Mock, забытых операторах await или отсутствии блоков finally в yield-фикстурах. Скилл пресекает дублирование логики вместо @pytest.mark.parametrize. Отдельное правило касается патчинга: агент проверяет путь импорта там, где объект вызывается, а не в месте его объявления.
Агент не выдаёт абстрактную критику. Каждое замечание обязано содержать конкретный файл и строку кода.
Какие задачи решает
- найти пропущенные
awaitи некорректные вызовыAsyncMockв тестах - проверить очистку ресурсов в блоках
finallyдля yield-фикстур - устранить дублирование проверок с помощью
@pytest.mark.parametrize - выявить ошибки в путях
patch(), указанных не в месте вызова
Примеры запросов агенту
- Проверь
tests/test_auth.pyи найди ошибки в путях вызоваpatch() - Сделай ревью
tests/test_billing.pyиconftest.pyпо чеклисту pytest - Проанализируй
tests/test_api.pyна пропущенныеawaitв асинхронных тестах
Как установить pytest-code-review
1Через Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill pytest-code-review -a claude-code2Вручную: положить файлы
~/.claude/skills/pytest-code-review/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/pytest-code-review/
1Через Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill pytest-code-review -a codex2Вручную: положить файлы
.agents/skills/pytest-code-review/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill pytest-code-review -a cursor2Вручную: положить файлы
.cursor/skills/pytest-code-review/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install existential-birds/beagle plugins/beagle-python/skills/pytest-code-review2Вручную: положить файлы
.github/skills/pytest-code-review/SKILL.md1Через Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill pytest-code-review -a gemini-cli2Командой платформы
gemini skills install https://github.com/existential-birds/beagle --path plugins/beagle-python/skills/pytest-code-reviewВручную: положить файлы
.devin/skills/pytest-code-review/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill pytest-code-review -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о pytest-code-review
Как установить pytest-code-review в Claude Code?
Выполните в терминале команду npx skills add existential-birds/beagle --skill pytest-code-review -a claude-code. Файл скилла сохранится по пути ~/.claude/skills/pytest-code-review/SKILL.md.
Что делает скилл pytest-code-review?
Он проводит структурированный аудит тестов pytest по пяти гейтам, проверяя корректность асинхронных вызовов, область видимости фикстур, очистку ресурсов и пути импорта для patch().
Как скилл проверяет использование mock и patch?
Скилл требует подтверждать вызовы через assert_called_once_with, запрещает мокать внутренности вместо внешних зависимостей и следит, чтобы patch() применялся строго по месту вызова символа.
Исходный текст
SKILL.md · Apache-2.0
--- name: pytest-code-review description: Reviews pytest test code for async patterns, fixtures, parametrize, and mocking. Use when reviewing test_*.py files, checking async test functions, fixture usage, or mock patterns. --- # Pytest Code Review ## Quick Reference | Issue Type | Reference | |------------|-----------| | async def test_*, AsyncMock, await patterns | [references/async-testing.md](references/async-testing.md) | | conftest.py, factory fixtures, scope, cleanup | [references/fixtures.md](references/fixtures.md) | | @pytest.mark.parametrize, DRY patterns | [references/parametrize.md](references/parametrize.md) | | AsyncMock tracking, patch patterns, when to mock | [references/mocking.md](references/mocking.md) | ## Review gates Work in order. Do not assert pytest-specific problems until each applicable gate passes. 1. **Scoped files** — **Pass when:** You list every `test_*.py` and any `conftest.py` you will cite; no findings for files outside that list. 2. **Async vs sync** — **Pass when:** Per scoped file, you note whether it uses `async def test_*` / `await`; if yes, open [references/async-testing.md](references/async-testing.md) before criticizing async usage. 3. **Fixtures** — **Pass when:** If shared setup matters, you name the `conftest.py` path(s) or state none; for yield fixtures, confirm cleanup exists before claiming resource leaks. 4. **patch / mocks** — **Pass when:** For any `patch` or mock critique, you give the import path where the symbol is **used** (call site), or mark N/A; open [references/mocking.md](references/mocking.md) when mocking is central to the review. 5. **Findings** — **Pass when:** Each finding includes a file path and line(s) or test node id, not a generic rule restatement. ## Review Checklist - [ ] Test functions are `async def test_*` for async code under test - [ ] AsyncMock used for async dependencies, not Mock - [ ] All async mocks and coroutines are awaited - [ ] Fixtures in conftest.py for shared setup - [ ] Fixture scope appropriate (function, class, module, session) - [ ] Yield fixtures have proper cleanup in finally block - [ ] @pytest.mark.parametrize for similar test cases - [ ] No duplicated test logic across multiple test functions - [ ] Mocks track calls properly (assert_called_once_with) - [ ] patch() targets correct location (where used, not defined) - [ ] No mocking of internals that should be tested - [ ] Test isolation (no shared mutable state between tests) ## When to Load References - Reviewing async test functions → async-testing.md - Reviewing fixtures or conftest.py → fixtures.md - Reviewing similar test cases → parametrize.md - Reviewing mocks and patches → mocking.md ## Review Questions 1. Are all async functions tested with async def test_*? 2. Are fixtures properly scoped with appropriate cleanup? 3. Can similar test cases be parametrized to reduce duplication? 4. Are mocks tracking calls and used at the right locations?
© existential-birds · Apache-2.0 · existential-birds/beagle