abap-cds-model-check
Optional intended usage such as analytical, transactional, reuse, value-help, or extraction
Analyzes SQLScript code for performance issues and suggests optimizations with auto-fix capability
$ npx -y skills add secondsky/sap-skills --agent claude-codeHow it fires
How this command gets triggered: by you, by Claude, or both.
/sqlscript-optimizeContext preview
What this command does when you run it.
Analyzes SQLScript code for performance issues and suggests optimizations with auto-fix capability
name: sqlscript-optimize description: Analyzes SQLScript code for performance issues and suggests optimizations with auto-fix capability allowed-tools: - Read - Grep argument-hint: "<file_path> [--fix|--explain]"
Return performance findings, evidence, suggested rewrites, risk level, and validation steps. Default to analysis-only; apply edits only with an explicit fix request and exact file confirmation.
Analyze SQLScript procedures and functions for performance anti-patterns and suggest optimizations. Offers auto-fix for common performance issues.
/sqlscript-optimize [file_path] /sqlscript-optimize [file_path] --fix /sqlscript-optimize [file_path] --explain
1. **Read the specified file** 2. **Analyze execution patterns**:
3. **Calculate impact scores** (High/Medium/Low) 4. **Generate recommendations** with:
5. **Offer auto-fixes** where applicable
| Issue | Auto-Fix Available | Notes | |-------|-------------------|-------| | Cursor loop to set-based | Partial | Simple patterns only | | UNION to UNION ALL | Yes | When safe to change | | SELECT * to column list | No | Requires column selection | | Subquery to JOIN | Partial | Standard patterns | | Add LIMIT clause | Yes | Adds configurable limit | | Filter pushdown | Yes | Moves WHERE earlier |
## SQLScript Performance Analysis **File**: [filename] **Procedure/Function**: [name] **Estimated Impact**: [High/Medium/Low] ### Critical Performance Issues #### Issue 1: [Name] (Impact: High) **Location**: Lines X-Y **Current Pattern**: ```sql [current code]
**Optimized Pattern**:
[optimized code]
**Expected Improvement**: [description] **Auto-fix**: [Yes/No]
[Similar format]
| Metric | Before | After (Est.) | |--------|--------|--------------| | Execution Model | Imperative | Declarative | | Parallel Potential | Low | High | | Data Movement | High | Low |
1. [Most impactful fix] 2. [Second priority] ...
Would you like me to apply the X auto-fixable optimizations?
## Examples ### Analyze Performance
/sqlscript-optimize src/procedures/process_orders.sql
### Analyze with Detailed Explanations
/sqlscript-optimize src/procedures/process_orders.sql --explain
### Analyze and Apply Fixes
/sqlscript-optimize src/procedures/process_orders.sql --fix
## Common Optimizations ### Cursor Loop to Set-Based ```sql -- BEFORE (Slow: Row-by-row) FOR row AS cur DO UPDATE orders SET status = 'PROCESSED' WHERE id = row.id; END FOR; -- AFTER (Fast: Set-based) UPDATE orders SET status = 'PROCESSED' WHERE id IN (SELECT id FROM :lt_ids);
-- BEFORE (Slow: Subquery per row) SELECT id, (SELECT name FROM customers WHERE id = o.customer_id) as customer_name FROM orders o; -- AFTER (Fast: Single JOIN) SELECT o.id, c.name as customer_name FROM orders o LEFT JOIN customers c ON o.customer_id = c.id;
-- BEFORE (Slow: Removes duplicates) SELECT id FROM table1 UNION SELECT id FROM table2; -- AFTER (Fast: No deduplication when not needed) SELECT id FROM table1 UNION ALL SELECT id FROM table2;
-- BEFORE (Slow: Filter after join)
lt_result = SELECT * FROM t1 JOIN t2 ON t1.id = t2.id;
lt_filtered = SELECT * FROM :lt_result WHERE status = 'A';
-- AFTER (Fast: Filter in source)
lt_result = SELECT * FROM t1
JOIN t2 ON t1.id = t2.id
WHERE t1.status = 'A';When this command is invoked:
1. Read the specified SQLScript file 2. Parse to identify:
3. For each pattern, check against optimization rules 4. Calculate potential impact based on:
5. Generate optimized alternatives 6. Present findings with before/after comparisons 7. If `--fix` specified, apply safe transformations 8. Re-analyze to confirm improvements
40 SAP development plugins with evidence-tracked verification SAP development plugins for AI coding assistants, with public-source or package-registry verification tracked where available.
Repo: secondsky/sap-skills
Optional intended usage such as analytical, transactional, reuse, value-help, or extraction
Optional target ABAP platform or SAP BTP ABAP Environment release
Optional runtime or scenario name, such as orchestration, serving, training, or batch
Optional scenario lens such as extension, integration, analytics, or AI