STOP - Read before ANY tool call
- Read
{{GUARDRAILS_PATH}}
- Read
{{TOOLKIT_ROOT}}/skills/_shared/sdd-artifacts/SESSION.md; load session-state for $Cwd
- If the relevant gate is not approved: STOP - ask user (pt-BR) - do NOT Write/Shell
- SDD/develop skills: after ONE step/task, STOP session - handoff only
- This skill body is English; user-facing prompts may be (pt-BR)
Step -1 - Gate check (report in chat before continuing)
Gate check:
[ ] guardrails.mdc read
[ ] SESSION.md read; session-state loaded
[ ] PIPELINE.md read (SDD skills only)
[ ] User confirmed current action (sim)
-> If any unchecked: STOP
Skill: performance-profile
Trigger
Invoke when the user requests: /performance-profile, optimize performance, /performance-profile, or asks to fix query bottlenecks.
Arguments (optional):
| Input |
Meaning |
| Target method / query |
Target function, method, or LINQ/SQL query block to optimize |
Outcome
Documented performance improvements verified by local benchmarking:
- Identified bottlenecks (SQL/LINQ analysis, loop allocations).
- Optimization proposal (e.g., eager loading, projection, indexes, caching, memory span allocations).
- Micro-benchmark results comparing execution speed and memory allocations (before vs. after).
Lazy-load
| When |
Path (after scripts/sync-cursor.ps1) |
| C# projects |
{{TOOLKIT_ROOT}}/skills/_shared/dotnet-guidelines/csharp-patterns.md, {{TOOLKIT_ROOT}}/skills/_shared/dotnet-guidelines/string-manipulation.md |
| JavaScript / TypeScript |
{{TOOLKIT_ROOT}}/skills/_shared/javascript-guidelines/clean-code-js.md |
| Python projects |
{{TOOLKIT_ROOT}}/skills/_shared/python-guidelines/principles.md |
| Caveman Mode (if active) |
{{TOOLKIT_ROOT}}/skills/_shared/caveman/CAVEMAN.md - Full cap |
Process
Step -1b - Caveman Mode (Full cap)
- Read
{{SDD_ROOT}}/preferences.json (create { "caveman_mode": false, "caveman_level": "full" } if missing).
- If
caveman_mode is false: continue without compression.
- If true: load
{{TOOLKIT_ROOT}}/skills/_shared/caveman/CAVEMAN.md; apply Full participation cap + prefs caveman_level (Lite skills never escalate); show once: [Caveman] Modo ativo (respostas compactas, level={effective}). Digite caveman off para desativar.
- Honor
caveman on|off|status|lite|full|ultra (and stop caveman / normal mode) during the session.
- Auto-Clarity + never-compress gates/drafts/paths per
CAVEMAN.md.
-1. Re-check guardrails and session
Confirm guardrails.mdc and SESSION.md are loaded.
If missing, ask user (pt-BR):
Antes do profiling, confirme:
- guardrails.mdc lido
- SESSION.md carregado
Posso seguir? (sim / ajustar / cancelar)
0. Target Identification
- Locate the target method, database routine, or loop structure.
- Confirm what metrics are critical: Execution Time (ms) or Memory Allocation (MB/GC cycles).
1. Static Performance Audit & Workflow Decision
- Analyze the target code for common anti-patterns:
- Database: N+1 queries (no eager loading), lack of projection (
select new), missing query limits (Take/limit), unindexed search fields.
- Memory: Excessive allocations inside loops, duplicate string concatenations, boxing/unboxing.
- Present the diagnostic report summarizing the bottlenecks.
- Stop and ask the user to choose the workflow execution path for applying and benchmarking these optimizations:
- Option A - Direct Developer Skill (
/developer): For straightforward local optimization and benchmark setup.
- Option B - Classic SDD (
/sdd-spec -> sdd-plan -> sdd-develop): For complex structural refactorings or query tuning requiring formal specifications (PRD) and a detailed plan (PLAN) in Portuguese.
- Option D - Plain Chat Plan: Establish a simple task list directly in the chat, executing steps one by one without extra file creations.
- Wait for explicit user choice before writing code or initializing another workflow.
2. Configure Benchmark
- Propose the setup for a benchmark suite:
- C#: Create a BenchmarkDotNet class under the test project.
- Python: Write a test script utilizing
timeit or cProfile.
- TS/JS: Write a benchmark script utilizing Node's
perf_hooks or benchmark.js.
- Wait for confirmation, then write the benchmark script/class.
3. Collect Baseline (Before)
- Instruct the user/agent to run the benchmark script and capture the execution outputs:
- Capture Mean Time, Standard Deviation, and Allocated Bytes.
- Document the baseline metrics.
4. Implement & Verify Optimization
- Write the optimized implementation in a separate branch or method variant (e.g.
CalculateOptimized).
- Run the benchmark again to compare:
- Verify that optimization achieves measurable improvements (e.g. 20% speedup or lower GC allocation) without regression.
- Present a comparison table:
| Variant |
Mean Time |
Allocated Bytes |
| Baseline |
... |
... |
| Optimized |
... |
... |
5. Apply Final Changes
- Replace the old code with the validated optimized version.
- Run compiler checks and regular test suites to ensure behavior remains identical.
6. Handoff
- Offer committing the optimizations:
/commit
Must not
- Perform optimizations without a benchmark validation.
- Introduce breaking changes or bypass domain validation rules to improve speed.
1---2name: performance-profile-93description: Find performance bottlenecks, set up micro-benchmarks, and optimize hot paths. Use when optimizing performance or invoking /performance-profile.4---567## STOP - Read before ANY tool call891. Read `{{GUARDRAILS_PATH}}`102. Read `{{TOOLKIT_ROOT}}/skills/_shared/sdd-artifacts/SESSION.md`; load session-state for `$Cwd`113. If the relevant gate is not approved: **STOP** - ask user **(pt-BR)** - do **NOT** Write/Shell124. SDD/develop skills: after **ONE** step/task, **STOP** session - handoff only135. This skill body is **English**; user-facing prompts may be **(pt-BR)**1415### Step -1 - Gate check (report in chat before continuing)1617```18Gate check:19[ ] guardrails.mdc read20[ ] SESSION.md read; session-state loaded21[ ] PIPELINE.md read (SDD skills only)22[ ] User confirmed current action (sim)23-> If any unchecked: STOP24```2526---2728# Skill: performance-profile2930## Trigger3132Invoke when the user requests: `/performance-profile`, `optimize performance`, `/performance-profile`, or asks to fix query bottlenecks.3334**Arguments (optional):**3536| Input | Meaning |37|-------|---------|38| Target method / query | Target function, method, or LINQ/SQL query block to optimize |3940## Outcome4142Documented performance improvements verified by local benchmarking:43441. Identified bottlenecks (SQL/LINQ analysis, loop allocations).452. Optimization proposal (e.g., eager loading, projection, indexes, caching, memory span allocations).463. Micro-benchmark results comparing execution speed and memory allocations (before vs. after).4748## Lazy-load4950| When | Path (after `scripts/sync-cursor.ps1`) |51|------|----------------------------------------|52| C# projects | `{{TOOLKIT_ROOT}}/skills/_shared/dotnet-guidelines/csharp-patterns.md`, `{{TOOLKIT_ROOT}}/skills/_shared/dotnet-guidelines/string-manipulation.md` |53| JavaScript / TypeScript | `{{TOOLKIT_ROOT}}/skills/_shared/javascript-guidelines/clean-code-js.md` |54| Python projects | `{{TOOLKIT_ROOT}}/skills/_shared/python-guidelines/principles.md` |55| Caveman Mode (if active) | `{{TOOLKIT_ROOT}}/skills/_shared/caveman/CAVEMAN.md` - **Full cap** |5657## Process5859### Step -1b - Caveman Mode (Full cap)601. Read `{{SDD_ROOT}}/preferences.json` (create `{ "caveman_mode": false, "caveman_level": "full" }` if missing).612. If `caveman_mode` is false: continue without compression.623. If true: load `{{TOOLKIT_ROOT}}/skills/_shared/caveman/CAVEMAN.md`; apply **Full** participation cap + prefs `caveman_level` (Lite skills never escalate); show once: `[Caveman] Modo ativo (respostas compactas, level={effective}). Digite caveman off para desativar.`634. Honor `caveman on|off|status|lite|full|ultra` (and `stop caveman` / `normal mode`) during the session.645. Auto-Clarity + never-compress gates/drafts/paths per `CAVEMAN.md`.6566### -1. Re-check guardrails and session6768Confirm `guardrails.mdc` and `SESSION.md` are loaded.69If missing, ask user (pt-BR):7071```text72Antes do profiling, confirme:73- guardrails.mdc lido74- SESSION.md carregado7576Posso seguir? (sim / ajustar / cancelar)77```787980### 0. Target Identification8182* Locate the target method, database routine, or loop structure.83* Confirm what metrics are critical: Execution Time (ms) or Memory Allocation (MB/GC cycles).8485### 1. Static Performance Audit & Workflow Decision8687* Analyze the target code for common anti-patterns:88 * Database: N+1 queries (no eager loading), lack of projection (`select new`), missing query limits (`Take`/`limit`), unindexed search fields.89 * Memory: Excessive allocations inside loops, duplicate string concatenations, boxing/unboxing.90* Present the diagnostic report summarizing the bottlenecks.91* Stop and ask the user to choose the workflow execution path for applying and benchmarking these optimizations:92 * **Option A - Direct Developer Skill (`/developer`):** For straightforward local optimization and benchmark setup.93 * **Option B - Classic SDD (`/sdd-spec` -> `sdd-plan` -> `sdd-develop`):** For complex structural refactorings or query tuning requiring formal specifications (PRD) and a detailed plan (PLAN) in Portuguese.94 * **Option D - Plain Chat Plan:** Establish a simple task list directly in the chat, executing steps one by one without extra file creations.95* **Wait for explicit user choice** before writing code or initializing another workflow.9697### 2. Configure Benchmark9899* Propose the setup for a benchmark suite:100 * C#: Create a BenchmarkDotNet class under the test project.101 * Python: Write a test script utilizing `timeit` or `cProfile`.102 * TS/JS: Write a benchmark script utilizing Node's `perf_hooks` or `benchmark.js`.103* Wait for confirmation, then write the benchmark script/class.104105### 3. Collect Baseline (Before)106107* Instruct the user/agent to run the benchmark script and capture the execution outputs:108 * Capture Mean Time, Standard Deviation, and Allocated Bytes.109* Document the baseline metrics.110111### 4. Implement & Verify Optimization112113* Write the optimized implementation in a separate branch or method variant (e.g. `CalculateOptimized`).114* Run the benchmark again to compare:115 * Verify that optimization achieves measurable improvements (e.g. 20% speedup or lower GC allocation) without regression.116* Present a comparison table:117118| Variant | Mean Time | Allocated Bytes |119|---------|-----------|-----------------|120| Baseline | ... | ... |121| Optimized | ... | ... |122123### 5. Apply Final Changes124125* Replace the old code with the validated optimized version.126* Run compiler checks and regular test suites to ensure behavior remains identical.127128### 6. Handoff129130* Offer committing the optimizations:131132```133/commit134```135136## Must not137138* Perform optimizations without a benchmark validation.139* Introduce breaking changes or bypass domain validation rules to improve speed.