git-agent for Pythongit-agent understands Django, Flask, FastAPI, and standard Python project layouts, splitting your staged changes into meaningful atomic commits with properly scoped conventional messages.
diff --git a/app/api/users.py b/app/api/users.py
index 3a1f2c4..8b9d1e7 100644
--- a/app/api/users.py
+++ b/app/api/users.py
@@ -12,6 +12,14 @@ from app.models import User
from app.schemas import UserCreate, UserRead
from app.database import get_db
+class UserAlreadyExistsError(Exception):
+ """Raised when attempting to create a user with a duplicate email."""
+ pass
+
async def create_user(db: AsyncSession, payload: UserCreate) -> UserRead:
- user = User(**payload.dict())
- db.add(user)
- await db.commit()
- return UserRead.from_orm(user)
+ existing = await db.execute(select(User).where(User.email == payload.email))
+ if existing.scalar_one_or_none():
+ raise UserAlreadyExistsError(f"email {payload.email!r} already registered")
+ user = User(**payload.model_dump())
+ db.add(user)
+ await db.commit()
+ await db.refresh(user)
+ return UserRead.model_validate(user)feat(users): guard against duplicate email on creation
- add UserAlreadyExistsError domain exception
- check for existing email before insert to avoid db constraint failures
- migrate payload.dict() to payload.model_dump() for Pydantic v2 compatibility
Prevents a 500 on duplicate-email POST /users; callers now receive a
clear exception they can map to 409 Conflict at the HTTP layer.brew install gitagenthq/tap/git-agent
# inside your Python repo
git-agent init # detects pyproject.toml / setup.cfg and suggests scopesDoes git-agent work with Django migrations?migrations, keeping them out of your feature commits.Can I use git-agent with a virtual environment or conda?How does git-agent determine scopes for Python projects?git-agent init scans your git history to infer scopes from your directory structure, then writes them to .git-agent/project.yml for consistent scope suggestions.