Add Game Subsystem

VerifiedCaution

Scaffolds a complete new game subsystem end-to-end: models, service, router, schemas, migrations, OpenAPI spec, and tests. Use this skill when adding a major new game feature that spans multiple layers (database, service, API, tests), such as a crafting system, an auction house, a reputation system, or a quest system.

Sby Skills Guide Bot
DevelopmentIntermediate
1606/2/2026
Claude CodeCursorWindsurfCopilotCodex
#game-development#scaffolding#backend#api#testing

Recommended for

Our review

This skill scaffolds a complete new game subsystem end-to-end, including models, service, router, schemas, migrations, OpenAPI spec, and tests.

Strengths

  • Automates creation of a full backend pipeline (model → migration → API)
  • Enforces best practices (UUID, optimistic locking, timestamps)
  • Includes error handling and telemetry out-of-the-box
  • Modular and extensible structure

Limitations

  • Does not cover frontend integration or complex business logic
  • Assumes an existing architecture (FastAPI, SQLAlchemy, Pydantic)
  • Generated tests are skeletons and need to be filled in
When to use it

Use this skill when adding a major game feature that requires new database tables, API endpoints, and testing.

When not to use it

Do not use it for minor changes to existing features or when the subsystem is trivial enough to add manually.

Security analysis

Caution
Quality score95/100

The skill instructs using Docker containers and database migrations, which are powerful operations. While legitimate for development, misapplication could disrupt local environments. The telemetry call may collect player data, requiring careful implementation to avoid privacy issues.

Findings
  • Uses make and docker commands that control development environment and database migrations
  • Telemetry emission could collect player data; ensure proper anonymization and consent

Examples

Crafting system scaffold
Add a new game subsystem for crafting. Entities needed: CraftingRecipe, CraftingSession, CraftingResult. Include models, service, router, schemas, migration, and tests.
Auction house subsystem
Create an auction house subsystem with AuctionListing, Bid, and AuctionHistory entities. Generate the full pipeline: models, service, router, schemas, migration, OpenAPI spec, and tests.
Quest system scaffold
Scaffold a quest system with Quest, QuestObjective, and PlayerQuestProgress entities. Include all layers: models, service, router, schemas, migration, and test stubs.

Skill: Add Game Subsystem

Scaffold a complete new game subsystem end-to-end: models, service, router, schemas, migrations, OpenAPI spec, and tests.

When to Use

Use this skill when adding a major new game feature that spans multiple layers (database, service, API, tests). Examples: a crafting system, an auction house, a reputation system, a quest system.

Instructions

1. Design the domain model

Before writing code, identify:

  • Entities: What new database tables are needed?
  • Relationships: How do they relate to existing entities (Player, Entity, Party)?
  • Determinism: Does any logic need seeded randomness?
  • State machines: What status transitions exist (e.g., active → completed → expired)?

2. Create database models

Add SQLAlchemy models to server/app/core/models.py or a new entity file:

class MySubsystemRecord(Base):
    __tablename__ = "my_subsystem_records"

    id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    entity_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("entities.id"), nullable=False)
    status: Mapped[str] = mapped_column(String, nullable=False, default="active")
    version: Mapped[int] = mapped_column(Integer, nullable=False, default=1)
    created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())

    entity: Mapped["Entity"] = relationship(back_populates="subsystem_records")

Always include: id (UUID), version (optimistic concurrency), created_at.

3. Generate database migration

make docker-up
make docker-migrate-revision m="add_my_subsystem_tables"
make docker-migrate

Review the generated migration in server/migrations/versions/.

4. Create Pydantic schemas

Add request/response models to server/app/core/models.py (response models) and server/app/core/schemas.py (request validation):

# Response model
class MySubsystemResponse(BaseModel):
    id: str
    entity_id: str
    status: str
    created_at: datetime

    model_config = ConfigDict(from_attributes=True)

# Request model
class CreateMySubsystemRequest(BaseModel):
    entity_id: str
    parameters: dict[str, Any] = Field(default_factory=dict)

5. Create the service

Create server/app/core/my_subsystem_service.py:

class MySubsystemService:
    def __init__(self, session: Session) -> None:
        self._session = session

    def create(self, entity: Entity, *, player: Player, seed: int | None = None) -> MySubsystemRecord:
        if entity.player_id != player.id:
            raise DomainForbidden()
        record = MySubsystemRecord(entity_id=entity.id, ...)
        self._session.add(record)
        self._session.flush()
        return record

For complex subsystems, use a subdirectory: server/app/core/my_subsystem/.

6. Add the dependency provider

In server/app/api/dependencies.py:

def get_my_subsystem_service(session: Session = Depends(get_db_session)) -> MySubsystemService:
    return MySubsystemService(session)

7. Create the router

Create server/app/api/my_subsystem.py:

router = APIRouter(prefix="/my-subsystem", tags=["my-subsystem"])

@router.post("/", response_model=MySubsystemResponse, status_code=201)
def create_record(
    *,
    payload: CreateMySubsystemRequest,
    service: MySubsystemService = Depends(get_my_subsystem_service),
    session: Session = Depends(get_db_session),
    player: Player = Depends(get_current_player),
) -> MySubsystemResponse:
    entity = session.get(Entity, payload.entity_id)
    if entity is None:
        raise DomainNotFound("Entity not found")
    result = service.create(entity, player=player)
    telemetry_emit("my_subsystem.created", player_id=str(player.id))
    return MySubsystemResponse.model_validate(result)

8. Register the router

In server/app/main.py:

  1. Import the router
  2. Add to _ROUTERS list

In server/app/api/__init__.py:

  1. Export the router

9. Update OpenAPI spec

Add all new paths and schemas to server/openapi/openapi.yaml. Validate:

make docker-openapi-validate

10. Write comprehensive tests

Create tests/test_my_subsystem.py:

  • Unit tests (@pytest.mark.unit) for pure service logic
  • Integration tests (@pytest.mark.integration) for API endpoints
  • Determinism tests (same seed = same output) if applicable
  • Error case tests (404, 403, 409)
  • Edge case tests (empty inputs, boundary values)
  • Property-based tests (Hypothesis) for complex logic

11. Validate everything

make docker-lint
make docker-test
make docker-openapi-validate

Coverage must remain at 99%.

12. Document

  • Update docs/DOMAIN_MODEL.md if the subsystem introduces new domain concepts
  • Update docs/API_COVERAGE_ANALYSIS.md with new endpoint status
  • Add subsystem-specific docs in docs/agents/ if the subsystem is complex
Related skills