JSON Web Tokens — when to use JWTs vs opaque tokens, signing algorithms (asymmetric preferred), key rotation with kid/JWKS, mandatory claim validation, algorithm confusion and `none` attacks, expiry and revocation strategies, size and privacy. Use when issuing or validating JWTs (JWT, JWS, JWKS, token validation, key rotation).
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Jwt?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/vectora-os-jwt)
---
name: jwt
description: JSON Web Tokens — when to use JWTs vs opaque tokens, signing algorithms (asymmetric preferred), key rotation with kid/JWKS, mandatory claim validation, algorithm confusion and `none` attacks, expiry and revocation strategies, size and privacy. Use when issuing or validating JWTs (JWT, JWS, JWKS, token validation, key rotation).
metadata:
category: security
---
# JWT
## Purpose
Issue and validate JWTs without the classic vulnerabilities.
**Use when:** token-based auth with JWTs.
**Not for:** session design for first-party web apps (consider cookies).
## Inputs
- Token use case, key management.
## Outputs
- Token format, validation code and tests, rotation procedure.
## Read first
- [Project Brain](../../../project-brain/README.md) — `npm run brain -- query "jwt"` for prior decisions, patterns and anti-patterns.
- [Security standard](../../../standards/security.md)
## Steps
1. **Choose.** Prefer opaque tokens when revocation matters; JWT when stateless validation is needed.
Done when choice justified.
2. **Sign.** Asymmetric (ES256/EdDSA/RS256); fixed allow-list of algorithms.
Done when `none` and HS/RS confusion impossible.
3. **Validate.** iss, aud, exp, nbf, signature with kid lookup.
Done when negative tests for each claim.
4. **Rotate.** JWKS with overlap window.
Done when rotation rehearsed.
## Best practices
- Keep payload minimal; no personal data.
- Short expiry plus refresh.
## Common mistakes
- Trusting the `alg` header.
- Using JWT as a session store for everything.
## Example
ES256 tokens, `kid` per key, JWKS cached 10 min, validation rejects wrong audience — tests for 7 negative cases.
## Reusable prompt
```text
Apply the JWT skill (.agents/skills/jwt/SKILL.md).
Context: {{task card or question; links to PRD, ADRs, code paths}}
Constraints: {{approved thresholds, deadlines, allowed files}}
Define the token format, signing and validation rules with negative tests and the key rotation procedure.
Return: Token format, validation code and tests, rotation procedure..
Cite evidence (file:line, command output, source) for every claim; list open questions separately.
```