py-feature
Skill3 starsChanged 9 months agoMITView on GitHub
Use when implementing a new feature, endpoint, or use case in a Python/FastAPI backend with clean architecture, SQLAlchemy, and PostgreSQL
In this repository36 other files it gives its agents.
- adrSkill
- analyticsSkill
- api-contractSkill
- api-designSkill
- ci-pipelineSkill
- claude-mdSkill
- code-qualitySkill
- data-modelSkill
- db-migrateSkill
- debugSkill
- deploySkill
- dep-updateSkill
- disk-cleanupSkill
- docker-buildSkill
- eng-leadSkill
- event-drivenSkill
- fullstack-healthcheckSkill
- go-featureSkill
- go-integration-testSkill
- go-refactorSkill
- go-scaffoldSkill
- incident-responseSkill
- interactive-clarifySkill
- observabilitySkill
- onboardingSkill
- product-specSkill
- py-integration-testSkill
- py-migrateSkill
- py-refactorSkill
- py-scaffoldSkill
- react-featureSkill
- react-refactorSkill
- react-scaffoldSkill
- review-codeSkill
- securitySkill
- system-designSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Core principle: Every layer gets its own test before implementation.
- Very specific: line 80
Test with mocks: Use unittest.mock.AsyncMock for the protocol.
- Distinctive: line 133
All functions have return type annotations
- Very specific: line 142
REQUIRED: Follow code-quality standards — no N+1 queries (use selectinload/joinedload), batch operations, set-based lookups, asyncio.gather …
- Very specific: line 143
REQUIRED: Update CLAUDE.md if new conventions, commands, or patterns are introduced (claude-md)
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Feature Development
Overview
Layer-by-layer TDD workflow for FastAPI backends following clean architecture. Build inside-out: domain → application → infrastructure → interfaces. All code fully typed with mypy strict.
Core principle: Every layer gets its own test before implementation. Type safety is non-negotiable.
Layer-by-Layer Workflow
1. Domain Entity + Validation
# src/domain/user.py
from dataclasses import dataclass, field
from datetime import datetime
from uuid import UUID, uuid4
@dataclass(frozen=True)
class User:
email: str
name: str
id: UUID = field(default_factory=uuid4)
created_at: datetime = field(default_factory=datetime.utcnow)
def __post_init__(self) -> None:
if not self.email:
raise ValueError("Email is required")Test first: Parametrized tests for validation.
@pytest.mark.parametrize("email,expected_error", [
("valid@test.com", None),
("", "Email is required"),
])
def test_create_user(email: str, expected_error: str | None) -> None:
if expected_error:
with pytest.raises(ValueError, match=expected_error):
User(email=email, name="Test")
else:
user = User(email=email, name="Test")
assert user.email == email2. Repository Protocol (in domain)
# src/domain/repositories.py
from typing import Protocol
class UserRepository(Protocol):
async def create(self, user: User) -> User: ...
async def get_by_id(self, id: UUID) -> User | None: ...
async def get_by_email(self, email: str) -> User | None: ...3. Use Case + Mock Tests
# src/application/create_user.py
class CreateUserUseCase:
def __init__(self, repo: UserRepository) -> None:
self._repo = repo
async def execute(self, input: CreateUserInput) -> User:
existing = await self._repo.get_by_email(input.email)
if existing:
raise DuplicateEmailError(input.email)
user = User(email=input.email, name=input.name)
return await self._repo.create(user)Test with mocks: Use unittest.mock.AsyncMock for the protocol.
4. SQLAlchemy Repository + Integration Test
# src/infrastructure/postgres/user_repository.py
class SQLAlchemyUserRepository:
def __init__(self, session: AsyncSession) -> None:
self._session = session
async def create(self, user: User) -> User:
model = UserModel.from_domain(user)
self._session.add(model)
await self._session.flush()
return model.to_domain()REQUIRED: Invoke py-integration-test for testcontainers patterns.
5. FastAPI Router + HTTP Test
# src/interfaces/http/users.py
router = APIRouter(prefix="/users", tags=["users"])
@router.post("/", status_code=201, response_model=UserResponse)
async def create_user(
body: CreateUserRequest,
use_case: CreateUserUseCase = Depends(get_create_user),
) -> UserResponse:
result = await use_case.execute(body.to_input())
return UserResponse.from_domain(result)Test with httpx:
async def test_create_user(client: AsyncClient) -> None:
resp = await client.post("/api/v1/users", json={"email": "t@t.com", "name": "T"})
assert resp.status_code == 201
assert resp.json()["data"]["email"] == "t@t.com"Quick Reference
| Layer | Package | Tests | Dependencies |
| Domain | src/domain/ | Unit (parametrize) | None |
| Application | src/application/ | Unit (AsyncMock) | Domain |
| Infrastructure | src/infrastructure/ | Integration (testcontainers) | Domain, SQLAlchemy |
| Interfaces | src/interfaces/http/ | HTTP (httpx AsyncClient) | Application |
Type Safety Checklist
- All functions have return type annotations
Protocolfor repository interfaces (not ABC)Mapped[type]for SQLAlchemy models- Pydantic
BaseModelfor request/response AsyncGeneratorfor session fixtures
Chains
- REQUIRED: Invoke
superpowers:test-driven-developmentat each layer - REQUIRED: Follow
code-qualitystandards — no N+1 queries (useselectinload/joinedload), batch operations, set-based lookups, asyncio.gather for independent I/O - REQUIRED: Update CLAUDE.md if new conventions, commands, or patterns are introduced (
claude-md) - Schema changes: Invoke
py-migratebefore implementing repository - API conventions: Reference
api-designfor request/response patterns
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
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.

