aj-geddes avatar

Sql Injection Prevention

Covers the fundamentals of preventing SQL injection with prepared statements, parameterized queries, and input validation across multiple stacks. Includes working examples for Node.js with PostgreSQL, Python with SQLAlchemy, and Java JDBC, plus a dedicated guide on input sanitization. The do's and don'ts are straightforward: always use prepared statements, never concatenate user input into queries, whitelist dynamic values when you absolutely need them. If you're writing database code or reviewing legacy systems for vulnerabilities, this gives you the patterns to lock things down. The reference implementations are practical enough to adapt directly into your codebase.

skills.sh installs
533
GitHub stars
379
last updated
Aug 21, 2026

Install

$ npx -y skills add aj-geddes/useful-ai-prompts --skill sql-injection-prevention --agent claude-code

Installs into .claude/skills of the current project.

Files

SQL Injection Prevention

Table of Contents

Overview

Implement comprehensive SQL injection prevention using prepared statements, parameterized queries, ORM best practices, and input validation.

When to Use

  • Database query development
  • Legacy code security review
  • Security audit remediation
  • API endpoint development
  • User input handling
  • Dynamic query generation

Quick Start

Minimal working example:

// secure-db.js
const { Pool } = require("pg");

class SecureDatabase {
  constructor() {
    this.pool = new Pool({
      host: process.env.DB_HOST,
      database: process.env.DB_NAME,
      user: process.env.DB_USER,
      password: process.env.DB_PASSWORD,
      max: 20,
      idleTimeoutMillis: 30000,
      connectionTimeoutMillis: 2000,
    });
  }

  /**
   * ✅ SECURE: Parameterized query
   */
  async getUserById(userId) {
    const query = "SELECT * FROM users WHERE id = $1";
    const values = [userId];

Sponsors

Details

Repository
github.com/aj-geddes/useful-ai-prompts
Categories
Backend & APIs, Security, AI & Agent Building, Databases
First seen
Jun 3, 2026

More from aj-geddes/useful-ai-prompts

All 258
1aj-geddes avatarmicroservices-architectureaj-geddes/useful-ai-promptsDesign and implement microservices architecture including service boundaries, communication patterns, API gateways, service mesh, service discovery, and distrib527skills.sh installs
2longbridge avatarlongbridge-security-listlongbridge/skillsUS overnight-eligible securities directory and HK broker participant directory via Longbridge Securities. `security-list` covers the US overnight-trading catalo524skills.sh installs
3aaronontheweb avataraspire-integration-testingaaronontheweb/dotnet-skillsWrite integration tests using .NET Aspire's testing facilities with xUnit. Covers test fixtures, distributed application setup, endpoint discovery, and patterns522skills.sh installs
4xiaomingx avatardingtalk-connectionxiaomingx/moltbot-connector-feishu-dingtalkBridge DingTalk outgoing webhook messages to Clawdbot Gateway and send replies back to DingTalk sessions. Use when setting up DingTalk as a messaging channel, t521skills.sh installs
5blitzreels avatarblitzreels-video-editingblitzreels/agent-skillsEdit a BlitzReels project through REST. Use for timeline, captions, media, previews, or exports.514skills.sh installs
6secondsky avatartanstack-tablesecondsky/claude-skillsTanStack Table v8 headless data tables with server-side features for Cloudflare Workers + D1. Use for pagination, filtering, sorting, virtualization, or encount513skills.sh installs