sql-injection-prevention — Claude Code skill: how to install
Enforces parameterized queries, prepared statements, and input validation in database code. Useful when writing API endpoints or auditing legacy queries for security flaws.
npx skills add aj-geddes/useful-ai-prompts --skill sql-injection-prevention -a claude-codeWhat sql-injection-prevention does
This skill instructs coding agents to avoid string concatenation in SQL queries and stick to prepared statements. It helps during database query development and legacy code refactoring.
The repository provides implementation guides for Node.js with PostgreSQL and Python using SQLAlchemy ORM. Separate references cover Java JDBC and input sanitization. The quick start demonstrates a PostgreSQL connection pool configured with strict timeouts.
Dynamic table or column names are forbidden unless verified against an explicit whitelist. Never trust client-side validation. The skill also enforces least privilege database roles and query logging.
What it helps with
- rewrite raw SQL queries into parameterized statements
- audit legacy database code for injection vulnerabilities
- configure secure queries in SQLAlchemy or JDBC
- implement strict input validation using allowlists
Example prompts for the agent
- Review
secure-db.jsfor SQL injection risks and convert dynamic queries to prepared statements. - Show me how to filter user records safely with SQLAlchemy ORM without string formatting.
- Add input validation and an allowlist for dynamic query parameters in our database layer.
How to install sql-injection-prevention
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill sql-injection-prevention -a claude-code2Manually: put the files in place
~/.claude/skills/sql-injection-prevention/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/sql-injection-prevention/
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill sql-injection-prevention -a codex2Manually: put the files in place
.agents/skills/sql-injection-prevention/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill sql-injection-prevention -a cursor2Manually: put the files in place
.cursor/skills/sql-injection-prevention/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install aj-geddes/useful-ai-prompts sql-injection-prevention2Manually: put the files in place
.github/skills/sql-injection-prevention/SKILL.md1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill sql-injection-prevention -a gemini-cli2Platform CLI
gemini skills install https://github.com/aj-geddes/useful-ai-prompts --path skills/sql-injection-preventionManually: put the files in place
.devin/skills/sql-injection-prevention/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill sql-injection-prevention -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about sql-injection-prevention
How do I install sql-injection-prevention in Claude Code?
Run npx skills add aj-geddes/useful-ai-prompts --skill sql-injection-prevention -a claude-code. The skill file will be placed in ~/.claude/skills/sql-injection-prevention/SKILL.md.
What does the sql-injection-prevention skill do?
It instructs your AI coding assistant to use parameterized queries and prepared statements, reject string concatenation, and validate all inputs server-side.
Which languages and frameworks are covered by the reference guides?
The skill includes dedicated guides for Node.js with PostgreSQL, Python using SQLAlchemy ORM, and Java using JDBC prepared statements.
Source text
SKILL.md · MIT
---
name: sql-injection-prevention
description: >
Prevent SQL injection attacks using prepared statements, parameterized
queries, and input validation. Use when building database-driven applications
securely.
---
# SQL Injection Prevention
## Table of Contents
- [Overview](#overview)
- [When to Use](#when-to-use)
- [Quick Start](#quick-start)
- [Reference Guides](#reference-guides)
- [Best Practices](#best-practices)
## 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:
```javascript
// 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];
try {
const result = await this.pool.query(query, values);
// ... (see reference guides for full implementation)
```
## Reference Guides
Detailed implementations in the `references/` directory:
| Guide | Contents |
|---|---|
| [Node.js with PostgreSQL](references/nodejs-with-postgresql.md) | Node.js with PostgreSQL |
| [Python with SQLAlchemy ORM](references/python-with-sqlalchemy-orm.md) | Python with SQLAlchemy ORM |
| [Java JDBC with Prepared Statements](references/java-jdbc-with-prepared-statements.md) | Java JDBC with Prepared Statements |
| [Input Validation & Sanitization](references/input-validation-sanitization.md) | Input Validation & Sanitization |
## Best Practices
### ✅ DO
- Use prepared statements ALWAYS
- Use ORM frameworks properly
- Validate all user inputs
- Whitelist dynamic values
- Use least privilege DB accounts
- Enable query logging
- Regular security audits
- Use parameterized queries
### ❌ DON'T
- Concatenate user input
- Trust client-side validation
- Use string formatting for queries
- Allow dynamic table/column names
- Grant excessive DB permissions
- Skip input validation
© aj-geddes · MIT · aj-geddes/useful-ai-prompts