Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
jeffallan avatar

Secure Code Guardian

  • 3.7k installs
  • 10.8k repo stars
  • Updated May 20, 2026
  • jeffallan/claude-skills

secure-code-guardian is an agent skill for implement auth, input validation, and owasp top 10 defenses including secure hashing and session handling.

About

The secure-code-guardian skill Use when implementing authentication/authorization, securing user input, or preventing OWASP Top 10 vulnerabilities including custom security implementations such as hashing passwords with bcrypt/argon2, sanitizing SQL queries with parameterized statements, configuring CORS/CSP headers, validating input with Zod, and setting up JWT tokens. Invoke for authentication, authorization, input validation, encryption, OWASP Top 10 prevention, secure session management, and security hardening. For pre-built OAuth/SSO integrations or standalone security audits, consider a more specialized skill. 1. Threat model Identify attack surface and threats 2. Design Plan security controls 3. Implement Write secure code with defense in depth; see code examples below 4. Validate Test security controls with explicit checkpoints (see below) 5. Document Record security decisions - Authentication: Test brute-force protection (lockout/rate limit triggers), session fixation resistance, token expiration, and invalid-credential error messages (must not leak user existence). - Authorization: Verify horizontal and vertical privilege escalation paths are blocked; test with tokens be.

  • Threat model — Identify attack surface and threats
  • Design — Plan security controls
  • Implement — Write secure code with defense in depth; see code examples below
  • Validate — Test security controls with explicit checkpoints (see below)
  • Document — Record security decisions

Secure Code Guardian by the numbers

  • 3,675 all-time installs (skills.sh)
  • +111 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #170 of 2,209 Security skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

secure-code-guardian capabilities & compatibility

Capabilities
threat model — identify attack surface and threa · design — plan security controls · implement — write secure code with defense in de · validate — test security controls with explicit · document — record security decisions
Use cases
security audit · api development
From the docs

What secure-code-guardian says it does

1. **Threat model** — Identify attack surface and threats
SKILL.md
2. **Design** — Plan security controls
SKILL.md
3. **Implement** — Write secure code with defense in depth; see code examples below
SKILL.md
npx skills add https://github.com/jeffallan/claude-skills --skill secure-code-guardian

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs3.7k
repo stars10.8k
Security audit3 / 3 scanners passed
Last updatedMay 20, 2026
Repositoryjeffallan/claude-skills

How do I implement auth, input validation, and owasp top 10 defenses including secure hashing and session handling with documented agent guidance?

Implement auth, input validation, and OWASP Top 10 defenses including secure hashing and session handling.

Who is it for?

Developers who need security help during ship work.

Skip if: Skip when the task falls outside Security scope described in SKILL.md.

When should I use this skill?

Implement auth, input validation, and OWASP Top 10 defenses including secure hashing and session handling.

What you get

Completed security workflow aligned with SKILL.md steps and validation.

  • Secure auth helper code
  • Password validation rules

By the numbers

  • Threat model — Identify attack surface and threats
  • Design — Plan security controls
  • Implement — Write secure code with defense in depth; see code examples below

Files

SKILL.mdMarkdownGitHub ↗

Secure Code Guardian

Core Workflow

1. Threat model — Identify attack surface and threats 2. Design — Plan security controls 3. Implement — Write secure code with defense in depth; see code examples below 4. Validate — Test security controls with explicit checkpoints (see below) 5. Document — Record security decisions

Validation Checkpoints

