agentleFS
salavendersalavender/antigravity-compound-engineering-plugin/skills/standard-security-auth/SKILL.md

standard-security-auth

Skill48 starsChanged 11 months agoMITView on GitHub

Security & Authentication Specialist - Expert in JWT, cookie-based auth, MFA, and generic security patterns

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 11 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Authentication Implementation: When implementing or modifying auth flows

    line 20
  2. Distinctive:

    Security Review: When reviewing code for security vulnerabilities

    line 21
  3. Distinctive:

    API Integration: When connecting new features to the auth system

    line 22
  4. Distinctive:

    MFA/Role-based Logic: When working with multi-factor authentication or role-based access

    line 23
  5. Distinctive:

    Audit Compliance: When ensuring code follows audit logging requirements

    line 24
  6. Distinctive:

    Use the standard API client for calls that require authentication

    line 46
  7. Distinctive:

    Never manually attach Authorization headers in cookie mode

    line 47
  8. Distinctive:

    All security-relevant events must be logged:

    line 101
  9. Distinctive:

    Check browser cookies for valid auth tokens

    line 124
  10. Distinctive:

    Verify the token is a properly formatted JWT

    line 125
  11. Distinctive:

    Check middleware logs for route protection decisions

    line 126

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Security & Authentication Specialist

Overview

An expert agent specializing in the project's authentication system, security patterns, and API integration. This agent understands JWT, cookie-based, and multi-factor authentication flows, as well as proxy architectures for secure backend communication.

When To Use

  • Authentication Implementation: When implementing or modifying auth flows
  • Security Review: When reviewing code for security vulnerabilities
  • API Integration: When connecting new features to the auth system
  • MFA/Role-based Logic: When working with multi-factor authentication or role-based access
  • Audit Compliance: When ensuring code follows audit logging requirements

Instrumentation

# Log usage when using this skill
./scripts/log-skill.sh "standard-security-auth" "manual" "$$"

What do you want to do?

  1. Implement Authentication Flow → See "Auth Flow Patterns" below
  2. Review Security Vulnerabilities → See "Security Checklist" below
  3. Connect API to Auth System → See "API Integration" below
  4. MFA/Role-based Access → See "Role Management" below
  5. Audit & Compliance → See "Audit Patterns" below

Auth Flow Patterns

Cookie-Based Authentication

  • Use the standard API client for calls that require authentication
  • Never manually attach Authorization headers in cookie mode
  • The middleware automatically handles JWT validation and refresh
  • Session state is maintained in a centralized AuthContext

JWT Token Management

  • Tokens are stored in HttpOnly cookies for security
  • Middleware handles proactive refresh before expiration
  • Multi-Factor Authentication (MFA) sessions require secondary verification
  • Role-based access is enforced at both middleware and component levels

Security Checklist

Critical Security Checks

  • All API calls use the canonical API client
  • No hardcoded API URLs or fallbacks (use environment variables)
  • Middleware route protection is properly configured
  • Role-based access control is enforced at both frontend and backend
  • No sensitive data is stored in unencrypted local storage
  • Content Security Policy (CSP) headers are properly applied

API Integration

Proxy Architecture

The application uses a Backend for Frontend (BFF) proxy pattern:

// Correct way to make authenticated API calls
import { fetchWithAuth } from '@/lib/apiClient';

const response = await fetchWithAuth('/api/resource/data');

Role Management

Role Definitions

  • admin: Full administrative access, typically requires MFA
  • user: Standard access to personal/assigned resources

Route Protection

Routes are typically configured in middleware.ts:

  • Public routes: Login, callback, and landing pages
  • Protected routes: Administrative and user dashboard routes

Audit Patterns

Security Event Logging

All security-relevant events must be logged:

  • Token refresh events
  • Login/logout success and failure
  • Role access violations
  • Critical data modifications

Common Pitfalls & Solutions

Pitfall: Guest State Handling

  • ❌ WRONG: Auth status endpoint returns 401 for unauthenticated users (causes browser noise)
  • ✅ CORRECT: Auth status endpoint returns 200 with { authenticated: false }

Pitfall: Duplicate API Calls

  • ❌ WRONG: Session initialization called multiple times outside of controlled effects
  • ✅ CORRECT: Use controlled effects with proper guards to prevent duplicate calls

Troubleshooting

Debugging Authentication Issues

  1. Check browser cookies for valid auth tokens
  2. Verify the token is a properly formatted JWT
  3. Check middleware logs for route protection decisions
  4. Confirm user role matches expected access level

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.