AGENT SKILL

legacy-tests

Use when running Step 3.2 of legacy refactoring protocol — generates contract/characterization/architecture tests for the new module before any cutover. Triggers on '/legacy-tests <module>' or when user asks to 'згенерувати тести для legacy', 'characterization tests', 'fix point of reference'.

License 许可
MIT
最近更新
2026-11-12
Stars
★ 15
Forks
13

01 前言 Front Matter

name
legacy-tests
description
Use when running Step 3.2 of legacy refactoring protocol — generates contract/characterization/architecture tests for the new module before any cutover. Triggers on '/legacy-tests <module>' or when user asks to 'згенерувати тести для legacy', 'characterization tests', 'fix point of reference'.
allowed-tools
Read, Write, Edit, Bash, Glob
argument-hint
<module-name>
disable-model-invocation
false

03 SKILL.md 正文

legacy-tests — Step 3.2 фіксація поведінки тестами

Генерує три обовʼязкові типи тестів у tests/<module>/ + два опційні. Усі мають бути зелені на legacy-реалізації перед finalize-плану.

Аргументи

  • <module-name> — імʼя нового модуля.

Inputs

  • LEGACY/<module>.md (Step 2)
  • PLAN.md skeleton (Step 3.1) — для public interface

Three obligatory test types

1. Contract tests — tests/<module>/contract/

Перевіряють що public interface поводить себе як описано у apps/api/openapi.yaml (відповіді, статус-коди, формат). Не перевіряють внутрішню логіку.

2. Characterization tests — tests/<module>/characterization/

Параметризовані тести з 15-20 кейсами вхід→вихід (кейси беруться з LEGACY/<module>.md секція 4 + доповнюються через subagent).

3. Architecture tests — tests/<module>/architecture/

Перевіряють що нова архітектура domain → app → infra → ports дотримана. Через import-linter або pytest-кастомні правила:

# tests/account/architecture/test_layers.py
import pytest
import importlib
import inspect

def test_domain_does_not_import_infra():
    domain = importlib.import_module("internal.account.domain")
    src = inspect.getsource(domain)
    assert "internal.account.infra" not in src, "domain не має знати про infra"

Або через .importlinter config + lint-imports.

Optional (nice to have)

4. Integration tests — tests/<module>/integration/

Через server.setup_app(): повний флоу через DI-точку. HTTP-шару в демо немає; у проєкті з веб-фреймворком тут був би його тестовий клієнт.

5. Unit tests — tests/<module>/unit/

Точкові тести на domain validators (для edge cases hypothesis-based).

Subagent для генерації characterization-кейсів

Read LEGACY/<module>.md + public interface з PLAN.md skeleton.
Поверни 15-20 пар вхід→вихід у форматі:

@pytest.mark.parametrize("input1,input2,expected", [
  ("...", "...", "..."),
  ...
])

Включи:
- Усі приклади з LEGACY секція 4
- Edge cases: empty, very long, unicode, duplicates
- Error cases: invalid format, taken value, expired token
- Race condition cases (rate limit, concurrent register)

Без імплементації тесту, тільки список кейсів і необхідні моки.

Acceptance criteria

  • tests/<module>/{contract,characterization,architecture}/ створені
  • Кожна папка має ≥1 test_*.py файл
  • characterization має 15-20 кейсів через parametrize
  • architecture перевіряє хоча б 1 layer constraint
  • pytest tests/<module> зелений
  • Тести не використовують мовчазних мокіів — кожен мок або підтверджує виклик через mock.assert_called_with(...), або не використовується

Verification: smell-test через "deliberate breakage"

Перед тим як finalize-плану — тимчасово зламай legacy реалізацію:

# у internal/users/registration.py замінити return на None
sed -i.bak 's/return {"status"/return None  # broken/' internal/users/registration.py
pytest tests/account/  # має почервоніти
mv internal/users/registration.py.bak internal/users/registration.py
pytest tests/account/  # знов зелено

Якщо breakage не червонить тест — це привид. Виправ, потім finalize.

Examples

