agentleFS
dperezcabreradperezcabrera/pico-skills/.claude/skills/add-tests/SKILL.md

add-tests

Skill4 starsChanged 4 months agoMITView on GitHub

Generate tests for pico components. Use when creating unit tests, integration tests, or test fixtures for services, repositories, controllers, or agents.

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the component source code first, then generate tests following these patterns.

    line 12

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Add Tests

Generate tests for: $ARGUMENTS

Read the component source code first, then generate tests following these patterns.

Service Test (unit)

import pytest
from unittest.mock import AsyncMock

class TestMyService:
    @pytest.fixture
    def mock_repo(self):
        repo = AsyncMock()
        repo.find_by_id.return_value = User(id=1, name="Alice")
        return repo

    @pytest.fixture
    def service(self, mock_repo):
        return MyService(repo=mock_repo)

    @pytest.mark.asyncio
    async def test_get_user_returns_user(self, service):
        result = await service.get_user(1)
        assert result.name == "Alice"

    @pytest.mark.asyncio
    async def test_get_user_raises_when_not_found(self, service, mock_repo):
        mock_repo.find_by_id.return_value = None
        with pytest.raises(ValueError, match="not found"):
            await service.get_user(999)

Repository Test (integration, in-memory DB)

import pytest
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
from pico_sqlalchemy import SessionManager, AppBase

@pytest.fixture
async def session_manager():
    engine = create_async_engine("sqlite+aiosqlite:///:memory:")
    async with engine.begin() as conn:
        await conn.run_sync(AppBase.metadata.create_all)
    sm = SessionManager(async_sessionmaker(engine))
    yield sm
    await engine.dispose()

@pytest.fixture
def repo(session_manager):
    return UserRepository(manager=session_manager)

class TestUserRepository:
    @pytest.mark.asyncio
    async def test_save_and_find(self, repo, session_manager):
        async with session_manager.transaction():
            user = await repo.save(User(name="Alice"))
            found = await repo.find_by_id(user.id)
            assert found.name == "Alice"

Controller Test (HTTP)

import pytest
from httpx import AsyncClient, ASGITransport

@pytest.fixture
async def client(app):
    transport = ASGITransport(app=app)
    async with AsyncClient(transport=transport, base_url="http://test") as c:
        yield c

class TestItemController:
    @pytest.mark.asyncio
    async def test_list_items(self, client):
        response = await client.get("/items/")
        assert response.status_code == 200

    @pytest.mark.asyncio
    async def test_create_item(self, client):
        response = await client.post("/items/", json={"name": "Test"})
        assert response.status_code == 201

Container Integration Test

from pico_ioc import init

class TestIntegration:
    @pytest.fixture
    def container(self):
        return init(modules=[__name__])

    def test_service_resolves(self, container):
        service = container.get(MyService)
        assert service is not None

Checklist

  • Unit tests with mocked dependencies
  • Happy path and error cases covered
  • Async tests use @pytest.mark.asyncio
  • Fixtures for reusable setup
  • Test naming: test_<method>_<scenario>

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.