@totaland/create-starter-kit 1.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +130 -18
- package/bin/index.js +109 -21
- package/package.json +2 -2
- package/templates/backend/.github/agents/ /360/237/216/255 planner.agent.md" +92 -0
- package/templates/backend/.github/agents/api-architect.agent.md +41 -0
- package/templates/backend/.github/agents/code-reviewer.agent.md +26 -0
- package/templates/backend/.github/agents/code-simplifier.agent.md +41 -0
- package/templates/backend/.github/agents/code-skeptic.agent.md +74 -0
- package/templates/backend/.github/agents/docs-specialist.agent.md +25 -0
- package/templates/backend/.github/agents/implementation-plan.agent.md +160 -0
- package/templates/backend/.github/agents/janitor.agent.md +90 -0
- package/templates/backend/.github/agents/ms-sql-dba.agent.md +25 -0
- package/templates/backend/.github/agents/plan.agent.md +115 -0
- package/templates/backend/.github/agents/planner.agent.md +15 -0
- package/templates/backend/.github/agents/playwright-tester.agent.md +13 -0
- package/templates/backend/.github/agents/postgresql-dba.agent.md +18 -0
- package/templates/backend/.github/agents/prd.agent.md +202 -0
- package/templates/backend/.github/agents/research-technical-spike.agent.md +170 -0
- package/templates/backend/.github/agents/software-engineer-agent-v1.agent.md +165 -0
- package/templates/backend/.github/agents/task-planner.agent.md +375 -0
- package/templates/backend/.github/agents/task-researcher.agent.md +255 -0
- package/templates/backend/.github/agents/tdd-green.agent.md +60 -0
- package/templates/backend/.github/agents/tdd-red.agent.md +60 -0
- package/templates/backend/.github/agents/tdd-refactor.agent.md +85 -0
- package/templates/backend/.github/agents/tech-debt-remediation-plan.agent.md +50 -0
- package/templates/backend/.github/agents/typescript-mcp-expert.agent.md +91 -0
- package/templates/backend/.github/agents/ultimate-thinking-beastmode.agent.md +644 -0
- package/templates/backend/.github/agents//360/237/216/255 generator.agent.md" +264 -0
- package/templates/backend/.github/agents//360/237/216/255 healer.agent.md" +44 -0
- package/templates/backend/.github/agents//360/237/216/255 pom.agent.md" +308 -0
- package/templates/backend/.github/instructions/a11y.instructions.md +369 -0
- package/templates/backend/.github/instructions/ms-sql-dba.instructions.md +25 -0
- package/templates/backend/.github/instructions/object-calisthenics.instructions.md +302 -0
- package/templates/backend/.github/instructions/performance-optimization.instructions.md +420 -0
- package/templates/backend/.github/instructions/playwright-python.instructions.md +62 -0
- package/templates/backend/.github/instructions/playwright-typescript.instructions.md +86 -0
- package/templates/backend/.github/instructions/security-and-owasp.instructions.md +51 -0
- package/templates/backend/.github/instructions/self-explanatory-code-commenting.instructions.md +162 -0
- package/templates/backend/.github/instructions/spec-driven-workflow-v1.instructions.md +323 -0
- package/templates/backend/.github/instructions/sql-sp-generation.instructions.md +74 -0
- package/templates/backend/.github/instructions/task-implementation.instructions.md +190 -0
- package/templates/backend/.github/instructions/typescript-mcp-server.instructions.md +228 -0
- package/templates/backend/.github/prompts/ai-prompt-engineering-safety-review.prompt.md +229 -0
- package/templates/backend/.github/prompts/architecture-blueprint-generator.prompt.md +321 -0
- package/templates/backend/.github/prompts/breakdown-epic-arch.prompt.md +65 -0
- package/templates/backend/.github/prompts/breakdown-epic-pm.prompt.md +57 -0
- package/templates/backend/.github/prompts/breakdown-feature-implementation.prompt.md +127 -0
- package/templates/backend/.github/prompts/breakdown-feature-prd.prompt.md +60 -0
- package/templates/backend/.github/prompts/breakdown-plan.prompt.md +508 -0
- package/templates/backend/.github/prompts/copilot-instructions-blueprint-generator.prompt.md +293 -0
- package/templates/backend/.github/prompts/create-agentsmd.prompt.md +248 -0
- package/templates/backend/.github/prompts/create-github-issue-feature-from-specification.prompt.md +27 -0
- package/templates/backend/.github/prompts/create-github-issues-feature-from-implementation-plan.prompt.md +27 -0
- package/templates/backend/.github/prompts/create-github-issues-for-unmet-specification-requirements.prompt.md +35 -0
- package/templates/backend/.github/prompts/create-implementation-plan.prompt.md +156 -0
- package/templates/backend/.github/prompts/create-llms.prompt.md +209 -0
- package/templates/backend/.github/prompts/create-specification.prompt.md +126 -0
- package/templates/backend/.github/prompts/create-technical-spike.prompt.md +230 -0
- package/templates/backend/.github/prompts/csharp-nunit.prompt.md +71 -0
- package/templates/backend/.github/prompts/ef-core.prompt.md +76 -0
- package/templates/backend/.github/prompts/folder-structure-blueprint-generator.prompt.md +404 -0
- package/templates/backend/.github/prompts/gen-specs-as-issues.prompt.md +165 -0
- package/templates/backend/.github/prompts/generate-custom-instructions-from-codebase.prompt.md +239 -0
- package/templates/backend/.github/prompts/java-junit.prompt.md +64 -0
- package/templates/backend/.github/prompts/memory-merger.prompt.md +107 -0
- package/templates/backend/.github/prompts/multi-stage-dockerfile.prompt.md +46 -0
- package/templates/backend/.github/prompts/playwright-automation-fill-in-form.prompt.md +29 -0
- package/templates/backend/.github/prompts/playwright-explore-website.prompt.md +19 -0
- package/templates/backend/.github/prompts/playwright-generate-test.prompt.md +19 -0
- package/templates/backend/.github/prompts/postgresql-code-review.prompt.md +214 -0
- package/templates/backend/.github/prompts/postgresql-optimization.prompt.md +406 -0
- package/templates/backend/.github/prompts/project-workflow-analysis-blueprint-generator.prompt.md +294 -0
- package/templates/backend/.github/prompts/prompt-builder.prompt.md +142 -0
- package/templates/backend/.github/prompts/remember.prompt.md +125 -0
- package/templates/backend/.github/prompts/review-and-refactor.prompt.md +15 -0
- package/templates/backend/.github/prompts/sql-code-review.prompt.md +303 -0
- package/templates/backend/.github/prompts/sql-optimization.prompt.md +298 -0
- package/templates/backend/.github/prompts/suggest-awesome-github-copilot-agents.prompt.md +72 -0
- package/templates/backend/.github/prompts/suggest-awesome-github-copilot-chatmodes.prompt.md +71 -0
- package/templates/backend/.github/prompts/suggest-awesome-github-copilot-collections.prompt.md +149 -0
- package/templates/backend/.github/prompts/suggest-awesome-github-copilot-instructions.prompt.md +88 -0
- package/templates/backend/.github/prompts/suggest-awesome-github-copilot-prompts.prompt.md +71 -0
- package/templates/backend/.github/prompts/technology-stack-blueprint-generator.prompt.md +242 -0
- package/templates/backend/.github/prompts/typescript-mcp-server-generator.prompt.md +90 -0
- package/templates/backend/.github/prompts/update-implementation-plan.prompt.md +157 -0
- package/templates/backend/.github/prompts/update-markdown-file-index.prompt.md +76 -0
- package/templates/backend/Project_Folders_Structure_Blueprint.md +529 -0
- package/templates/backend/README.md +99 -0
- package/templates/backend/biome.json +45 -0
- package/{template → templates/backend}/drizzle.config.ts +1 -1
- package/{template → templates/backend}/package.json +9 -4
- package/templates/backend/pnpm-lock.yaml +4240 -0
- package/templates/backend/src/features/health/health.test.ts +23 -0
- package/{template → templates/backend}/src/features/health/index.ts +1 -0
- package/templates/backend/src/features/health/schemas.ts +29 -0
- package/templates/backend/src/features/orders/controller.ts +18 -0
- package/templates/backend/src/features/orders/index.ts +10 -0
- package/templates/backend/src/features/orders/schemas.ts +62 -0
- package/{template → templates/backend}/src/index.ts +3 -36
- package/templates/backend/src/lib/openapi.ts +25 -0
- package/templates/backend/src/lib/validateRequest.test.ts +84 -0
- package/templates/backend/src/lib/validateRequest.ts +72 -0
- package/{template → templates/backend}/tsconfig.json +2 -2
- package/{template → templates/backend}/vitest.config.ts +8 -1
- package/templates/frontend/.env.example +7 -0
- package/templates/frontend/.github/agents/ /360/237/216/255 planner.agent.md" +92 -0
- package/templates/frontend/.github/agents/api-architect.agent.md +41 -0
- package/templates/frontend/.github/agents/code-reviewer.agent.md +26 -0
- package/templates/frontend/.github/agents/code-simplifier.agent.md +41 -0
- package/templates/frontend/.github/agents/code-skeptic.agent.md +74 -0
- package/templates/frontend/.github/agents/docs-specialist.agent.md +25 -0
- package/templates/frontend/.github/agents/implementation-plan.agent.md +160 -0
- package/templates/frontend/.github/agents/janitor.agent.md +90 -0
- package/templates/frontend/.github/agents/ms-sql-dba.agent.md +25 -0
- package/templates/frontend/.github/agents/plan.agent.md +115 -0
- package/templates/frontend/.github/agents/planner.agent.md +15 -0
- package/templates/frontend/.github/agents/playwright-tester.agent.md +13 -0
- package/templates/frontend/.github/agents/postgresql-dba.agent.md +18 -0
- package/templates/frontend/.github/agents/prd.agent.md +202 -0
- package/templates/frontend/.github/agents/research-technical-spike.agent.md +170 -0
- package/templates/frontend/.github/agents/software-engineer-agent-v1.agent.md +165 -0
- package/templates/frontend/.github/agents/task-planner.agent.md +375 -0
- package/templates/frontend/.github/agents/task-researcher.agent.md +255 -0
- package/templates/frontend/.github/agents/tdd-green.agent.md +60 -0
- package/templates/frontend/.github/agents/tdd-red.agent.md +60 -0
- package/templates/frontend/.github/agents/tdd-refactor.agent.md +85 -0
- package/templates/frontend/.github/agents/tech-debt-remediation-plan.agent.md +50 -0
- package/templates/frontend/.github/agents/typescript-mcp-expert.agent.md +91 -0
- package/templates/frontend/.github/agents/ultimate-thinking-beastmode.agent.md +644 -0
- package/templates/frontend/.github/agents//360/237/216/255 generator.agent.md" +264 -0
- package/templates/frontend/.github/agents//360/237/216/255 healer.agent.md" +44 -0
- package/templates/frontend/.github/agents//360/237/216/255 pom.agent.md" +308 -0
- package/templates/frontend/.github/instructions/a11y.instructions.md +369 -0
- package/templates/frontend/.github/instructions/ms-sql-dba.instructions.md +25 -0
- package/templates/frontend/.github/instructions/object-calisthenics.instructions.md +302 -0
- package/templates/frontend/.github/instructions/performance-optimization.instructions.md +420 -0
- package/templates/frontend/.github/instructions/playwright-python.instructions.md +62 -0
- package/templates/frontend/.github/instructions/playwright-typescript.instructions.md +86 -0
- package/templates/frontend/.github/instructions/security-and-owasp.instructions.md +51 -0
- package/templates/frontend/.github/instructions/self-explanatory-code-commenting.instructions.md +162 -0
- package/templates/frontend/.github/instructions/spec-driven-workflow-v1.instructions.md +323 -0
- package/templates/frontend/.github/instructions/sql-sp-generation.instructions.md +74 -0
- package/templates/frontend/.github/instructions/task-implementation.instructions.md +190 -0
- package/templates/frontend/.github/instructions/typescript-mcp-server.instructions.md +228 -0
- package/templates/frontend/.github/prompts/ai-prompt-engineering-safety-review.prompt.md +229 -0
- package/templates/frontend/.github/prompts/architecture-blueprint-generator.prompt.md +321 -0
- package/templates/frontend/.github/prompts/breakdown-epic-arch.prompt.md +65 -0
- package/templates/frontend/.github/prompts/breakdown-epic-pm.prompt.md +57 -0
- package/templates/frontend/.github/prompts/breakdown-feature-implementation.prompt.md +127 -0
- package/templates/frontend/.github/prompts/breakdown-feature-prd.prompt.md +60 -0
- package/templates/frontend/.github/prompts/breakdown-plan.prompt.md +508 -0
- package/templates/frontend/.github/prompts/copilot-instructions-blueprint-generator.prompt.md +293 -0
- package/templates/frontend/.github/prompts/create-agentsmd.prompt.md +248 -0
- package/templates/frontend/.github/prompts/create-github-issue-feature-from-specification.prompt.md +27 -0
- package/templates/frontend/.github/prompts/create-github-issues-feature-from-implementation-plan.prompt.md +27 -0
- package/templates/frontend/.github/prompts/create-github-issues-for-unmet-specification-requirements.prompt.md +35 -0
- package/templates/frontend/.github/prompts/create-implementation-plan.prompt.md +156 -0
- package/templates/frontend/.github/prompts/create-llms.prompt.md +209 -0
- package/templates/frontend/.github/prompts/create-specification.prompt.md +126 -0
- package/templates/frontend/.github/prompts/create-technical-spike.prompt.md +230 -0
- package/templates/frontend/.github/prompts/csharp-nunit.prompt.md +71 -0
- package/templates/frontend/.github/prompts/ef-core.prompt.md +76 -0
- package/templates/frontend/.github/prompts/folder-structure-blueprint-generator.prompt.md +404 -0
- package/templates/frontend/.github/prompts/gen-specs-as-issues.prompt.md +165 -0
- package/templates/frontend/.github/prompts/generate-custom-instructions-from-codebase.prompt.md +239 -0
- package/templates/frontend/.github/prompts/java-junit.prompt.md +64 -0
- package/templates/frontend/.github/prompts/memory-merger.prompt.md +107 -0
- package/templates/frontend/.github/prompts/multi-stage-dockerfile.prompt.md +46 -0
- package/templates/frontend/.github/prompts/playwright-automation-fill-in-form.prompt.md +29 -0
- package/templates/frontend/.github/prompts/playwright-explore-website.prompt.md +19 -0
- package/templates/frontend/.github/prompts/playwright-generate-test.prompt.md +19 -0
- package/templates/frontend/.github/prompts/postgresql-code-review.prompt.md +214 -0
- package/templates/frontend/.github/prompts/postgresql-optimization.prompt.md +406 -0
- package/templates/frontend/.github/prompts/project-workflow-analysis-blueprint-generator.prompt.md +294 -0
- package/templates/frontend/.github/prompts/prompt-builder.prompt.md +142 -0
- package/templates/frontend/.github/prompts/remember.prompt.md +125 -0
- package/templates/frontend/.github/prompts/review-and-refactor.prompt.md +15 -0
- package/templates/frontend/.github/prompts/sql-code-review.prompt.md +303 -0
- package/templates/frontend/.github/prompts/sql-optimization.prompt.md +298 -0
- package/templates/frontend/.github/prompts/suggest-awesome-github-copilot-agents.prompt.md +72 -0
- package/templates/frontend/.github/prompts/suggest-awesome-github-copilot-chatmodes.prompt.md +71 -0
- package/templates/frontend/.github/prompts/suggest-awesome-github-copilot-collections.prompt.md +149 -0
- package/templates/frontend/.github/prompts/suggest-awesome-github-copilot-instructions.prompt.md +88 -0
- package/templates/frontend/.github/prompts/suggest-awesome-github-copilot-prompts.prompt.md +71 -0
- package/templates/frontend/.github/prompts/technology-stack-blueprint-generator.prompt.md +242 -0
- package/templates/frontend/.github/prompts/typescript-mcp-server-generator.prompt.md +90 -0
- package/templates/frontend/.github/prompts/update-implementation-plan.prompt.md +157 -0
- package/templates/frontend/.github/prompts/update-markdown-file-index.prompt.md +76 -0
- package/templates/frontend/README.md +199 -0
- package/templates/frontend/biome.json +45 -0
- package/templates/frontend/components.json +22 -0
- package/templates/frontend/index.html +13 -0
- package/templates/frontend/package.json +44 -0
- package/templates/frontend/pnpm-lock.yaml +2011 -0
- package/templates/frontend/postcss.config.js +6 -0
- package/templates/frontend/public/vite.svg +1 -0
- package/templates/frontend/src/App.css +42 -0
- package/templates/frontend/src/App.tsx +17 -0
- package/templates/frontend/src/assets/react.svg +1 -0
- package/templates/frontend/src/components/layout/layout.component.tsx +31 -0
- package/templates/frontend/src/components/menu-toggle-icon.tsx +53 -0
- package/templates/frontend/src/components/ui/button.tsx +57 -0
- package/templates/frontend/src/docs/RECOMMENDED_LIBRARIES.md +226 -0
- package/templates/frontend/src/docs/SETUP_SUMMARY.md +162 -0
- package/templates/frontend/src/hooks/use-scroll.ts +21 -0
- package/templates/frontend/src/index.css +121 -0
- package/templates/frontend/src/lib/api-client.ts +46 -0
- package/templates/frontend/src/lib/utils.ts +6 -0
- package/templates/frontend/src/main.tsx +30 -0
- package/templates/frontend/src/pages/about/about.page.tsx +50 -0
- package/templates/frontend/src/pages/home/home.page.tsx +43 -0
- package/templates/frontend/tailwind.config.js +59 -0
- package/templates/frontend/tsconfig.app.json +41 -0
- package/templates/frontend/tsconfig.json +13 -0
- package/templates/frontend/tsconfig.node.json +26 -0
- package/templates/frontend/vite.config.ts +14 -0
- package/template/.env.example +0 -8
- package/template/AGENTS.md +0 -23
- package/template/ARCHITECTURE.md +0 -53
- package/template/ORDER_SYSTEM.md +0 -93
- package/template/biome.json +0 -3
- package/template/src/features/orders/controller.ts +0 -13
- package/template/src/features/orders/index.ts +0 -7
- /package/{template → templates/backend}/knip.json +0 -0
- /package/{template → templates/backend}/playwright.config.ts +0 -0
- /package/{template → templates/backend}/pnpm-workspace.yaml +0 -0
- /package/{template → templates/backend}/src/features/health/controller.ts +0 -0
- /package/{template → templates/backend}/tsconfig.build.json +0 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
---
|
|
2
|
+
mode: 'agent'
|
|
3
|
+
tools: ['changes', 'search/codebase', 'edit/editFiles', 'problems']
|
|
4
|
+
description: 'Universal SQL code review assistant that performs comprehensive security, maintainability, and code quality analysis across all SQL databases (MySQL, PostgreSQL, SQL Server, Oracle). Focuses on SQL injection prevention, access control, code standards, and anti-pattern detection. Complements SQL optimization prompt for complete development coverage.'
|
|
5
|
+
tested_with: 'GitHub Copilot Chat (GPT-4o) - Validated July 20, 2025'
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# SQL Code Review
|
|
9
|
+
|
|
10
|
+
Perform a thorough SQL code review of ${selection} (or entire project if no selection) focusing on security, performance, maintainability, and database best practices.
|
|
11
|
+
|
|
12
|
+
## 🔒 Security Analysis
|
|
13
|
+
|
|
14
|
+
### SQL Injection Prevention
|
|
15
|
+
```sql
|
|
16
|
+
-- ❌ CRITICAL: SQL Injection vulnerability
|
|
17
|
+
query = "SELECT * FROM users WHERE id = " + userInput;
|
|
18
|
+
query = f"DELETE FROM orders WHERE user_id = {user_id}";
|
|
19
|
+
|
|
20
|
+
-- ✅ SECURE: Parameterized queries
|
|
21
|
+
-- PostgreSQL/MySQL
|
|
22
|
+
PREPARE stmt FROM 'SELECT * FROM users WHERE id = ?';
|
|
23
|
+
EXECUTE stmt USING @user_id;
|
|
24
|
+
|
|
25
|
+
-- SQL Server
|
|
26
|
+
EXEC sp_executesql N'SELECT * FROM users WHERE id = @id', N'@id INT', @id = @user_id;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Access Control & Permissions
|
|
30
|
+
- **Principle of Least Privilege**: Grant minimum required permissions
|
|
31
|
+
- **Role-Based Access**: Use database roles instead of direct user permissions
|
|
32
|
+
- **Schema Security**: Proper schema ownership and access controls
|
|
33
|
+
- **Function/Procedure Security**: Review DEFINER vs INVOKER rights
|
|
34
|
+
|
|
35
|
+
### Data Protection
|
|
36
|
+
- **Sensitive Data Exposure**: Avoid SELECT * on tables with sensitive columns
|
|
37
|
+
- **Audit Logging**: Ensure sensitive operations are logged
|
|
38
|
+
- **Data Masking**: Use views or functions to mask sensitive data
|
|
39
|
+
- **Encryption**: Verify encrypted storage for sensitive data
|
|
40
|
+
|
|
41
|
+
## ⚡ Performance Optimization
|
|
42
|
+
|
|
43
|
+
### Query Structure Analysis
|
|
44
|
+
```sql
|
|
45
|
+
-- ❌ BAD: Inefficient query patterns
|
|
46
|
+
SELECT DISTINCT u.*
|
|
47
|
+
FROM users u, orders o, products p
|
|
48
|
+
WHERE u.id = o.user_id
|
|
49
|
+
AND o.product_id = p.id
|
|
50
|
+
AND YEAR(o.order_date) = 2024;
|
|
51
|
+
|
|
52
|
+
-- ✅ GOOD: Optimized structure
|
|
53
|
+
SELECT u.id, u.name, u.email
|
|
54
|
+
FROM users u
|
|
55
|
+
INNER JOIN orders o ON u.id = o.user_id
|
|
56
|
+
WHERE o.order_date >= '2024-01-01'
|
|
57
|
+
AND o.order_date < '2025-01-01';
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Index Strategy Review
|
|
61
|
+
- **Missing Indexes**: Identify columns that need indexing
|
|
62
|
+
- **Over-Indexing**: Find unused or redundant indexes
|
|
63
|
+
- **Composite Indexes**: Multi-column indexes for complex queries
|
|
64
|
+
- **Index Maintenance**: Check for fragmented or outdated indexes
|
|
65
|
+
|
|
66
|
+
### Join Optimization
|
|
67
|
+
- **Join Types**: Verify appropriate join types (INNER vs LEFT vs EXISTS)
|
|
68
|
+
- **Join Order**: Optimize for smaller result sets first
|
|
69
|
+
- **Cartesian Products**: Identify and fix missing join conditions
|
|
70
|
+
- **Subquery vs JOIN**: Choose the most efficient approach
|
|
71
|
+
|
|
72
|
+
### Aggregate and Window Functions
|
|
73
|
+
```sql
|
|
74
|
+
-- ❌ BAD: Inefficient aggregation
|
|
75
|
+
SELECT user_id,
|
|
76
|
+
(SELECT COUNT(*) FROM orders o2 WHERE o2.user_id = o1.user_id) as order_count
|
|
77
|
+
FROM orders o1
|
|
78
|
+
GROUP BY user_id;
|
|
79
|
+
|
|
80
|
+
-- ✅ GOOD: Efficient aggregation
|
|
81
|
+
SELECT user_id, COUNT(*) as order_count
|
|
82
|
+
FROM orders
|
|
83
|
+
GROUP BY user_id;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## 🛠️ Code Quality & Maintainability
|
|
87
|
+
|
|
88
|
+
### SQL Style & Formatting
|
|
89
|
+
```sql
|
|
90
|
+
-- ❌ BAD: Poor formatting and style
|
|
91
|
+
select u.id,u.name,o.total from users u left join orders o on u.id=o.user_id where u.status='active' and o.order_date>='2024-01-01';
|
|
92
|
+
|
|
93
|
+
-- ✅ GOOD: Clean, readable formatting
|
|
94
|
+
SELECT u.id,
|
|
95
|
+
u.name,
|
|
96
|
+
o.total
|
|
97
|
+
FROM users u
|
|
98
|
+
LEFT JOIN orders o ON u.id = o.user_id
|
|
99
|
+
WHERE u.status = 'active'
|
|
100
|
+
AND o.order_date >= '2024-01-01';
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Naming Conventions
|
|
104
|
+
- **Consistent Naming**: Tables, columns, constraints follow consistent patterns
|
|
105
|
+
- **Descriptive Names**: Clear, meaningful names for database objects
|
|
106
|
+
- **Reserved Words**: Avoid using database reserved words as identifiers
|
|
107
|
+
- **Case Sensitivity**: Consistent case usage across schema
|
|
108
|
+
|
|
109
|
+
### Schema Design Review
|
|
110
|
+
- **Normalization**: Appropriate normalization level (avoid over/under-normalization)
|
|
111
|
+
- **Data Types**: Optimal data type choices for storage and performance
|
|
112
|
+
- **Constraints**: Proper use of PRIMARY KEY, FOREIGN KEY, CHECK, NOT NULL
|
|
113
|
+
- **Default Values**: Appropriate default values for columns
|
|
114
|
+
|
|
115
|
+
## 🗄️ Database-Specific Best Practices
|
|
116
|
+
|
|
117
|
+
### PostgreSQL
|
|
118
|
+
```sql
|
|
119
|
+
-- Use JSONB for JSON data
|
|
120
|
+
CREATE TABLE events (
|
|
121
|
+
id SERIAL PRIMARY KEY,
|
|
122
|
+
data JSONB NOT NULL,
|
|
123
|
+
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
-- GIN index for JSONB queries
|
|
127
|
+
CREATE INDEX idx_events_data ON events USING gin(data);
|
|
128
|
+
|
|
129
|
+
-- Array types for multi-value columns
|
|
130
|
+
CREATE TABLE tags (
|
|
131
|
+
post_id INT,
|
|
132
|
+
tag_names TEXT[]
|
|
133
|
+
);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### MySQL
|
|
137
|
+
```sql
|
|
138
|
+
-- Use appropriate storage engines
|
|
139
|
+
CREATE TABLE sessions (
|
|
140
|
+
id VARCHAR(128) PRIMARY KEY,
|
|
141
|
+
data TEXT,
|
|
142
|
+
expires TIMESTAMP
|
|
143
|
+
) ENGINE=InnoDB;
|
|
144
|
+
|
|
145
|
+
-- Optimize for InnoDB
|
|
146
|
+
ALTER TABLE large_table
|
|
147
|
+
ADD INDEX idx_covering (status, created_at, id);
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### SQL Server
|
|
151
|
+
```sql
|
|
152
|
+
-- Use appropriate data types
|
|
153
|
+
CREATE TABLE products (
|
|
154
|
+
id BIGINT IDENTITY(1,1) PRIMARY KEY,
|
|
155
|
+
name NVARCHAR(255) NOT NULL,
|
|
156
|
+
price DECIMAL(10,2) NOT NULL,
|
|
157
|
+
created_at DATETIME2 DEFAULT GETUTCDATE()
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
-- Columnstore indexes for analytics
|
|
161
|
+
CREATE COLUMNSTORE INDEX idx_sales_cs ON sales;
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Oracle
|
|
165
|
+
```sql
|
|
166
|
+
-- Use sequences for auto-increment
|
|
167
|
+
CREATE SEQUENCE user_id_seq START WITH 1 INCREMENT BY 1;
|
|
168
|
+
|
|
169
|
+
CREATE TABLE users (
|
|
170
|
+
id NUMBER DEFAULT user_id_seq.NEXTVAL PRIMARY KEY,
|
|
171
|
+
name VARCHAR2(255) NOT NULL
|
|
172
|
+
);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## 🧪 Testing & Validation
|
|
176
|
+
|
|
177
|
+
### Data Integrity Checks
|
|
178
|
+
```sql
|
|
179
|
+
-- Verify referential integrity
|
|
180
|
+
SELECT o.user_id
|
|
181
|
+
FROM orders o
|
|
182
|
+
LEFT JOIN users u ON o.user_id = u.id
|
|
183
|
+
WHERE u.id IS NULL;
|
|
184
|
+
|
|
185
|
+
-- Check for data consistency
|
|
186
|
+
SELECT COUNT(*) as inconsistent_records
|
|
187
|
+
FROM products
|
|
188
|
+
WHERE price < 0 OR stock_quantity < 0;
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Performance Testing
|
|
192
|
+
- **Execution Plans**: Review query execution plans
|
|
193
|
+
- **Load Testing**: Test queries with realistic data volumes
|
|
194
|
+
- **Stress Testing**: Verify performance under concurrent load
|
|
195
|
+
- **Regression Testing**: Ensure optimizations don't break functionality
|
|
196
|
+
|
|
197
|
+
## 📊 Common Anti-Patterns
|
|
198
|
+
|
|
199
|
+
### N+1 Query Problem
|
|
200
|
+
```sql
|
|
201
|
+
-- ❌ BAD: N+1 queries in application code
|
|
202
|
+
for user in users:
|
|
203
|
+
orders = query("SELECT * FROM orders WHERE user_id = ?", user.id)
|
|
204
|
+
|
|
205
|
+
-- ✅ GOOD: Single optimized query
|
|
206
|
+
SELECT u.*, o.*
|
|
207
|
+
FROM users u
|
|
208
|
+
LEFT JOIN orders o ON u.id = o.user_id;
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Overuse of DISTINCT
|
|
212
|
+
```sql
|
|
213
|
+
-- ❌ BAD: DISTINCT masking join issues
|
|
214
|
+
SELECT DISTINCT u.name
|
|
215
|
+
FROM users u, orders o
|
|
216
|
+
WHERE u.id = o.user_id;
|
|
217
|
+
|
|
218
|
+
-- ✅ GOOD: Proper join without DISTINCT
|
|
219
|
+
SELECT u.name
|
|
220
|
+
FROM users u
|
|
221
|
+
INNER JOIN orders o ON u.id = o.user_id
|
|
222
|
+
GROUP BY u.name;
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Function Misuse in WHERE Clauses
|
|
226
|
+
```sql
|
|
227
|
+
-- ❌ BAD: Functions prevent index usage
|
|
228
|
+
SELECT * FROM orders
|
|
229
|
+
WHERE YEAR(order_date) = 2024;
|
|
230
|
+
|
|
231
|
+
-- ✅ GOOD: Range conditions use indexes
|
|
232
|
+
SELECT * FROM orders
|
|
233
|
+
WHERE order_date >= '2024-01-01'
|
|
234
|
+
AND order_date < '2025-01-01';
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## 📋 SQL Review Checklist
|
|
238
|
+
|
|
239
|
+
### Security
|
|
240
|
+
- [ ] All user inputs are parameterized
|
|
241
|
+
- [ ] No dynamic SQL construction with string concatenation
|
|
242
|
+
- [ ] Appropriate access controls and permissions
|
|
243
|
+
- [ ] Sensitive data is properly protected
|
|
244
|
+
- [ ] SQL injection attack vectors are eliminated
|
|
245
|
+
|
|
246
|
+
### Performance
|
|
247
|
+
- [ ] Indexes exist for frequently queried columns
|
|
248
|
+
- [ ] No unnecessary SELECT * statements
|
|
249
|
+
- [ ] JOINs are optimized and use appropriate types
|
|
250
|
+
- [ ] WHERE clauses are selective and use indexes
|
|
251
|
+
- [ ] Subqueries are optimized or converted to JOINs
|
|
252
|
+
|
|
253
|
+
### Code Quality
|
|
254
|
+
- [ ] Consistent naming conventions
|
|
255
|
+
- [ ] Proper formatting and indentation
|
|
256
|
+
- [ ] Meaningful comments for complex logic
|
|
257
|
+
- [ ] Appropriate data types are used
|
|
258
|
+
- [ ] Error handling is implemented
|
|
259
|
+
|
|
260
|
+
### Schema Design
|
|
261
|
+
- [ ] Tables are properly normalized
|
|
262
|
+
- [ ] Constraints enforce data integrity
|
|
263
|
+
- [ ] Indexes support query patterns
|
|
264
|
+
- [ ] Foreign key relationships are defined
|
|
265
|
+
- [ ] Default values are appropriate
|
|
266
|
+
|
|
267
|
+
## 🎯 Review Output Format
|
|
268
|
+
|
|
269
|
+
### Issue Template
|
|
270
|
+
```
|
|
271
|
+
## [PRIORITY] [CATEGORY]: [Brief Description]
|
|
272
|
+
|
|
273
|
+
**Location**: [Table/View/Procedure name and line number if applicable]
|
|
274
|
+
**Issue**: [Detailed explanation of the problem]
|
|
275
|
+
**Security Risk**: [If applicable - injection risk, data exposure, etc.]
|
|
276
|
+
**Performance Impact**: [Query cost, execution time impact]
|
|
277
|
+
**Recommendation**: [Specific fix with code example]
|
|
278
|
+
|
|
279
|
+
**Before**:
|
|
280
|
+
```sql
|
|
281
|
+
-- Problematic SQL
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**After**:
|
|
285
|
+
```sql
|
|
286
|
+
-- Improved SQL
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**Expected Improvement**: [Performance gain, security benefit]
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Summary Assessment
|
|
293
|
+
- **Security Score**: [1-10] - SQL injection protection, access controls
|
|
294
|
+
- **Performance Score**: [1-10] - Query efficiency, index usage
|
|
295
|
+
- **Maintainability Score**: [1-10] - Code quality, documentation
|
|
296
|
+
- **Schema Quality Score**: [1-10] - Design patterns, normalization
|
|
297
|
+
|
|
298
|
+
### Top 3 Priority Actions
|
|
299
|
+
1. **[Critical Security Fix]**: Address SQL injection vulnerabilities
|
|
300
|
+
2. **[Performance Optimization]**: Add missing indexes or optimize queries
|
|
301
|
+
3. **[Code Quality]**: Improve naming conventions and documentation
|
|
302
|
+
|
|
303
|
+
Focus on providing actionable, database-agnostic recommendations while highlighting platform-specific optimizations and best practices.
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
---
|
|
2
|
+
mode: 'agent'
|
|
3
|
+
tools: ['changes', 'search/codebase', 'edit/editFiles', 'problems']
|
|
4
|
+
description: 'Universal SQL performance optimization assistant for comprehensive query tuning, indexing strategies, and database performance analysis across all SQL databases (MySQL, PostgreSQL, SQL Server, Oracle). Provides execution plan analysis, pagination optimization, batch operations, and performance monitoring guidance.'
|
|
5
|
+
tested_with: 'GitHub Copilot Chat (GPT-4o) - Validated July 20, 2025'
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# SQL Performance Optimization Assistant
|
|
9
|
+
|
|
10
|
+
Expert SQL performance optimization for ${selection} (or entire project if no selection). Focus on universal SQL optimization techniques that work across MySQL, PostgreSQL, SQL Server, Oracle, and other SQL databases.
|
|
11
|
+
|
|
12
|
+
## 🎯 Core Optimization Areas
|
|
13
|
+
|
|
14
|
+
### Query Performance Analysis
|
|
15
|
+
```sql
|
|
16
|
+
-- ❌ BAD: Inefficient query patterns
|
|
17
|
+
SELECT * FROM orders o
|
|
18
|
+
WHERE YEAR(o.created_at) = 2024
|
|
19
|
+
AND o.customer_id IN (
|
|
20
|
+
SELECT c.id FROM customers c WHERE c.status = 'active'
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
-- ✅ GOOD: Optimized query with proper indexing hints
|
|
24
|
+
SELECT o.id, o.customer_id, o.total_amount, o.created_at
|
|
25
|
+
FROM orders o
|
|
26
|
+
INNER JOIN customers c ON o.customer_id = c.id
|
|
27
|
+
WHERE o.created_at >= '2024-01-01'
|
|
28
|
+
AND o.created_at < '2025-01-01'
|
|
29
|
+
AND c.status = 'active';
|
|
30
|
+
|
|
31
|
+
-- Required indexes:
|
|
32
|
+
-- CREATE INDEX idx_orders_created_at ON orders(created_at);
|
|
33
|
+
-- CREATE INDEX idx_customers_status ON customers(status);
|
|
34
|
+
-- CREATE INDEX idx_orders_customer_id ON orders(customer_id);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Index Strategy Optimization
|
|
38
|
+
```sql
|
|
39
|
+
-- ❌ BAD: Poor indexing strategy
|
|
40
|
+
CREATE INDEX idx_user_data ON users(email, first_name, last_name, created_at);
|
|
41
|
+
|
|
42
|
+
-- ✅ GOOD: Optimized composite indexing
|
|
43
|
+
-- For queries filtering by email first, then sorting by created_at
|
|
44
|
+
CREATE INDEX idx_users_email_created ON users(email, created_at);
|
|
45
|
+
|
|
46
|
+
-- For full-text name searches
|
|
47
|
+
CREATE INDEX idx_users_name ON users(last_name, first_name);
|
|
48
|
+
|
|
49
|
+
-- For user status queries
|
|
50
|
+
CREATE INDEX idx_users_status_created ON users(status, created_at)
|
|
51
|
+
WHERE status IS NOT NULL;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Subquery Optimization
|
|
55
|
+
```sql
|
|
56
|
+
-- ❌ BAD: Correlated subquery
|
|
57
|
+
SELECT p.product_name, p.price
|
|
58
|
+
FROM products p
|
|
59
|
+
WHERE p.price > (
|
|
60
|
+
SELECT AVG(price)
|
|
61
|
+
FROM products p2
|
|
62
|
+
WHERE p2.category_id = p.category_id
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
-- ✅ GOOD: Window function approach
|
|
66
|
+
SELECT product_name, price
|
|
67
|
+
FROM (
|
|
68
|
+
SELECT product_name, price,
|
|
69
|
+
AVG(price) OVER (PARTITION BY category_id) as avg_category_price
|
|
70
|
+
FROM products
|
|
71
|
+
) ranked
|
|
72
|
+
WHERE price > avg_category_price;
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 📊 Performance Tuning Techniques
|
|
76
|
+
|
|
77
|
+
### JOIN Optimization
|
|
78
|
+
```sql
|
|
79
|
+
-- ❌ BAD: Inefficient JOIN order and conditions
|
|
80
|
+
SELECT o.*, c.name, p.product_name
|
|
81
|
+
FROM orders o
|
|
82
|
+
LEFT JOIN customers c ON o.customer_id = c.id
|
|
83
|
+
LEFT JOIN order_items oi ON o.id = oi.order_id
|
|
84
|
+
LEFT JOIN products p ON oi.product_id = p.id
|
|
85
|
+
WHERE o.created_at > '2024-01-01'
|
|
86
|
+
AND c.status = 'active';
|
|
87
|
+
|
|
88
|
+
-- ✅ GOOD: Optimized JOIN with filtering
|
|
89
|
+
SELECT o.id, o.total_amount, c.name, p.product_name
|
|
90
|
+
FROM orders o
|
|
91
|
+
INNER JOIN customers c ON o.customer_id = c.id AND c.status = 'active'
|
|
92
|
+
INNER JOIN order_items oi ON o.id = oi.order_id
|
|
93
|
+
INNER JOIN products p ON oi.product_id = p.id
|
|
94
|
+
WHERE o.created_at > '2024-01-01';
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Pagination Optimization
|
|
98
|
+
```sql
|
|
99
|
+
-- ❌ BAD: OFFSET-based pagination (slow for large offsets)
|
|
100
|
+
SELECT * FROM products
|
|
101
|
+
ORDER BY created_at DESC
|
|
102
|
+
LIMIT 20 OFFSET 10000;
|
|
103
|
+
|
|
104
|
+
-- ✅ GOOD: Cursor-based pagination
|
|
105
|
+
SELECT * FROM products
|
|
106
|
+
WHERE created_at < '2024-06-15 10:30:00'
|
|
107
|
+
ORDER BY created_at DESC
|
|
108
|
+
LIMIT 20;
|
|
109
|
+
|
|
110
|
+
-- Or using ID-based cursor
|
|
111
|
+
SELECT * FROM products
|
|
112
|
+
WHERE id > 1000
|
|
113
|
+
ORDER BY id
|
|
114
|
+
LIMIT 20;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Aggregation Optimization
|
|
118
|
+
```sql
|
|
119
|
+
-- ❌ BAD: Multiple separate aggregation queries
|
|
120
|
+
SELECT COUNT(*) FROM orders WHERE status = 'pending';
|
|
121
|
+
SELECT COUNT(*) FROM orders WHERE status = 'shipped';
|
|
122
|
+
SELECT COUNT(*) FROM orders WHERE status = 'delivered';
|
|
123
|
+
|
|
124
|
+
-- ✅ GOOD: Single query with conditional aggregation
|
|
125
|
+
SELECT
|
|
126
|
+
COUNT(CASE WHEN status = 'pending' THEN 1 END) as pending_count,
|
|
127
|
+
COUNT(CASE WHEN status = 'shipped' THEN 1 END) as shipped_count,
|
|
128
|
+
COUNT(CASE WHEN status = 'delivered' THEN 1 END) as delivered_count
|
|
129
|
+
FROM orders;
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 🔍 Query Anti-Patterns
|
|
133
|
+
|
|
134
|
+
### SELECT Performance Issues
|
|
135
|
+
```sql
|
|
136
|
+
-- ❌ BAD: SELECT * anti-pattern
|
|
137
|
+
SELECT * FROM large_table lt
|
|
138
|
+
JOIN another_table at ON lt.id = at.ref_id;
|
|
139
|
+
|
|
140
|
+
-- ✅ GOOD: Explicit column selection
|
|
141
|
+
SELECT lt.id, lt.name, at.value
|
|
142
|
+
FROM large_table lt
|
|
143
|
+
JOIN another_table at ON lt.id = at.ref_id;
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### WHERE Clause Optimization
|
|
147
|
+
```sql
|
|
148
|
+
-- ❌ BAD: Function calls in WHERE clause
|
|
149
|
+
SELECT * FROM orders
|
|
150
|
+
WHERE UPPER(customer_email) = 'JOHN@EXAMPLE.COM';
|
|
151
|
+
|
|
152
|
+
-- ✅ GOOD: Index-friendly WHERE clause
|
|
153
|
+
SELECT * FROM orders
|
|
154
|
+
WHERE customer_email = 'john@example.com';
|
|
155
|
+
-- Consider: CREATE INDEX idx_orders_email ON orders(LOWER(customer_email));
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### OR vs UNION Optimization
|
|
159
|
+
```sql
|
|
160
|
+
-- ❌ BAD: Complex OR conditions
|
|
161
|
+
SELECT * FROM products
|
|
162
|
+
WHERE (category = 'electronics' AND price < 1000)
|
|
163
|
+
OR (category = 'books' AND price < 50);
|
|
164
|
+
|
|
165
|
+
-- ✅ GOOD: UNION approach for better optimization
|
|
166
|
+
SELECT * FROM products WHERE category = 'electronics' AND price < 1000
|
|
167
|
+
UNION ALL
|
|
168
|
+
SELECT * FROM products WHERE category = 'books' AND price < 50;
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## 📈 Database-Agnostic Optimization
|
|
172
|
+
|
|
173
|
+
### Batch Operations
|
|
174
|
+
```sql
|
|
175
|
+
-- ❌ BAD: Row-by-row operations
|
|
176
|
+
INSERT INTO products (name, price) VALUES ('Product 1', 10.00);
|
|
177
|
+
INSERT INTO products (name, price) VALUES ('Product 2', 15.00);
|
|
178
|
+
INSERT INTO products (name, price) VALUES ('Product 3', 20.00);
|
|
179
|
+
|
|
180
|
+
-- ✅ GOOD: Batch insert
|
|
181
|
+
INSERT INTO products (name, price) VALUES
|
|
182
|
+
('Product 1', 10.00),
|
|
183
|
+
('Product 2', 15.00),
|
|
184
|
+
('Product 3', 20.00);
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Temporary Table Usage
|
|
188
|
+
```sql
|
|
189
|
+
-- ✅ GOOD: Using temporary tables for complex operations
|
|
190
|
+
CREATE TEMPORARY TABLE temp_calculations AS
|
|
191
|
+
SELECT customer_id,
|
|
192
|
+
SUM(total_amount) as total_spent,
|
|
193
|
+
COUNT(*) as order_count
|
|
194
|
+
FROM orders
|
|
195
|
+
WHERE created_at >= '2024-01-01'
|
|
196
|
+
GROUP BY customer_id;
|
|
197
|
+
|
|
198
|
+
-- Use the temp table for further calculations
|
|
199
|
+
SELECT c.name, tc.total_spent, tc.order_count
|
|
200
|
+
FROM temp_calculations tc
|
|
201
|
+
JOIN customers c ON tc.customer_id = c.id
|
|
202
|
+
WHERE tc.total_spent > 1000;
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## 🛠️ Index Management
|
|
206
|
+
|
|
207
|
+
### Index Design Principles
|
|
208
|
+
```sql
|
|
209
|
+
-- ✅ GOOD: Covering index design
|
|
210
|
+
CREATE INDEX idx_orders_covering
|
|
211
|
+
ON orders(customer_id, created_at)
|
|
212
|
+
INCLUDE (total_amount, status); -- SQL Server syntax
|
|
213
|
+
-- Or: CREATE INDEX idx_orders_covering ON orders(customer_id, created_at, total_amount, status); -- Other databases
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Partial Index Strategy
|
|
217
|
+
```sql
|
|
218
|
+
-- ✅ GOOD: Partial indexes for specific conditions
|
|
219
|
+
CREATE INDEX idx_orders_active
|
|
220
|
+
ON orders(created_at)
|
|
221
|
+
WHERE status IN ('pending', 'processing');
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## 📊 Performance Monitoring Queries
|
|
225
|
+
|
|
226
|
+
### Query Performance Analysis
|
|
227
|
+
```sql
|
|
228
|
+
-- Generic approach to identify slow queries
|
|
229
|
+
-- (Specific syntax varies by database)
|
|
230
|
+
|
|
231
|
+
-- For MySQL:
|
|
232
|
+
SELECT query_time, lock_time, rows_sent, rows_examined, sql_text
|
|
233
|
+
FROM mysql.slow_log
|
|
234
|
+
ORDER BY query_time DESC;
|
|
235
|
+
|
|
236
|
+
-- For PostgreSQL:
|
|
237
|
+
SELECT query, calls, total_time, mean_time
|
|
238
|
+
FROM pg_stat_statements
|
|
239
|
+
ORDER BY total_time DESC;
|
|
240
|
+
|
|
241
|
+
-- For SQL Server:
|
|
242
|
+
SELECT
|
|
243
|
+
qs.total_elapsed_time/qs.execution_count as avg_elapsed_time,
|
|
244
|
+
qs.execution_count,
|
|
245
|
+
SUBSTRING(qt.text, (qs.statement_start_offset/2)+1,
|
|
246
|
+
((CASE qs.statement_end_offset WHEN -1 THEN DATALENGTH(qt.text)
|
|
247
|
+
ELSE qs.statement_end_offset END - qs.statement_start_offset)/2)+1) as query_text
|
|
248
|
+
FROM sys.dm_exec_query_stats qs
|
|
249
|
+
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) qt
|
|
250
|
+
ORDER BY avg_elapsed_time DESC;
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## 🎯 Universal Optimization Checklist
|
|
254
|
+
|
|
255
|
+
### Query Structure
|
|
256
|
+
- [ ] Avoiding SELECT * in production queries
|
|
257
|
+
- [ ] Using appropriate JOIN types (INNER vs LEFT/RIGHT)
|
|
258
|
+
- [ ] Filtering early in WHERE clauses
|
|
259
|
+
- [ ] Using EXISTS instead of IN for subqueries when appropriate
|
|
260
|
+
- [ ] Avoiding functions in WHERE clauses that prevent index usage
|
|
261
|
+
|
|
262
|
+
### Index Strategy
|
|
263
|
+
- [ ] Creating indexes on frequently queried columns
|
|
264
|
+
- [ ] Using composite indexes in the right column order
|
|
265
|
+
- [ ] Avoiding over-indexing (impacts INSERT/UPDATE performance)
|
|
266
|
+
- [ ] Using covering indexes where beneficial
|
|
267
|
+
- [ ] Creating partial indexes for specific query patterns
|
|
268
|
+
|
|
269
|
+
### Data Types and Schema
|
|
270
|
+
- [ ] Using appropriate data types for storage efficiency
|
|
271
|
+
- [ ] Normalizing appropriately (3NF for OLTP, denormalized for OLAP)
|
|
272
|
+
- [ ] Using constraints to help query optimizer
|
|
273
|
+
- [ ] Partitioning large tables when appropriate
|
|
274
|
+
|
|
275
|
+
### Query Patterns
|
|
276
|
+
- [ ] Using LIMIT/TOP for result set control
|
|
277
|
+
- [ ] Implementing efficient pagination strategies
|
|
278
|
+
- [ ] Using batch operations for bulk data changes
|
|
279
|
+
- [ ] Avoiding N+1 query problems
|
|
280
|
+
- [ ] Using prepared statements for repeated queries
|
|
281
|
+
|
|
282
|
+
### Performance Testing
|
|
283
|
+
- [ ] Testing queries with realistic data volumes
|
|
284
|
+
- [ ] Analyzing query execution plans
|
|
285
|
+
- [ ] Monitoring query performance over time
|
|
286
|
+
- [ ] Setting up alerts for slow queries
|
|
287
|
+
- [ ] Regular index usage analysis
|
|
288
|
+
|
|
289
|
+
## 📝 Optimization Methodology
|
|
290
|
+
|
|
291
|
+
1. **Identify**: Use database-specific tools to find slow queries
|
|
292
|
+
2. **Analyze**: Examine execution plans and identify bottlenecks
|
|
293
|
+
3. **Optimize**: Apply appropriate optimization techniques
|
|
294
|
+
4. **Test**: Verify performance improvements
|
|
295
|
+
5. **Monitor**: Continuously track performance metrics
|
|
296
|
+
6. **Iterate**: Regular performance review and optimization
|
|
297
|
+
|
|
298
|
+
Focus on measurable performance improvements and always test optimizations with realistic data volumes and query patterns.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
agent: "agent"
|
|
3
|
+
description: "Suggest relevant GitHub Copilot Custom Agents files from the awesome-copilot repository based on current repository context and chat history, avoiding duplicates with existing custom agents in this repository."
|
|
4
|
+
tools: ["edit", "search", "runCommands", "runTasks", "changes", "testFailure", "openSimpleBrowser", "fetch", "githubRepo", "todos"]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Suggest Awesome GitHub Copilot Custom Agents
|
|
8
|
+
|
|
9
|
+
Analyze current repository context and suggest relevant Custom Agents files from the [GitHub awesome-copilot repository](https://github.com/github/awesome-copilot/blob/main/docs/README.agents.md) that are not already available in this repository. Custom Agent files are located in the [agents](https://github.com/github/awesome-copilot/tree/main/agents) folder of the awesome-copilot repository.
|
|
10
|
+
|
|
11
|
+
## Process
|
|
12
|
+
|
|
13
|
+
1. **Fetch Available Custom Agents**: Extract Custom Agents list and descriptions from [awesome-copilot README.agents.md](https://github.com/github/awesome-copilot/blob/main/docs/README.agents.md). Must use `fetch` tool.
|
|
14
|
+
2. **Scan Local Custom Agents**: Discover existing custom agent files in `.github/agents/` folder
|
|
15
|
+
3. **Extract Descriptions**: Read front matter from local custom agent files to get descriptions
|
|
16
|
+
4. **Analyze Context**: Review chat history, repository files, and current project needs
|
|
17
|
+
5. **Compare Existing**: Check against custom agents already available in this repository
|
|
18
|
+
6. **Match Relevance**: Compare available custom agents against identified patterns and requirements
|
|
19
|
+
7. **Present Options**: Display relevant custom agents with descriptions, rationale, and availability status
|
|
20
|
+
8. **Validate**: Ensure suggested agents would add value not already covered by existing agents
|
|
21
|
+
9. **Output**: Provide structured table with suggestions, descriptions, and links to both awesome-copilot custom agents and similar local custom agents
|
|
22
|
+
**AWAIT** user request to proceed with installation of specific custom agents. DO NOT INSTALL UNLESS DIRECTED TO DO SO.
|
|
23
|
+
10. **Download Assets**: For requested agents, automatically download and install individual agents to `.github/agents/` folder. Do NOT adjust content of the files. Use `#todos` tool to track progress. Prioritize use of `#fetch` tool to download assets, but may use `curl` using `#runInTerminal` tool to ensure all content is retrieved.
|
|
24
|
+
|
|
25
|
+
## Context Analysis Criteria
|
|
26
|
+
|
|
27
|
+
🔍 **Repository Patterns**:
|
|
28
|
+
|
|
29
|
+
- Programming languages used (.cs, .js, .py, etc.)
|
|
30
|
+
- Framework indicators (ASP.NET, React, Azure, etc.)
|
|
31
|
+
- Project types (web apps, APIs, libraries, tools)
|
|
32
|
+
- Documentation needs (README, specs, ADRs)
|
|
33
|
+
|
|
34
|
+
🗨️ **Chat History Context**:
|
|
35
|
+
|
|
36
|
+
- Recent discussions and pain points
|
|
37
|
+
- Feature requests or implementation needs
|
|
38
|
+
- Code review patterns
|
|
39
|
+
- Development workflow requirements
|
|
40
|
+
|
|
41
|
+
## Output Format
|
|
42
|
+
|
|
43
|
+
Display analysis results in structured table comparing awesome-copilot custom agents with existing repository custom agents:
|
|
44
|
+
|
|
45
|
+
| Awesome-Copilot Custom Agent | Description | Already Installed | Similar Local Custom Agent | Suggestion Rationale |
|
|
46
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ---------------------------------- | ------------------------------------------------------------- |
|
|
47
|
+
| [amplitude-experiment-implementation.agent.md](https://github.com/github/awesome-copilot/blob/main/agents/amplitude-experiment-implementation.agent.md) | This custom agent uses Amplitude's MCP tools to deploy new experiments inside of Amplitude, enabling seamless variant testing capabilities and rollout of product features | ❌ No | None | Would enhance experimentation capabilities within the product |
|
|
48
|
+
| [launchdarkly-flag-cleanup.agent.md](https://github.com/github/awesome-copilot/blob/main/agents/launchdarkly-flag-cleanup.agent.md) | Feature flag cleanup agent for LaunchDarkly | ✅ Yes | launchdarkly-flag-cleanup.agent.md | Already covered by existing LaunchDarkly custom agents |
|
|
49
|
+
|
|
50
|
+
## Local Agent Discovery Process
|
|
51
|
+
|
|
52
|
+
1. List all `*.agent.md` files in `.github/agents/` directory
|
|
53
|
+
2. For each discovered file, read front matter to extract `description`
|
|
54
|
+
3. Build comprehensive inventory of existing agents
|
|
55
|
+
4. Use this inventory to avoid suggesting duplicates
|
|
56
|
+
|
|
57
|
+
## Requirements
|
|
58
|
+
|
|
59
|
+
- Use `githubRepo` tool to get content from awesome-copilot repository agents folder
|
|
60
|
+
- Scan local file system for existing agents in `.github/agents/` directory
|
|
61
|
+
- Read YAML front matter from local agent files to extract descriptions
|
|
62
|
+
- Compare against existing agents in this repository to avoid duplicates
|
|
63
|
+
- Focus on gaps in current agent library coverage
|
|
64
|
+
- Validate that suggested agents align with repository's purpose and standards
|
|
65
|
+
- Provide clear rationale for each suggestion
|
|
66
|
+
- Include links to both awesome-copilot agents and similar local agents
|
|
67
|
+
- Don't provide any additional information or context beyond the table and the analysis
|
|
68
|
+
|
|
69
|
+
## Icons Reference
|
|
70
|
+
|
|
71
|
+
- ✅ Already installed in repo
|
|
72
|
+
- ❌ Not installed in repo
|