/legacy-tests account
pytest tests/account/  # has to be green
/legacy-plan account --phase=finalize

Anti-patterns

  • Не дозволь subagent повертати тест із assert True — це привид. Skill валідовує: grep "assert True" tests/<module> має дати 0 матчів.
  • Не мокай так, щоби мок повертав None — це призводить до silent pass. Кожен мок має або реальний return value, або assert_called_with.
  • Не лий усі тести в один файл — три типи тестів живуть у трьох папках, інакше характеристичні і архітектурні мішаються і ламається структура звіту.

04 同仓库更多 Skills

genkovich
genkovich/agentic-engineering-course-public

release

Run the whole local release pipeline in order, stopping at each human gate. Triggers on "run the release", "prepare a release", "/release", "зроби реліз", "підготуй реліз". Drives the four stages back to back — bump-version → curate-changelog → release-notes → check-docs-drift — pausing after each so the human reviews the diff before the next stage. Prepares everything in the working tree; never tags, commits, or pushes. The tag push (which fires CI) stays the human's action.

★ 15
genkovich
genkovich/agentic-engineering-course-public

release-notes

Draft partner-facing release notes from the same commits as the changelog. Triggers on "draft release notes", "release notes for the next version", "/release-notes", "нотатки релізу", "release notes партнеру". Same input as curate-changelog, different audience and tone: a short, benefit-first narrative for a user or partner — "what's new for you" — not a categorized engineer's list. Keeps only changes a user actually notices; drops internal refactors and tooling. Prints the notes to the chat to seed a GitHub Release description or a partner announcement. Writes no file.

★ 15
genkovich
genkovich/agentic-engineering-course-public

curate-changelog

Curate the [Unreleased] section of docs/CHANGELOG.md from git history. Triggers on "curate the changelog", "update the changelog", "/curate-changelog", "онови changelog", "курування журналу". Reads git log since the last tag, FILTERS out what a reader never feels (test/ci/chore/merge), GROUPS commits about one feature into one bullet, and REWRITES technical subjects into plain language under the six Keep a Changelog categories (Added/Changed/Deprecated/ Removed/Fixed/Security). The result must have FEWER lines than the raw log — that is the proof of curation, not a dump. Leaves the edit in the working tree; never commits or pushes.

★ 15
genkovich
genkovich/agentic-engineering-course-public

codify-rule

Turn a repeated mistake into a durable, path-scoped rule in .claude/rules/. Triggers on "codify this rule", "make a rule so this doesn't happen again", "/codify-rule", "закодифікуй правило", "петля помилка-правило". Use only when the same mistake showed up TWICE (twice = a pattern, once = noise). Names the wrong shape and the right shape with one short example of each, scopes the rule to the paths that matter, and leaves the edit in the working tree so the next agent on this repo inherits the fix. Edits only .claude/rules/; never commits or pushes.

★ 15
genkovich
genkovich/agentic-engineering-course-public

check-docs-drift

Find and fix where docs/api.md fell behind the code. Triggers on "check for doc drift", "is the API doc up to date", "/check-docs-drift", "перевір дрейф документації", "docs drift". Runs the deterministic scripts/check-docs-drift.py (parses the public NoteBook methods with ast, compares to what docs/api.md documents — NO LLM finds the gap), reports the drift, and PROPOSES the doc edit that closes it. The gap is found by parsing; the agent writes the missing documentation in the doc's existing style. Edits only docs/; never commits or pushes.

★ 15
genkovich
genkovich/agentic-engineering-course-public

bump-version

Decide and apply the next semver for a release. Triggers on "bump the version", "what version is next", "/bump-version", "простав версію", "яка наступна версія". Reads the next number from the deterministic scripts/next-version.sh (NEVER guesses it), explains in plain language WHICH part moved and why (e.g. "MINOR, because a feat landed: filter notes by tag"), edits the version line in pyproject.toml, and proposes the matching `git tag vX.Y.Z`. The number is decided by a rule; the agent explains and applies — the human confirms the tag. Never pushes a tag itself.

★ 15