magento-sql

magento-sql is a skill for Claude Code, Codex from furan917/magento-ai-toolkit. It costs 77 tokens per session (8,523 once invoked), scanned A, original, MPL-2.0.

A Magento 2 guide for writing safe SQL and changing database schemas with MySQL or MariaDB.

In plain words
What is it for?
Use it when building Magento queries, working with its EAV data model, processing records in batches, handling transactions, diagnosing slow reads, or editing db_schema.xml.
Why use it?
It helps avoid unsafe query construction, slow indexes, stalled schema updates, and problems with Magento's database conventions.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when building Magento queries, working with its EAV data model, processing records in batches, handling transactions, diagnosing slow reads, or editing db_schema.xml.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/furan917/magento-ai-toolkit/magento-sql
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add furan917/magento-ai-toolkit --skill magento-sql
Clone the repo
git clone --depth 1 https://github.com/furan917/magento-ai-toolkit

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for magento-sql

README.md
[![agentmods](https://agentmods.dev/badge/skills/furan917/magento-ai-toolkit/magento-sql.svg)](https://agentmods.dev/skills/furan917/magento-ai-toolkit/magento-sql)
Your own site
<a href="https://agentmods.dev/skills/furan917/magento-ai-toolkit/magento-sql"><img src="https://agentmods.dev/badge/skills/furan917/magento-ai-toolkit/magento-sql.svg" alt="Measured on agentmods" height="20"></a>
Per session 77 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 8,523 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00077 $0.08523
Opus 5 $0.00039 $0.04262
Sonnet 5 $0.00015 $0.01705
Haiku 4.5 $0.00008 $0.00852

Measured 8d ago against content hash 2375c79ead41, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

magento-sql scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/magento-sql/SKILL.md · 804 lines

How it starts

The opening of the file, as written. The whole thing — 804 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Skill: magento-sql

Purpose: Write safe, fast SQL in Magento 2 and design schemas that scale. Covers the query side (Select builder, placeholders, EAV, batch ops, transactions, deadlocks) and the schema side (composite indexes, db_schema.xml, db_schema_whitelist.json, MySQL 8 / MariaDB features Magento core doesn't use by default). Compatible with: Any LLM (Claude, GPT, Gemini, local models) Usage: Paste this file as a system prompt, then describe the query, slow table, or schema change you are working on.


System Prompt

You are a Magento 2 database specialist. You write queries via ResourceConnection and the Select builder, never via ObjectManager::getInstance() and never by string-concatenating SQL. You design composite indexes by selectivity and by the actual WHERE + ORDER BY + GROUP BY the query executes. The default path for schema changes is db_schema.xml + regenerated db_schema_whitelist.json + setup:upgrade. The documented escape hatch for huge tables (tens of millions of rows where letting setup:upgrade run an in-place ALTER would stall the store for hours) is a manual ALTER TABLE … ALGORITHM=INSTANT, LOCK=NONE ahead of setup:upgrade, with db_schema.xml + whitelist updated in the same deploy so setup:upgrade becomes a no-op — and only when the engine + version supports INSTANT for the operation. You detect N+1 patterns, recommend insertOnDuplicate / insertFromSelect over row-at-a-time writes, and distinguish MySQL 8 features from MariaDB's divergent implementations.


When to Reach For Raw SQL

Situation Preferred tool
Single entity load / save Repository (\Magento\Catalog\Api\ProductRepositoryInterface)
Filtered list SearchCriteria + Repository getList()
Custom list with joins to non-entity tables Collection — addFieldToFilter / join
Reporting query across many tables ResourceConnection + Select builder
Bulk insert / update (> ~100 rows) insertMultiple, insertOnDuplicate, insertFromSelect
Schema change (column / index / FK) db_schema.xml + whitelist regen
One-off admin operation CLI command using ResourceConnection, never a migration script

Read the full file on GitHub · 804 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 804 lines · 77 tokens per session scan A 2375c79ead41

Subscribe to this mod's changes

magento-sql is a skill published in the GitHub repository furan917/magento-ai-toolkit (34 stars, last pushed 4mo ago), licensed MPL-2.0. It adds 77 tokens to every session and 8,523 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

magento-model-developer

Designs and implements data layer architecture for Magento 2. Use when creating data models, designing database schemas, implementing repositories, or working with EAV/flat table structures. Masters entity design, repository patterns, collections, and database optimization.

maxnorm/magento2-agent-skills · 54 tokens

magento-cache-analyst

Optimizes Magento 2 caching strategies for enterprise performance. Use when optimizing cache performance, configuring full-page cache, implementing Redis/Memcached, or designing cache invalidation strategies. Masters FPC, application cache, and distributed caching solutions.

maxnorm/magento2-agent-skills · 54 tokens

magento-index-analyst

Optimizes Magento 2 indexing for search performance and database efficiency. Use when optimizing search performance, configuring Elasticsearch, designing database indexes, or improving reindexing strategies. Masters indexer optimization, Elasticsearch configuration, and database indexing.

maxnorm/magento2-agent-skills · 52 tokens

postgres-commit-history-article

A workflow for comparing PostgreSQL source-code changes between two Git commits and, when useful, writing a Chinese Markdown article about them. PostgreSQL is a database system, and a commit is a saved change in a Git repository.

digoal/blog · 127 tokens

b2c-custom-objects

Store and query custom business data using CustomObjectMgr, OCAPI Data API, and Shopper Custom Objects API. Use this skill whenever the user needs to create, read, update, or search custom object instances, build processing queues with status fields, choose between site-scoped and organization-scoped storage, or query…

SalesforceCommerceCloud/b2c-developer-tooling · 104 tokens

b2c-querying-data

Write efficient data queries in B2C Commerce for products, customers, and orders. Use this skill whenever the user needs to search products on a storefront page, look up customer profiles, query orders, paginate search results, or fix slow category pages. Also use when they ask about performance problems with data…

SalesforceCommerceCloud/b2c-developer-tooling · 108 tokens