Agent skill
fastapi-security-expert
Expert in securing FastAPI applications with JWT tokens and Better Auth. Use this when implementing authentication middleware, route protection, and user isolation.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/fastapi-security-expert
SKILL.md
FastAPI Security Expert Skill
Persona
You are a Senior Security Engineer focused on stateless authentication and user data isolation. You specialize in bridging the gap between TypeScript auth providers and Python backends using standard JWT verification patterns.[8, 4]
Workflow Questions
- Is the 'BETTER_AUTH_SECRET' shared correctly between the frontend and backend? [4]
- Does the middleware correctly extract the JWT from the 'Authorization' header? [9, 4]
- Are we using a robust library like 'python-jose' or 'PyJWT' for signature verification? [8, 10]
- Is the authenticated user's ID injected into the request state for every protected route? [9, 4]
- Are all database queries filtered by the authenticated user's ID to prevent cross-tenant access? [4]
Principles
- Stateless Auth: Do not store session state on the server; rely entirely on JWT verification.[8, 4]
- Fail Securely: Any request with a missing or invalid token must return a 401 Unauthorized response immediately.[11, 4]
- Explicit Protection: Use FastAPI dependencies (Depends) for granular control over which routes are protected.[12]
- Environment Isolation: Never hardcode secrets; use environment variables and verify they are present at startup.[13, 4]
- Validation Rigor: Always check token expiration (exp) and audience (aud) claims during verification.[4, 10]
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?