/dev-tools:writing-tests-pg-datafrom dev-tools
Instructions for writing tests for PG Data services, likely involving database fixtures and integration tests.
Ships in dev-tools. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
If this plugin is not initialized or an Agent IX command fails, read the dev-tools setup guide for its prerequisites and local diagnosis.
This skill provides guidelines for writing tests for services using SQLModel and postgres, aligned with the Agent-IX Golden Path.
Source Spec: Derived from pg-data-service (SQLModel, Alembic).
pytest-sqlmodel. This plugin provides all necessary fixtures and database management.postgres fixture. Do not use SQLite/in-memory databases.db_session fixture provided by pytest-sqlmodel handles transaction isolation (rollbacks) automatically.Standard fixtures used in conftest.py (provided by pytest-sqlmodel):
db_session: A Session object isolated by a transaction. Use this for DB interactions in tests.postgres: The underlying testcontainers or service-managed postgres instance URL.client: A TestClient with the session dependency overridden to use db_session.Test that models can be created and retrieved.
class TestHeroModel:
"""Tests for the Hero model."""
def test_create_hero(self, session: Session):
"""
Description:
Test that a Hero can be created and persisted.
Assumptions:
- Database is available
- Session is active
Criteria:
- Hero is saved with a generated ID
- Fields match input values
Trace: FR-001-AC-1
"""
hero = Hero(name="Deadpond", secret_name="Dive Wilson")
session.add(hero)
session.commit()
session.refresh(hero)
assert hero.id is not None
assert hero.age is None
Test that endpoints interact correctly with the DB.
class TestHeroAPI:
"""Tests for the Hero API endpoints."""
def test_create_hero_api(self, client: TestClient):
"""
Description:
Test the create hero POST endpoint.
Assumptions:
- API is running
- Database connection is valid
Criteria:
- Returns 200 OK
- Response contains created hero with ID
"""
response = client.post(
"/heroes/",
json={"name": "Spider-Boy", "secret_name": "Pedro Parqueador"}
)
data = response.json()
assert response.status_code == 200
assert data["name"] == "Spider-Boy"
assert data["id"] is not None
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub agent-ix/dev-tools --plugin dev-tools15 skills in this plugin
/audit-commentsAudit comments in a repository or bounded code section, remove tautologies and stale notes, convert decision records to ADRs, file issues for hack-enabling excuses, and add a ratcheting lint rule. Use when asked to audit or delete code comments./backport-codeA skill for systematically backporting bug fixes and features across specs, templates, and downstream repositories./code-reviewReview code for Agent-IX Golden Path compliance, focusing on test style, mock boundaries, implementation gaps, and code-test alignment. Dispatches by language — Python inline, Rust via `rust-review`, React via `review-react`.Other plugins' skills for the same job