$ recombobulate _
home / tips / use-claude-to-scaffold-a-fastapi-application-with-auth
116

Use Claude to Scaffold a FastAPI Application with Auth

recombobulate @recombobulate · Mar 26, 2026 · Workflows
use-claude-to-scaffold-a-fastapi-application-with-auth

FastAPI's async-first design and automatic docs are great — but the boilerplate for JWT auth, schemas, and routing still slows you down. Let Claude bootstrap the whole thing.

Scaffold a FastAPI app with JWT authentication. Include /auth/register and /auth/login endpoints, a /users/me protected route, SQLAlchemy models for User, and Pydantic schemas. Use bcrypt for password hashing and Alembic for migrations.

Claude generates the full project structure with working auth middleware, a reusable get_current_user dependency, and wired-up OpenAPI schemas — so /docs shows the lock icon on every protected route automatically.

The generated dependency looks like this:

async def get_current_user(
    token: str = Depends(oauth2_scheme),
    db: AsyncSession = Depends(get_db),
) -> User:
    payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
    user = await db.get(User, payload.get("sub"))
    if not user:
        raise HTTPException(status_code=401, detail="Invalid credentials")
    return user

From there, layer on more features without fighting the plumbing:

Add role-based access control with admin and standard roles. Admin-only routes should raise 403 for standard users.

Ask Claude to extend it with refresh tokens, rate limiting via slowapi, or background tasks using FastAPI's BackgroundTasks — one requirement at a time.

Start with a production-grade foundation — not a tutorial skeleton.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 day ago