git-agent for Python

Conventional commits for Python projects, automatically

git-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)
git-agent output
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.
  • Recognizes Django, Flask, and FastAPI project layouts for accurate scope detection
  • Understands Pydantic model changes and migration diffs
  • Handles monorepo Python services independently, committing each service atomically
  • Works with pyproject.toml and setup.cfg-based projects out of the box
brew install gitagenthq/tap/git-agent # inside your Python repo git-agent init # detects pyproject.toml / setup.cfg and suggests scopes
Does git-agent work with Django migrations?
Yes. git-agent detects migration files and treats them as a separate atomic commit with scope migrations, keeping them out of your feature commits.
Can I use git-agent with a virtual environment or conda?
git-agent is a standalone Go binary installed via Homebrew. It does not run inside your Python environment and requires no pip install.
How does git-agent determine scopes for Python projects?
Running 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.