Add Authentication
Workflow for implementing auth checks on routes or features
CLAUDE.md
When adding authentication to a route or feature:
- Identify which routes or actions require authentication.
- Use the existing auth middleware or guard pattern in the project — don’t invent a new one.
- Add the auth check to each route. Verify it returns 401 for unauthenticated requests.
- If the feature requires authorization (not just authentication), check the user’s role or permissions and return 403 for unauthorized access.
- Write tests for: authenticated access (200), unauthenticated access (401), and unauthorized access (403).
- Verify that auth tokens/sessions are not logged or exposed in error responses.
Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.