[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6X7TTAMADQ87AQ2V8V2HBPR":3,"skill-same:01M6X7TTAMADQ87AQ2V8V2HBPR":86},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":34,"publishedAt":48,"linkOnly":49,"markdownContent":50,"markdownBody":51,"frontMatter":52,"refName":57,"commitSha":58,"skillDirectory":59,"forksCount":60,"repositoryHtmlUrl":61,"repositoryHomepageUrl":62,"ownerHtmlUrl":63,"ownerBlogUrl":62,"ownerDescription":64,"updatedAt":65,"install":66,"resources":79},"01M6X7TTAMADQ87AQ2V8V2HBPR","sql-writing",null,"Use when writing raw SQL — dialect-aware syntax, parameterization, raw migrations, seeders with `DB::statement`; fires even on a pasted query asking 'why is this slow'.","event4u-app\u002Fagent-config","event4u-app","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F199339632?v=4","01M6X5TWBNCQCE1VDKT4E9KF7N","event4u.app","01M6X5TWF4HRM266RG2Q5VVH1X",19,"MIT","https:\u002F\u002Fgithub.com\u002Fevent4u-app\u002Fagent-config\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fsql-writing\u002FSKILL.md",[18,23,26,31],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":27,"categoryName":28,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",{"categoryNo":32,"categoryName":33,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000036","内容创作者",[35,36,37,38,39,40,41,42,43,44,45,46,47],"writing","sql","sql writing","engineering","why","syntax","use","migrations","base","query","db","with","when","2026-11-10 10:12:30",false,"---\nmodel_tier: medium\nname: sql-writing\ndescription: \"Use when writing raw SQL — dialect-aware syntax, parameterization, raw migrations, seeders with `DB::statement`; fires even on a pasted query asking 'why is this slow'.\"\ndomain: engineering\nworkspaces:\n  - engineering\npacks:\n  - engineering-base\n---\n\n# sql\n\n\n> **Grounded corpus:** tuning decisions (indexes, keyset pagination,\n> N+1, trigram search, lock contention) ground via the\n> [`database`](..\u002Fdatabase\u002FSKILL.md) corpus — `node\n> \u003Cskills-root>\u002Fcorpus-grounding\u002Fscripts\u002Fground.mjs search\n> --manifest \u003Cskills-root>\u002Fdatabase\u002Fdata\u002Fmanifest.json \"\u003Csymptom>\"`.\n\n## When to use\n\nUse when writing or reviewing raw SQL queries, migrations with raw statements, or seeders with raw SQL.\n\nDo NOT use when:\n- Eloquent\u002FQuery Builder queries (use `eloquent` or `database` skill)\n- Schema design (use `database` skill)\n\n## Procedure: Write raw SQL\n\n1. **Inspect call site & choose approach** — identify every dynamic value flowing into the query, then pick: query builder when possible. Raw SQL only when query builder can't express the query.\n2. **Parameterize** — Every variable must use `?` binding or named `:param`. Never interpolate PHP variables into SQL strings.\n3. **Read the engine, then choose the syntax** — check, in order: the project's DB config (`config\u002Fdatabase.php` default connection, `DB_CONNECTION`), a `docker-compose.yml` service image, a migration using engine-specific syntax. MySQL and MariaDB share the query-syntax world this skill writes in; PostgreSQL and MSSQL do not. **If none of those declare an engine, say so and ask — do not assume one.** A query written for the wrong engine passes review and fails in production.\n4. **Verify** — Run EXPLAIN on complex queries. Check that no PHP interpolation (`\"$var\"`, `'{$var}'`) appears in SQL.\n\n```\nNEVER build SQL strings with PHP variable interpolation or concatenation.\nALWAYS use parameterized queries or query builder.\n```\n\n## Conventions\n\n→ See guideline `php\u002Fsql.md` for parameterization patterns, common mistakes, MariaDB syntax reference.\n\n## Quick reference\n\n```php\n\u002F\u002F ✅ Safe\nDB::select('SELECT * FROM users WHERE email = ?', [$email]);\n\n\u002F\u002F ❌ SQL injection\nDB::select(\"SELECT * FROM users WHERE email = '{$email}'\");\n```\n\n### Validate\n\n1. Verify every variable in SQL uses parameter binding (`?` or named `:param`).\n2. Confirm Procedure step 3 found MySQL\u002FMariaDB; else say so.\n3. Run EXPLAIN on complex queries to check index usage.\n4. Check that no PHP variable interpolation (`\"$var\"`, `'{$var}'`) appears in SQL strings.\n\n## Output format\n\n1. Parameterized SQL query in MySQL\u002FMariaDB syntax\n2. EXPLAIN output for performance-critical queries\n\n## Gotcha\n\n**MySQL and MariaDB share a query-syntax world. They never share a migration\none.** Same principle as `database`: one engine for writing a `SELECT`, two for\nonline-DDL semantics, lock behavior under `ALTER`, feature availability and\n`EXPLAIN` output. Never carry a claim from the second group across the two\nwithout naming the engine and version it was measured on.\n\n- MariaDB and MySQL have subtle syntax differences.\n- The model writes `$variable` in SQL strings instead of `?` placeholders.\n- `GROUP BY` with `ONLY_FULL_GROUP_BY` requires all non-aggregated columns.\n- Use SQL types (`NULL`, `1\u002F0`, `JSON_ARRAY()`) — not PHP equivalents.\n\n## Do NOT\n\n- Do NOT interpolate PHP variables into SQL strings — always parameterize.\n- Do NOT use PHP syntax (arrays, booleans, null) in raw SQL — use SQL equivalents.\n- Do NOT write raw SQL when the query builder can express the same thing clearly.\n\n## Auto-trigger keywords\n\n- raw SQL\n- SQL query\n- parameterized query\n- MariaDB syntax\n- SQL injection\n","# sql\n\n\n> **Grounded corpus:** tuning decisions (indexes, keyset pagination,\n> N+1, trigram search, lock contention) ground via the\n> [`database`](..\u002Fdatabase\u002FSKILL.md) corpus — `node\n> \u003Cskills-root>\u002Fcorpus-grounding\u002Fscripts\u002Fground.mjs search\n> --manifest \u003Cskills-root>\u002Fdatabase\u002Fdata\u002Fmanifest.json \"\u003Csymptom>\"`.\n\n## When to use\n\nUse when writing or reviewing raw SQL queries, migrations with raw statements, or seeders with raw SQL.\n\nDo NOT use when:\n- Eloquent\u002FQuery Builder queries (use `eloquent` or `database` skill)\n- Schema design (use `database` skill)\n\n## Procedure: Write raw SQL\n\n1. **Inspect call site & choose approach** — identify every dynamic value flowing into the query, then pick: query builder when possible. Raw SQL only when query builder can't express the query.\n2. **Parameterize** — Every variable must use `?` binding or named `:param`. Never interpolate PHP variables into SQL strings.\n3. **Read the engine, then choose the syntax** — check, in order: the project's DB config (`config\u002Fdatabase.php` default connection, `DB_CONNECTION`), a `docker-compose.yml` service image, a migration using engine-specific syntax. MySQL and MariaDB share the query-syntax world this skill writes in; PostgreSQL and MSSQL do not. **If none of those declare an engine, say so and ask — do not assume one.** A query written for the wrong engine passes review and fails in production.\n4. **Verify** — Run EXPLAIN on complex queries. Check that no PHP interpolation (`\"$var\"`, `'{$var}'`) appears in SQL.\n\n```\nNEVER build SQL strings with PHP variable interpolation or concatenation.\nALWAYS use parameterized queries or query builder.\n```\n\n## Conventions\n\n→ See guideline `php\u002Fsql.md` for parameterization patterns, common mistakes, MariaDB syntax reference.\n\n## Quick reference\n\n```php\n\u002F\u002F ✅ Safe\nDB::select('SELECT * FROM users WHERE email = ?', [$email]);\n\n\u002F\u002F ❌ SQL injection\nDB::select(\"SELECT * FROM users WHERE email = '{$email}'\");\n```\n\n### Validate\n\n1. Verify every variable in SQL uses parameter binding (`?` or named `:param`).\n2. Confirm Procedure step 3 found MySQL\u002FMariaDB; else say so.\n3. Run EXPLAIN on complex queries to check index usage.\n4. Check that no PHP variable interpolation (`\"$var\"`, `'{$var}'`) appears in SQL strings.\n\n## Output format\n\n1. Parameterized SQL query in MySQL\u002FMariaDB syntax\n2. EXPLAIN output for performance-critical queries\n\n## Gotcha\n\n**MySQL and MariaDB share a query-syntax world. They never share a migration\none.** Same principle as `database`: one engine for writing a `SELECT`, two for\nonline-DDL semantics, lock behavior under `ALTER`, feature availability and\n`EXPLAIN` output. Never carry a claim from the second group across the two\nwithout naming the engine and version it was measured on.\n\n- MariaDB and MySQL have subtle syntax differences.\n- The model writes `$variable` in SQL strings instead of `?` placeholders.\n- `GROUP BY` with `ONLY_FULL_GROUP_BY` requires all non-aggregated columns.\n- Use SQL types (`NULL`, `1\u002F0`, `JSON_ARRAY()`) — not PHP equivalents.\n\n## Do NOT\n\n- Do NOT interpolate PHP variables into SQL strings — always parameterize.\n- Do NOT use PHP syntax (arrays, booleans, null) in raw SQL — use SQL equivalents.\n- Do NOT write raw SQL when the query builder can express the same thing clearly.\n\n## Auto-trigger keywords\n\n- raw SQL\n- SQL query\n- parameterized query\n- MariaDB syntax\n- SQL injection\n",{"name":5,"packs":53,"domain":38,"model_tier":55,"workspaces":56,"description":7},[54],"engineering-base","medium",[38],"main","12bd765ce1d800501d45dfb8232102793af01290","src\u002Fskills\u002Fsql-writing",1,"https:\u002F\u002Fgithub.com\u002Fevent4u-app\u002Fagent-config","https:\u002F\u002Fevent4u.app","https:\u002F\u002Fgithub.com\u002Fevent4u-app","Your events in your hand","2026-11-13 03:25:49",{"source":8,"skillName":5,"commands":67,"prompt":77,"zipAvailable":78},[68,71,74],{"tool":69,"command":70},"npx","npx skills add event4u-app\u002Fagent-config --skill sql-writing",{"tool":72,"command":73},"bunx","bunx skills add event4u-app\u002Fagent-config --skill sql-writing",{"tool":75,"command":76},"pnpm","pnpm dlx skills add event4u-app\u002Fagent-config --skill sql-writing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fevent4u-app\u002Fagent-config\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fsql-writing\u002FSKILL.md",true,[80],{"path":81,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":84,"sourceHtmlUrl":85},"evals\u002Ftriggers.json","REFERENCE","参考文档",3297,"https:\u002F\u002Fgithub.com\u002Fevent4u-app\u002Fagent-config\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fsql-writing\u002Fevals\u002Ftriggers.json",[87,103,116,128,140,150],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":96,"publishedAt":48},"01M6X84PK96XBPENXH66JCTSD1","unknown-key-fixture","Declares a key the schema does not know.","https:\u002F\u002Fgithub.com\u002Fevent4u-app\u002Fagent-config\u002Fblob\u002Fmain\u002Ftests\u002Fscripts\u002Ffixtures\u002Fbody-portable\u002Funknown-key\u002FSKILL.md",[93],{"categoryNo":94,"categoryName":95,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[97,98,99,100,101,102],"unknown key fixture","Unknown key","fixture","unknown","schema","package",{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":110,"publishedAt":48},"01M6X84HW7NAHZ7GZMQ9RXK1XJ","portable-fixture","Declares only semantics the MCP-lite carrier transports whole.","https:\u002F\u002Fgithub.com\u002Fevent4u-app\u002Fagent-config\u002Fblob\u002Fmain\u002Ftests\u002Fscripts\u002Ffixtures\u002Fbody-portable\u002Fportable\u002FSKILL.md",[109],{"categoryNo":94,"categoryName":95,"taxonomyType":21,"taxonomyTypeDesc":22},[99,111,112,113,114,102,115],"portable","portable fixture","engineer","only","MCP",{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":123,"publishedAt":48},"01M6X84F29FE0RGGZ1ZTFGZTX2","non-portable-fixture","Declares a runtime semantic the carrier drops.","https:\u002F\u002Fgithub.com\u002Fevent4u-app\u002Fagent-config\u002Fblob\u002Fmain\u002Ftests\u002Fscripts\u002Ffixtures\u002Fbody-portable\u002Fnon-portable\u002FSKILL.md",[122],{"categoryNo":94,"categoryName":95,"taxonomyType":21,"taxonomyTypeDesc":22},[112,124,111,99,125,126,127,102],"non portable fixture","semantic","high","runtime",{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":132,"categories":133,"keywords":135,"publishedAt":48},"01M6X848F706PT9MDCX75JKJ6B","candidate-zero-width","A candidate whose prose carries an invisible joiner.","https:\u002F\u002Fgithub.com\u002Fevent4u-app\u002Fagent-config\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskill-scout-candidates\u002Fzero-width-injection\u002FSKILL.md",[134],{"categoryNo":94,"categoryName":95,"taxonomyType":21,"taxonomyTypeDesc":22},[136,137,138,139],"candidate zero width","candidate","ZeRO","prose",{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":147,"publishedAt":48},"01M6X841SSC2T31VDF41SA6DG1","candidate-disclosure-suppression","A candidate whose prose tells the agent to withhold from the user.","https:\u002F\u002Fgithub.com\u002Fevent4u-app\u002Fagent-config\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskill-scout-candidates\u002Fdisclosure-suppression\u002FSKILL.md",[146],{"categoryNo":94,"categoryName":95,"taxonomyType":21,"taxonomyTypeDesc":22},[148,137,139,149],"candidate disclosure suppression","user",{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":154,"categories":155,"keywords":157,"publishedAt":48},"01M6X83TFS5AGPBPVTQNWP0BB3","candidate-dangerous-frontmatter","A candidate claiming an unscoped tool grant and a permission bypass.","https:\u002F\u002Fgithub.com\u002Fevent4u-app\u002Fagent-config\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskill-scout-candidates\u002Fdangerous-frontmatter\u002FSKILL.md",[156],{"categoryNo":94,"categoryName":95,"taxonomyType":21,"taxonomyTypeDesc":22},[158,137,159,160,161,162],"candidate dangerous frontmatter","frontmatter","shell","permission","tool"]