After each implementation step, verify:

  • Authentication: Test brute-force protection (lockout/rate limit triggers), session fixation resistance, token expiration, and invalid-credential error messages (must not leak user existence).
  • Authorization: Verify horizontal and vertical privilege escalation paths are blocked; test with tokens belonging to different roles/users.
  • Input handling: Confirm SQL injection payloads (' OR 1=1--) are rejected; confirm XSS payloads (<script>alert(1)</script>) are escaped or rejected.
  • Headers/CORS: Validate with a security scanner (e.g., curl -I, Mozilla Observatory) that security headers are present and CORS origin allowlist is correct.

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
OWASPreferences/owasp-prevention.mdOWASP Top 10 patterns
Authenticationreferences/authentication.mdPassword hashing, JWT
Input Validationreferences/input-validation.mdZod, SQL injection
XSS/CSRFreferences/xss-csrf.mdXSS prevention, CSRF
Headersreferences/security-headers.mdHelmet, rate limiting

Constraints

MUST DO

  • Hash passwords with bcrypt/argon2 (never MD5/SHA-1/unsalted hashes)
  • Use parameterized queries (never string-interpolated SQL)
  • Validate and sanitize all user input before use
  • Implement rate limiting on auth endpoints
  • Set security headers (CSP, HSTS, X-Frame-Options)
  • Log security events (failed auth, privilege escalation attempts)
  • Store secrets in environment variables or secret managers (never in source code)

MUST NOT DO

  • Store passwords in plaintext or reversibly encrypted form
  • Trust user input without validation
  • Expose sensitive data in logs or error responses
  • Use weak or deprecated algorithms (MD5, SHA-1, DES, ECB mode)
  • Hardcode secrets or credentials in code

Code Examples

Password Hashing (bcrypt)

import bcrypt from 'bcrypt';

const SALT_ROUNDS = 12; // minimum 10; 12 balances security and performance

export async function hashPassword(plaintext: string): Promise<string> {
  return bcrypt.hash(plaintext, SALT_ROUNDS);
}

export async function verifyPassword(plaintext: string, hash: string): Promise<boolean> {
  return bcrypt.compare(plaintext, hash);
}

Parameterized SQL Query (Node.js / pg)

// NEVER: `SELECT * FROM users WHERE email = '${email}'`
// ALWAYS: use positional parameters
import { Pool } from 'pg';
const pool = new Pool();

export async function getUserByEmail(email: string) {
  const { rows } = await pool.query(
    'SELECT id, email, role FROM users WHERE email = $1',
    [email]  // value passed separately — never interpolated
  );
  return rows[0] ?? null;
}

Input Validation with Zod

import { z } from 'zod';

const LoginSchema = z.object({
  email: z.string().email().max(254),
  password: z.string().min(8).max(128),
});

export function validateLoginInput(raw: unknown) {
  const result = LoginSchema.safeParse(raw);
  if (!result.success) {
    // Return generic error — never echo raw input back
    throw new Error('Invalid credentials format');
  }
  return result.data;
}

JWT Validation

import jwt from 'jsonwebtoken';

const JWT_SECRET = process.env.JWT_SECRET!; // never hardcode

export function verifyToken(token: string): jwt.JwtPayload {
  // Throws if expired, tampered, or wrong algorithm
  const payload = jwt.verify(token, JWT_SECRET, {
    algorithms: ['HS256'],   // explicitly allowlist algorithm
    issuer: 'your-app',
    audience: 'your-app',
  });
  if (typeof payload === 'string') throw new Error('Invalid token payload');
  return payload;
}

Securing an Endpoint — Full Flow

import express from 'express';
import rateLimit from 'express-rate-limit';
import helmet from 'helmet';

const app = express();
app.use(helmet()); // sets CSP, HSTS, X-Frame-Options, etc.
app.use(express.json({ limit: '10kb' })); // limit payload size

const authLimiter = rateLimit({
  windowMs: 15 * 60 * 1000, // 15 minutes
  max: 10,                   // 10 attempts per window per IP
  standardHeaders: true,
  legacyHeaders: false,
});

app.post('/api/login', authLimiter, async (req, res) => {
  // 1. Validate input
  const { email, password } = validateLoginInput(req.body);

  // 2. Authenticate — parameterized query, constant-time compare
  const user = await getUserByEmail(email);
  if (!user || !(await verifyPassword(password, user.passwordHash))) {
    // Generic message — do not reveal whether email exists
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  // 3. Authorize — issue scoped, short-lived token
  const token = jwt.sign(
    { sub: user.id, role: user.role },
    JWT_SECRET,
    { algorithm: 'HS256', expiresIn: '15m', issuer: 'your-app', audience: 'your-app' }
  );

  // 4. Secure response — token in httpOnly cookie, not body
  res.cookie('token', token, { httpOnly: true, secure: true, sameSite: 'strict' });
  return res.json({ message: 'Authenticated' });
});

Output Templates

When implementing security features, provide: 1. Secure implementation code 2. Security considerations noted 3. Configuration requirements (env vars, headers) 4. Testing recommendations

Knowledge Reference

OWASP Top 10, bcrypt/argon2, JWT, OAuth 2.0, OIDC, CSP, CORS, rate limiting, input validation, output encoding, encryption (AES, RSA), TLS, security headers

Documentation

Related skills

How it compares

secure-code-guardian is an agent skill for implement auth, input validation, and owasp top 10 defenses including secure hashing and session handling, not a generic alternative.

FAQ

Who is secure-code-guardian for?

Developers using Security workflows with agent-guided SKILL.md steps.

When should I use secure-code-guardian?

Implement auth, input validation, and OWASP Top 10 defenses including secure hashing and session handling.

Is secure-code-guardian safe to install?

Review the Security Audits panel on this page before installing in production.

Securityappsecsecrets

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.