{"kind":"AgentDefinition","metadata":{"namespace":"community","name":"sql-sp-generation","version":"0.1.0"},"spec":{"agents_md":"---\ndescription: 'Guidelines for generating SQL statements and stored procedures'\napplyTo: '**/*.sql'\n---\n\n# SQL Development\n\n## Database schema generation\n- all table names should be in singular form\n- all column names should be in singular form\n- all tables should have a primary key column named `id`\n- all tables should have a column named `created_at` to store the creation timestamp\n- all tables should have a column named `updated_at` to store the last update timestamp\n\n## Database schema design\n- all tables should have a primary key constraint\n- all foreign key constraints should have a name\n- all foreign key constraints should be defined inline\n- all foreign key constraints should have `ON DELETE CASCADE` option\n- all foreign key constraints should have `ON UPDATE CASCADE` option\n- all foreign key constraints should reference the primary key of the parent table\n\n## SQL Coding Style\n- use uppercase for SQL keywords (SELECT, FROM, WHERE)\n- use consistent indentation for nested queries and conditions\n- include comments to explain complex logic\n- break long queries into multiple lines for readability\n- organize clauses consistently (SELECT, FROM, JOIN, WHERE, GROUP BY, HAVING, ORDER BY)\n\n## SQL Query Structure\n- use explicit column names in SELECT statements instead of SELECT *\n- qualify column names with table name or alias when using multiple tables\n- limit the use of subqueries when joins can be used instead\n- include LIMIT/TOP clauses to restrict result sets\n- use appropriate indexing for frequently queried columns\n- avoid using functions on indexed columns in WHERE clauses\n\n## Stored Procedure Naming Conventions\n- prefix stored procedure names with 'usp_'\n- use PascalCase for stored procedure names\n- use descriptive names that indicate purpose (e.g., usp_GetCustomerOrders)\n- include plural noun when returning multiple records (e.g., usp_GetProducts)\n- include singular noun when returning single record (e.g., usp_GetProduct)\n\n## Parameter Handling\n- prefix parameters with '@'\n- use camelCase for parameter names\n- provide default values for optional parameters\n- validate parameter values before use\n- document parameters with comments\n- arrange parameters consistently (required first, optional later)\n\n\n## Stored Procedure Structure\n- include header comment block with description, parameters, and return values\n- return standardized error codes/messages\n- return result sets with consistent column order\n- use OUTPUT parameters for returning status information\n- prefix temporary tables with 'tmp_'\n\n\n## SQL Security Best Practices\n- parameterize all queries to prevent SQL injection\n- use prepared statements when executing dynamic SQL\n- avoid embedding credentials in SQL scripts\n- implement proper error handling without exposing system details\n- avoid using dynamic SQL within stored procedures\n\n## Transaction Management\n- explicitly begin and commit transactions\n- use appropriate isolation levels based on requirements\n- avoid long-running transactions that lock tables\n- use batch processing for large data operations\n- include SET NOCOUNT ON for stored procedures that modify data\n","description":"Guidelines for generating SQL statements and stored procedures","import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/blob/541b7819d8c3545c6df122491af4fa1eae415779/instructions/sql-sp-generation.instructions.md"},"manifest":{}},"content_hash":[145,8,142,202,107,115,219,147,236,175,46,186,180,87,51,246,89,230,240,9,48,249,183,28,212,155,198,134,244,54,239,204],"trust_level":"unsigned","yanked":false}
