MCPInstall

secure-coding-practices

Secure coding practices and defensive programming patterns for building security-first applications. Use when implementing authentication, handling user input, managing sensitive data, or conducting secure code reviews.

Installs
133
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/nickcrew/claude-cortex --skill secure-coding-practices
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads secure-coding-practices automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Secure Coding Practices

Comprehensive guidance for implementing security-first development patterns with defensive programming techniques and proactive threat mitigation strategies.

When to Use This Skill

  • Implementing authentication and authorization systems
  • Processing user input or external data
  • Handling sensitive data (PII, credentials, financial information)
  • Building APIs and web services
  • Managing cryptographic operations (hashing, encryption)
  • Conducting security-focused code reviews
  • Establishing secure development standards for teams
  • Evaluating third-party dependencies and libraries
  • Designing error handling and logging strategies
  • Implementing session management and token handling

Core Security Principles

Defense in Depth

Apply multiple layers of security controls - never rely on a single protection mechanism.

Fail Securely

When errors occur, default to the secure state (deny access, reject input, log event).

Least Privilege

Grant minimum necessary permissions - users, services, and databases should have only required access.

Trust Nothing

Validate all input, encode all output, verify all sources, authenticate all requests.

Quick Reference

TaskLoad reference
Input validation & sanitizationskills/secure-coding-practices/references/input-validation.md
Output encoding & XSS preventionskills/secure-coding-practices/references/output-encoding.md
Authentication & sessionsskills/secure-coding-practices/references/authentication.md
Cryptography & key managementskills/secure-coding-practices/references/cryptography.md
Dependencies & supply chainskills/secure-coding-practices/references/dependencies.md
Error handling & loggingskills/secure-coding-practices/references/error-handling.md
Secure defaults & configurationskills/secure-coding-practices/references/secure-defaults.md

Workflow

  1. Identify security requirements - Authentication, authorization, data protection, compliance
  2. Load relevant references - Use Quick Reference table to find specific guidance
  3. Implement security controls - Apply patterns from references with proper context
  4. Validate implementation - Test with security scanners, penetration testing, code review
  5. Monitor and maintain - Regular security audits, dependency updates, vulnerability scanning

Security Checklist

Input Validation:

  • Validate all user input server-side with allowlists
  • Use schema validation libraries (Joi, Yup, Zod)
  • Implement strict type checking
  • Sanitize file paths and prevent traversal

Output Encoding:

  • Apply context-aware encoding (HTML, JS, URL, SQL)
  • Use templating engines with auto-escaping
  • Implement Content Security Policy (CSP)
  • Set secure HTTP headers (Helmet.js)

Authentication & Authorization:

  • Hash passwords with bcrypt/Argon2 (salt rounds ≥12)
  • Implement secure session management
  • Use HTTPS-only cookies with HttpOnly and SameSite
  • Apply rate limiting on authentication endpoints
  • Verify authorization on every request

Cryptography:

  • Use AES-256-GCM for encryption
  • Generate keys with crypto.randomBytes()
  • Store secrets in environment variables or KMS
  • Never roll your own crypto

Dependencies:

  • Run npm audit regularly
  • Lock dependency versions in package.json
  • Use Snyk/Dependabot for monitoring
  • Verify package integrity (SRI for CDN)

Error Handling & Logging:

  • Return generic error messages to users
  • Log errors with correlation IDs
  • Never log passwords, tokens, or PII
  • Monitor security events and alerts

