Command Palette

Search for a command to run...

Назад к скиллам
скилл № 00699

test-writer

Write, extend, or review tests in any codebase. Use this skill whenever the user asks to write tests, add test coverage, test a new feature, fix failing…

БесплатноБез исполняемых скриптов
anchildress1от anchildress1★ 68 звёзд на GitHub

Установить test-writer в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Repo convention beats every preference below. Exception: the hard rules always win.

Step 0 — orient

Complete all of these before the first line of test code. Parallelize the reads.

  1. Read any AGENTS.md / CLAUDE.md in the directories under test that is not already in context.
  2. Read the source under test completely. Map every branch, early return, validation, and error path.
  3. Detect the framework (table below).
  4. Find the test command — package.json scripts.test, Makefile, pyproject.toml, or CI config. Required for the final verification step.
  5. Read existing tests for the module. Extract mock patterns, fixture shapes, naming. New tests must match them. None exist → check for tests/ or __tests__/; if neither, create one mirroring the source tree.
  6. Read the test config (vitest.config.ts, jest.config.ts, pytest.ini, pyproject.toml). Note coverage thresholds and exclusions.
  7. Read shared helpers and fixtures. Use what exists before inventing utilities.
  8. Decide which test types apply — unit, integration, e2e, performance, LHCI. Each has a different mock boundary.

Stack detection

Signal Framework
vitest.config.ts or vitest in package.json Vitest
jest.config.* or jest in package.json Jest
bunfig.toml, or bun test in scripts.test bun:test
pytest.ini, pyproject.toml [tool.pytest] pytest
.mocharc.* Mocha
cypress.config.* Cypress (e2e)
playwright.config.* Playwright (e2e)

Placement and naming follow the repo, always:

  • Co-located (src/foo.ts → src/foo.test.ts) or separate tree (tests/foo_test.py) — whichever already exists.
  • Bootstrapping from nothing: co-locate unit tests, put integration/e2e in tests/.
  • TS/JS <module>.test.ts or .spec.ts · Python test_<module>.py. Never mix styles inside one project.

Hard rules

  • No .skip. Diagnose the real cause — source, mock, or test logic — and fix it.
  • Never lower a coverage threshold. The config value is a floor. Coverage dropped → write more tests.
  • No copy-pasted bodies. Shared setup → beforeEach. Tests differing only in input/output → parametric (it.each, @pytest.mark.parametrize).
  • Assert result shape AND mock interactions. Return value alone misses wrong downstream calls; mock calls alone miss what the caller produced.
  • Self-contained. No dependence on execution order or on state beforeEach does not reset. Passes alone, fails in-suite → broken test.
  • Fix the source, not the assertion. A bug found while testing gets fixed first, then tested against correct behavior.

Naming

verb + subject + condition — a reader who has never seen the source knows what is verified and when, without opening the body.

it('returns 404 when the card does not exist')
it('normalizes whitespace-only url to undefined')
it('rejects signal above 5')
it('excludes soft-deleted cards from results by default')
it('handles partial batch failure without failing the whole run')

Never it('works'), it('test 1'), it('should be correct').

describe blocks encode shared context: describe('when the database returns an error').

Structure — Arrange / Act / Assert

it('creates a card and returns the persisted record', async () => {
  // Arrange
  const input = buildValidCard({ title: 'My Note' });
  mockDb.upsert.mockResolvedValue({ data: input, error: null });

  // Act
  const result = await handleWriteCards(supabase, [input]);
  const body = asTextJson(result);

  // Assert
  expect(body.written).toBe(1);
  expect(body.results[0].title).toBe('My Note');
  expect(mockDb.upsert).toHaveBeenCalledWith(
    expect.objectContaining({ title: 'My Note' }),
    expect.anything(),
  );
});

Required coverage

Work every row for each function, handler, or route. Never skip a row as obvious.

Path Cover
Happy Valid input, all required fields, dependencies succeed. Assert full response shape and every mock call argument.
Negative / validation Each required field missing individually · wrong types · out-of-range · whitespace-only strings · empty and oversized collections · bad formats (UUID, URL, email, datetime).
Dependency failure DB/API returns an error object · HTTP call fails · file absent. Assert the caller surfaces it — correct status, message, isError.
Unexpected throw Dependency throws synchronously or rejects. Assert the outer handler catches and returns a safe structured response.
Edge null/undefined optionals · empty arrays · boundaries (min, max, exactly at, one over) · whitespace normalization · timezone offsets · circular refs where serialized · state transitions (soft-delete on/off, flag on/off).

Any input that takes a different code path gets a test.

Schemas and validators — per field: valid full input · each required field missing (error names the fiel

Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл test-writer?

Write, extend, or review tests in any codebase. Use this skill whenever the user asks to write tests, add test coverage, test a new feature, fix failing tests, or audit existing test files — regardless of language, framework, or project. Also trigger for "add tests for", "write tests for", "cover this with tests", "test this file", "update the tests", "improve coverage", or "this needs tests". This skill enforces universal testing rules (no .skip, no lowering thresholds, full-path coverage) and adapts its mock patterns and tooling to whatever stack the repo uses.

Как установить скилл test-writer?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл test-writer запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

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

Сравнить test-writer с