Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Security patterns for session keys, caching, logging, and environment variables. Use when implementing authentication, caching sensitive data, or setting up logging. Triggers on: session key, private key, cache, logging, secrets, environment variable.
.claude/skills/aiskillstore-pitfalls-security/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | -32% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 34% | 0% |
| case-10 | ✗→✓ | ▲ Improved | -11% | 0% |
| case-11 | ✗→✓ | ▲ Improved | -28% | 0% |
| case-14 | ✗→✓ | ▲ Improved | -7% | 0% |
Common pitfalls and correct patterns for security.
Verify no private keys stored in plaintext.
Ensure sensitive data not cached inappropriately.
Confirm no secrets in logs.
typescript// ❌ NEVER store private keys localStorage.setItem('privateKey', key); // CATASTROPHIC // ✅ Use session keys with limited permissions interface SessionKey { address: Address; permissions: Permission[]; expiresAt: Date; maxPerTrade: bigint; } // ✅ AES-256-GCM for any stored credentials import { createCipheriv, randomBytes } from 'crypto'; const iv = randomBytes(16); const cipher = createCipheriv('aes-256-gcm', key, iv); // ✅ Audit logging for all key operations await auditLog.create({ action: 'SESSION_KEY_CREATED', userId, metadata: { permissions, expiresAt }, });
typescript// Frontend (Vite) const apiUrl = import.meta.env.VITE_API_URL; // ✅ VITE_ prefix required // ❌ process.env.API_URL won't work in frontend // Backend const dbUrl = process.env.DATABASE_URL; // ❌ NEVER log secrets console.log('Config:', config); // May contain secrets! // ✅ Log safely console.log('Config loaded for:', config.environment);
typescript// ✅ Server-side cache for expensive computations const priceCache = new Map<string, { value: number; expires: number }>(); function getCachedPrice(token: string): number | null { const cached = priceCache.get(token); if (cached && cached.expires > Date.now()) { return cached.value; } return null; } // ✅ TTL based on data freshness needs const CACHE_TTL = { tokenPrice: 10_000, // 10s - prices change fast poolReserves: 5_000, // 5s - critical for swaps gasPrice: 15_000, // 15s userBalance: 30_000, // 30s tokenMetadata: 3600_000, // 1 hour - rarely changes }; // ❌ Never cache user-specific sensitive data cache.set(`user:${userId}:privateKey`, key); // NEVER!
typescript// ✅ Structured logging (JSON format) const logger = { info: (message: string, context?: object) => { console.log(JSON.stringify({ level: 'info', message, timestamp: new Date().toISOString(), ...context, })); }, error: (message: string, error: Error, context?: object) => { console.error(JSON.stringify({ level: 'error', message, error: error.message, stack: error.stack, timestamp: new Date().toISOString(), ...context, })); }, }; // ✅ Include context logger.info('Trade executed', { userId: 'user123', txHash: '0x...', chain: 'ethereum', profit: '12.34', }); // ❌ NEVER log secrets logger.info('Config', { apiKey: process.env.API_KEY }); // NEVER!
typescript// ✅ Audit logging for sensitive operations await auditLog.create({ action: 'TRADE_EXECUTED', userId, before: previousState, after: newState, timestamp: new Date(), metadata: { txHash, chain }, });
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-02 | fail→pass | 27,843 | 14,341 | -48% | 1 | 1 | 0% | 5,498 | 3,763 | -32% | 0 | 0 | — |
case-04 | fail→pass | 18,680 | 23,191 | +24% | 1 | 1 | 0% | 3,430 | 4,608 | +34% | 0 | 0 | — |
case-03 | fail→fail | 28,177 | 19,588 | -30% | 1 | 1 | 0% | 4,413 | 4,764 | +8% | 0 | 0 | — |
case-01 | fail→fail | 23,104 | 23,301 | +1% | 1 | 1 | 0% | 4,619 | 4,563 | -1% | 0 | 0 | — |
case-05 | pass→pass | 17,527 | 6,573 | -62% | 1 | 1 | 0% | 2,594 | 2,293 | -12% | 0 | 0 | — |
case-06 | pass→pass | 18,335 | 6,452 | -65% | 1 | 1 | 0% | 2,041 | 2,180 | +7% | 0 | 0 | — |
case-07 | pass→pass | 18,120 | 9,976 | -45% | 1 | 1 | 0% | 2,382 | 2,741 | +15% | 0 | 0 | — |
case-08 | pass→pass | 14,711 | 13,640 | -7% | 1 | 1 | 0% | 2,466 | 2,500 | +1% | 0 | 0 | — |
case-09 | pass→pass | 21,035 | 13,445 | -36% | 1 | 1 | 0% | 4,111 | 3,823 | -7% | 0 | 0 | — |
case-10 | fail→pass | 21,832 | 13,660 | -37% | 1 | 1 | 0% | 2,656 | 2,375 | -11% | 0 | 0 | — |
case-11 | fail→pass | 15,048 | 7,125 | -53% | 1 | 1 | 0% | 2,860 | 2,046 | -28% | 0 | 0 | — |
case-12 | pass→pass | 13,841 | 13,228 | -4% | 1 | 1 | 0% | 2,160 | 2,407 | +11% | 0 | 0 | — |
case-13 | pass→pass | 20,285 | 10,378 | -49% | 1 | 1 | 0% | 2,474 | 2,400 | -3% | 0 | 0 | — |
case-14 | fail→pass | 9,974 | 11,398 | +14% | 1 | 1 | 0% | 1,973 | 1,836 | -7% | 0 | 0 | — |
case-15 | fail→fail | 19,226 | 12,431 | -35% | 1 | 1 | 0% | 2,468 | 2,342 | -5% | 0 | 0 | — |
case-16 | pass→pass | 5,458 | 10,357 | +90% | 1 | 1 | 0% | 1,081 | 1,900 | +76% | 0 | 0 | — |
case-17 | fail→pass | 17,193 | 13,703 | -20% | 1 | 1 | 0% | 2,085 | 2,490 | +19% | 0 | 0 | — |
case-18 | pass→pass | 10,758 | 11,635 | +8% | 1 | 1 | 0% | 1,872 | 1,945 | +4% | 0 | 0 | — |
case-19 | pass→fail | 16,399 | 14,267 | -13% | 1 | 1 | 0% | 2,680 | 2,733 | +2% | 0 | 0 | — |
case-20 | pass→pass | 12,246 | 12,171 | -1% | 1 | 1 | 0% | 2,242 | 3,298 | +47% | 0 | 0 | — |
case-21 | pass→pass | 20,778 | 28,105 | +35% | 1 | 1 | 0% | 2,806 | 4,622 | +65% | 0 | 0 | — |
case-22 | pass→pass | 12,833 | 17,266 | +35% | 1 | 1 | 0% | 1,348 | 2,003 | +49% | 0 | 0 | — |
case-23 | fail→pass | 32,200 | 43,394 | +35% | 1 | 1 | 0% | 3,498 | 3,284 | -6% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +26 percentage points is the difference between those two pass rates over the 23 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.