jwt-validate — Claude Code skill: verify JWT tokens
This skill checks a JWT's structure, claims and signature step by step. Useful when a token keeps getting rejected and you need the reason.
npx skills add jsonwebtoken/jwt-skills --skill jwt-validate -a claude-codeWhat jwt-validate does
Validation runs in three stages and stops at the first failure. Structure first: three dot-separated parts, each valid base64url, header and payload parsing as JSON, and an alg header that is not none. Then claims: exp in the future, nbf not in the future, iat in the past, with iss, aud and sub matched against expected values when you supply them. Time checks allow 60 seconds of clock skew.
The signature is only checked when you hand over a secret, a PEM key or a JWKS URI. On Node.js the skill reaches for jose, on Python for jwt, and it passes secrets and tokens through environment variables so they stay out of shell history. With no key, structure and claims still get checked, and the report states plainly that the signature was not verified.
One rule drives the whole thing: never trust the token's own alg header. The algorithm goes into the verification call as an explicit allowlist, because otherwise an attacker swaps RS256 for HS256 and signs with the public key as an HMAC secret. Worth checking your own verification code if it reads the algorithm from the header.
What it helps with
- verify a JWT signature before letting the request through
- find out why a token is rejected at the gate
- match
iss,audandsubagainst expected values - see how much time is left before
exp - check a token against a provider's JWKS endpoint
Example prompts for the agent
- verify this JWT, here's the token and secret
- is this token valid and not expired?
- check the signature against my JWKS
How to install jwt-validate
1Skills CLI (Vercel)
npx skills add jsonwebtoken/jwt-skills --skill jwt-validate -a claude-code2Manually: put the files in place
~/.claude/skills/jwt-validate/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/jwt-validate/
1Skills CLI (Vercel)
npx skills add jsonwebtoken/jwt-skills --skill jwt-validate -a codex2Manually: put the files in place
.agents/skills/jwt-validate/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add jsonwebtoken/jwt-skills --skill jwt-validate -a cursor2Manually: put the files in place
.cursor/skills/jwt-validate/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install jsonwebtoken/jwt-skills jwt-validate2Manually: put the files in place
.github/skills/jwt-validate/SKILL.md1Skills CLI (Vercel)
npx skills add jsonwebtoken/jwt-skills --skill jwt-validate -a gemini-cli2Platform CLI
gemini skills install https://github.com/jsonwebtoken/jwt-skills --path jwt-validateManually: put the files in place
.devin/skills/jwt-validate/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add jsonwebtoken/jwt-skills --skill jwt-validate -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about jwt-validate
How do I install jwt-validate in Claude?
Run npx skills add jsonwebtoken/jwt-skills --skill jwt-validate -a claude-code. The skill file lands at ~/.claude/skills/jwt-validate/SKILL.md.
What does jwt-validate do?
It checks the token's structure, claims and signature, then reports the result for each stage. HMAC, RSA and ECDSA are supported with secrets, PEM keys or JWKS.
Can it verify the signature without a key?
No. Without a secret, PEM key or JWKS URI it validates structure and claims only, and says the signature was not verified.
Source text
SKILL.md · Apache-2.0
---
name: jwt-validate
description: Verify and validate JSON Web Tokens (JWTs) by checking signatures, expiration, claims, and structure. Use when the user wants to verify, validate, or check a JWT — e.g. "verify this token", "is this JWT valid", "check the signature", "validate this token against my JWKS", "is this token expired". Supports HMAC, RSA, and ECDSA with secrets, PEM keys, or JWKS endpoints.
---
# JWT Validate
Verify a JWT's signature and validate its claims. Confirms the token is authentic, unexpired, and structurally sound.
## Validation Order
Check in this order. Stop and report at the first failure.
### 1. Structure
- Exactly 3 dot-separated parts, each valid base64url
- Header and payload parse as valid JSON
- Header contains `alg`; `alg` is not `none` (unless explicitly expected)
### 2. Claims
- `exp` must be in the future (report time until expiry or how long ago it expired)
- `nbf` must be in the past or present
- `iat` must be in the past; flag if > 30 days old
- `iss`, `aud`, `sub` — if user provides expected values, they must match
- Allow 60 seconds clock skew tolerance on all time checks
### 3. Signature
Requires the user to provide a secret, PEM public key, or JWKS URI. Always pass secrets and tokens via inline env vars to avoid shell history exposure.
**Node.js** (preferred):
First, ensure `jose` is available — install it globally if missing:
```bash
node --input-type=module -e "await import('jose')" 2>/dev/null || npm install -g jose
```
Then verify the token:
```bash
JWT_TOKEN='the.jwt.here' JWT_SECRET='user-provided-secret' node --input-type=module -e "import {jwtVerify} from 'jose'; try { const {payload}=await jwtVerify(process.env.JWT_TOKEN, new TextEncoder().encode(process.env.JWT_SECRET), {algorithms:['HS256'],clockTolerance:60}); console.log('VALID'); console.log(JSON.stringify(payload,null,2)); } catch(e) { console.log('INVALID:',e.message); }"
```
**Python**:
```bash
JWT_TOKEN='the.jwt.here' JWT_SECRET='user-provided-secret' python3 -c "
import jwt,json,os
try:
d=jwt.decode(os.environ['JWT_TOKEN'],os.environ['JWT_SECRET'],algorithms=['HS256'],leeway=60)
print('VALID'); print(json.dumps(d,indent=2))
except Exception as e: print(f'INVALID: {e}')
"
```
**JWKS verification** (Node.js):
```bash
JWT_TOKEN='the.jwt.here' JWKS_URI='https://example.auth0.com/.well-known/jwks.json' node --input-type=module -e "import {jwtVerify,createRemoteJWKSet} from 'jose'; try { const {payload}=await jwtVerify(process.env.JWT_TOKEN, createRemoteJWKSet(new URL(process.env.JWKS_URI)), {algorithms:['RS256']}); console.log('VALID'); console.log(JSON.stringify(payload,null,2)); } catch(e) { console.log('INVALID:',e.message); }"
```
If no secret/key is provided, perform structure + claims validation only, and clearly state the signature was NOT verified.
## Output Format
```
## JWT Validation Report
Structure: PASS
Claims: PASS — exp 2025-06-15T12:00:00Z (expires in 2h)
Signature: PASS — RS256, key kid "abc123"
Result: VALID
```
On failure:
```
## JWT Validation Report
Structure: PASS
Claims: FAIL — exp 2024-01-15T12:00:00Z (expired 6 months ago)
Signature: SKIPPED
Result: INVALID — token expired
```
## Security Rules
- **Never trust the token's `alg` header for verification.** Always use the algorithm the user expects or that matches the provided key type. Trusting the header enables algorithm confusion attacks where an attacker switches RS256 to HS256 and signs with the public key as an HMAC secret.
- **Always specify `algorithms` as an explicit allowlist** in verification calls. Never pass `algorithms: [decoded.header.alg]`.
- **Never pass secrets/tokens as literal command-line arguments.** Use environment variables. Args are visible in shell history and `ps` output.
- **`alg: none`** — Flag as a critical security issue. The token is unsigned and cannot be trusted.
- **If no key is provided**, validate structure and claims only. Clearly state: "Signature was NOT verified — token authenticity is unknown."
---
© jsonwebtoken · Apache-2.0 · jsonwebtoken/jwt-skills