test:first

A command for writing a failing pytest test before implementing a feature. This is the red phase of test-driven development (TDD), a method that cycles through writing a failing test, making it pass, and then improving the code.

In plain words
What is it for?
Use it to choose test scenarios and locations, set up mocks, and create a first test for a new function, service, or endpoint.
Why use it?
It gives the implementation a clear expected behavior first and helps catch missing edge cases early.

Command

Part of the python plugin — 4 skills, 10 commands, 1 agent, 1 hook shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/ruslan-korneev/claude-plugins/test-first
Clone the repo
git clone --depth 1 https://github.com/ruslan-korneev/claude-plugins

Or install python, the plugin that ships this one along with the rest of its 4 skills, 10 commands, 1 agent, 1 hook.

Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,197 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00017 $0.01197
Opus 5 $0.00009 $0.00598
Sonnet 5 $0.00003 $0.00239
Haiku 4.5 $0.00002 $0.00120

Measured 3d ago against content hash 04a69f46579e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

test:first scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/python/commands/test-first.md · 203 lines

How it starts

The opening of the file, as written. The whole thing — 203 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Command /test:first — TDD Red Phase

Create a test BEFORE writing implementation. This is the key command for TDD workflow.

TDD Principle

  1. Red — write a failing test (this command)
  2. Green — write minimal code to pass the test
  3. Refactor — improve code while keeping tests green

Instructions

Step 1: Determine test structure

Based on the feature description, determine:

  • What to test (function, method, endpoint)
  • Which scenarios to cover (happy path, edge cases, errors)
  • Which dependencies to mock

Step 2: Determine test location

src/modules/users/services.py → tests/modules/users/test_services.py
src/modules/users/routers.py → tests/modules/users/test_routers.py
src/core/security.py → tests/core/test_security.py

Step 3: Create a failing test

import pytest
from unittest.mock import AsyncMock, MagicMock

# Import what does NOT exist yet — test will fail
from src.modules.users.services import UserService


class TestUserService:
    """Tests for UserService — user creation."""

    @pytest.fixture
    def mock_repository(self) -> AsyncMock:
        """Mock repository."""
        return AsyncMock()

    @pytest.fixture
    def service(self, mock_repository: AsyncMock) -> UserService:
        """Service with mocked dependencies."""
        return UserService(repository=mock_repository)

    async def test_create_user_success(
        self,
        service: UserService,
        mock_repository: AsyncMock,
    ) -> None:
        """Successful user creation."""
        # Arrange
        user_data = {"email": "[email protected]", "name": "Test User"}
        mock_repository.save.return_value = {"id": 1, **user_data}

        # Act
        result = await service.create(user_data)

        # Assert
        assert result["id"] == 1
        assert result["email"] == "[email protected]"
        mock_repository.save.assert_called_once()

    async def test_create_user_duplicate_email_raises_conflict(
        self,
        service: UserService,
        mock_repository: AsyncMock,
    ) -> None:
        """Creating user with existing email raises ConflictError."""
        # Arrange
        from src.core.exceptions import ConflictError

        user_data = {"email": "[email protected]", "name": "Test User"}
        mock_repository.get_by_email.return_value = {"id": 1}  # already exists

        # Act & Assert
        with pytest.raises(ConflictError):
            await service.create(user_data)

Read the full file on GitHub · 203 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 203 lines · 17 tokens per session scan A 04a69f46579e

Subscribe to this mod's changes

test:first is a command published in the GitHub repository ruslan-korneev/claude-plugins (4 stars, last pushed 6mo ago), licensed MIT. It adds 17 tokens to every session and 1,197 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.