Common Mistakes

  • Using client-side validation as sole defense (always validate server-side)
  • Blocklisting instead of allowlisting (define what's allowed, not forbidden)
  • Exposing stack traces or internal errors to users
  • Hardcoding secrets in source code
  • Using Math.random() for security-critical operations
  • Not implementing rate limiting on authentication endpoints
  • Loose equality comparisons allowing type coercion attacks
  • Trusting user input in database queries (SQL injection)
  • Missing output encoding based on context (XSS vulnerabilities)
  • Insufficient password hashing (weak algorithms or low work factor)

High-Risk Code Patterns

Watch for these patterns in code reviews:

  1. String concatenation in SQL queries (injection risk)
  2. Direct file path construction from user input (traversal risk)
  3. eval(), Function(), or exec() with user input (code injection)
  4. Deserialization of untrusted data (RCE risk)
  5. Hardcoded secrets or credentials (exposure risk)
  6. Missing authentication/authorization checks (access control)
  7. Weak cryptography (MD5, SHA1, ECB mode)
  8. Verbose error messages in production (information disclosure)
  9. Missing input validation (injection, DoS)
  10. Insecure session configuration (hijacking risk)

Resources

OWASP Resources:

Standards & Guidelines:

Tools:

  • SAST: SonarQube, Semgrep, CodeQL
  • DAST: OWASP ZAP, Burp Suite
  • SCA: Snyk, npm audit, Dependabot
  • Secrets Detection: TruffleHog, git-secrets

FAQ

What does the secure-coding-practices skill do?

Secure coding practices and defensive programming patterns for building security-first applications. Use when implementing authentication, handling user input, managing sensitive data, or conducting secure code reviews.

How do I install secure-coding-practices?

Run npx skills add https://github.com/nickcrew/claude-cortex --skill secure-coding-practices in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/secure-coding-practices/ (personal) or .claude/skills/secure-coding-practices/ (project).

Which AI agents can use secure-coding-practices?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is secure-coding-practices safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains secure-coding-practices?

It is published by nickcrew in nickcrew/claude-cortex. It has 133 recorded installs.

More from nickcrew/claude-cortex

View all →

react-performance-optimization

nickcrew/claude-cortex

React performance optimization patterns using memoization, code splitting, and efficient rendering strategies. Use when optimizing slow React applications, reducing bundle size, or improving user experience with large datasets.

Frontend & Design1.9K installs

owasp-top-10

nickcrew/claude-cortex

OWASP Top 10 security vulnerabilities with detection and remediation patterns. Use when conducting security audits, implementing secure coding practices, or reviewing code for common security vulnerabilities.

Security758 installs

ui-design-aesthetics

nickcrew/claude-cortex

Generates high-quality, non-generic UI designs with a focus on performance, progressive disclosure, and distinctive aesthetics.

Frontend & Design358 installs

threat-modeling-techniques

nickcrew/claude-cortex

Open the skill to read its SKILL.md instructions.

Security357 installs

token-efficiency

nickcrew/claude-cortex

Compressed communication using symbols and abbreviations. Use when context is limited or brevity is needed.

228 installs

helm-chart-patterns

nickcrew/claude-cortex

Open the skill to read its SKILL.md instructions.

DevOps & Cloud179 installs

Popular security skills

View category →

azure-compliance

microsoft/azure-skills

Run Azure compliance and security audits with azqr plus Key Vault expiration checks. Covers best-practice assessment, resource review, policy/compliance validation, and security posture checks. WHEN: compliance scan, security audit, BEFORE running azqr (compliance cli tool), Azure best practices, Key Vault expiration check, expired certificates, expiring secrets, orphaned resources, compliance assessment.

OfficialSecurity567K installs

minimal-run-and-audit

lllllllama/rigorpilot-skills

Rigor Run skill for README-first deep learning repo reproduction. Use when the task is specifically to capture or normalize evidence from the selected smoke test or documented inference or evaluation command and write standardized reprooutputs/ files, including patch notes when repository files changed. Do not use for training execution, initial repo intake, generic environment setup, paper lookup, target selection, hidden scientific-meaning changes, or end-to-end orchestration by itself.

Security477.4K installs

seo-audit

coreyhaines31/marketingskills

When the user wants to audit, review, or diagnose SEO issues on their site. Also use when the user mentions "SEO audit," "technical SEO," "why am I not ranking," "SEO issues," "on-page SEO," "meta tags review," "SEO health check," "my traffic dropped," "lost rankings," "not showing up in Google," "site isn't ranking," "Google update hit me," "page speed," "core web vitals," "crawl errors," "indexing issues," "stuck on page 2," "striking distance keywords," "title tag rewrite," "low CTR," "local SEO," "Google Business Profile," or "map pack." Use this even if the user just says something vague like "my SEO is bad" or "help with SEO" — start with an audit. For building pages at scale to target keywords, see programmatic-seo. For adding structured data, see schema. For AI search optimization, see ai-seo.

Security238.7K installs

firebase-security-rules-auditor

firebase/agent-skills

Audits Firebase (Firestore, Cloud Storage) security rules for vulnerabilities, privilege escalation, role bypasses, create vs update inconsistencies, resource exhaustion, type safety, size limits, and hasOnly ownership checks. Use when auditing/reviewing rules, running red-team rule assessments, or scoring against auditor checklists. Don't use for Firebase CLI (login, deploy), Auth, Crashlytics, Remote Config, or database queries.

OfficialSecurity139.1K installs

audit

pbakaus/impeccable

Run technical quality checks across accessibility, performance, theming, responsive design, and anti-patterns. Generates a scored report with P0-P3 severity ratings and actionable plan. Use when the user wants an accessibility check, performance audit, or technical quality review.

Security81.9K installs

competitors

coreyhaines31/marketingskills

When the user wants to create competitor comparison or alternative pages for SEO and buyer-facing use. Also use when the user mentions 'alternative page,' 'vs page,' 'competitor comparison,' 'comparison page,' '[Product] vs [Product],' '[Product] alternative,' 'competitive landing pages,' 'how do we compare to X,' 'competitor teardown,' 'audit our competitor pages,' 'are our comparison pages out of date,' or 'competitive asset audit.' Use this for any content that positions your product against competitors. Covers four formats: singular alternative, plural alternatives, you vs competitor, and competitor vs competitor. For auditing existing claims (not researching competitors from scratch, which is competitor-profiling; not technical SEO on these pages, which is seo-audit), use the asset audit here. For internal battle cards and sales-specific competitor docs, see sales-enablement.

Security79.3K installs