AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

senior-backend

Use for backend work: REST or GraphQL APIs, auth, microservices, PostgreSQL queries, migrations or load tests. Decides with backend_decision_engine.py, scaffolds with api_scaffolder.py, migrates with database_migration_tool.py and load-tests with api_load_tester.py.

Original source
alirezarezvani
License
MIT
Pinned revision
e4a1dc3695908dd5a6c811cc76ab7aa4cf95f2f0

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

This skill also requires local files or dependencies. Remote reading alone may not be enough.

Ask your assistant

Use Agentic Memory skills to read alirezarezvani--senior-backend at revision e4a1dc3695908dd5a6c811cc76ab7aa4cf95f2f0, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 6

references/backend_security_practices.md · 24000

Key', ], censor: '[REDACTED]', }, });

// Security event types type SecurityEventType = | 'AUTH_SUCCESS' | 'AUTH_FAILURE' | 'AUTH_LOCKOUT' | 'PASSWORD_CHANGED' | 'PASSWORD_RESET_REQUEST' | 'PERMISSION_DENIED' | 'RATE_LIMIT_EXCEEDED' | 'SUSPICIOUS_ACTIVITY' | 'TOKEN_REVOKED';

interface SecurityEvent { type: SecurityEventType; userId?: string; ip: string; userAgent: string; path: string; details?: Record<string, unknown>; }

function logSecurityEvent(event: SecurityEvent): void { logger.info({ security: true, ...event, timestamp: new Date().toISOString(), }, Security: ${event.type}); }


### Request Logging

```typescript
import pinoHttp from 'pino-http';

app.use(pinoHttp({
  logger,
  genReqId: (req) => req.headers['x-request-id'] || crypto.randomUUID(),
  serializers: {
    req: (req) => ({
      id: req.id,
      method: req.method,
      url: req.url,
      remoteAddress: req.remoteAddress,
      // Don't log headers by default (may contain sensitive data)
    }),
    res: (res) => ({
      statusCode: res.statusCode,
    }),
  },
  customLogLevel: (req, res, err) => {
    if (res.statusCode >= 500 || err) return 'error';
    if (res.statusCode >= 400) return 'warn';
    return 'info';
  },
}));

Alerting Thresholds

| Metric | Warning | Critical | |--------|---------|----------| | Failed logins per IP (15 min) | > 5 | > 10 | | Failed logins per account (1 hour) | > 3 | > 5 | | 403 responses per IP (5 min) | > 10 | > 50 | | 500 errors (5 min) | > 5 | > 20 | | Request rate per IP (1 min) | > 100 | > 500 |


Quick Reference: Security Checklist

Authentication

  • [ ] bcrypt with cost >= 12 for password hashing
  • [ ] JWT with RS256, short expiry (15-30 min)
  • [ ] Refresh token rotation with family detection
  • [ ] Session regeneration on login
  • [ ] Secure cookie flags (httpOnly, secure, sameSite)

Input Validation

  • [ ] Schema validation on all inputs (Zod)
  • [ ] Parameterized queries (never string concat)
  • [ ] File path sanitization
  • [ ] Content-Type validation

Headers

  • [ ] Strict-Transport-Security
  • [ ] Content-Security-Policy
  • [ ] X-Content-Type-Options: nosniff
  • [ ] X-Frame-Options: DENY
  • [ ] CORS with specific origins

Logging

  • [ ] Redact sensitive fields
  • [ ] Log security events
  • [ ] Include request IDs
  • [ ] Alert on anomalies

Dependencies

  • [ ] npm audit in CI
  • [ ] Automated dependency updates
  • [ ] Lock file committed