Skip to content

feat(performance): Add Performance Optimization Workflow#90

Open
mrrajan wants to merge 23 commits into
RHEcosystemAppEng:mainfrom
mrrajan:TC-4129-performance-optimization
Open

feat(performance): Add Performance Optimization Workflow#90
mrrajan wants to merge 23 commits into
RHEcosystemAppEng:mainfrom
mrrajan:TC-4129-performance-optimization

Conversation

@mrrajan

@mrrajan mrrajan commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds a comprehensive Performance Optimization Workflow to the sdlc-workflow plugin, enabling teams to systematically analyze, optimize, and verify application performance as part of their SDLC.

What's Included

7 New Skills

  1. performance-setup - Initialize performance analysis configuration
  2. performance-baseline - Capture performance baselines with Playwright automation
  3. performance-analyze-module - Deep performance analysis with backend anti-pattern detection
  4. performance-plan-optimization - Generate optimization plans with Jira Epic/Tasks
  5. performance-implement-optimization - Execute optimizations with performance test generation
  6. performance-verify-optimization - Verify optimizations against acceptance criteria

Backend Source Code Analysis

  • Three-layer optimization model: Frontend/Backend/Integration
  • Anti-pattern detection: N+1 queries, missing pagination, inefficient queries
  • Framework support: actix-web, axum, Spring Boot, Express, FastAPI, Django, Rails, ASP.NET
  • Cross-repository over-fetching analysis: Backend schema vs frontend field usage
  • Serena MCP integration with Grep fallback

Workflow-First Architecture

  • BREAKING CHANGE: performance-workflow-discovery merged into performance-setup
  • User selects ONE workflow during setup (eliminates separate discovery step)
  • Scenarios auto-populated from workflow's key screens
  • Simpler flow: setup → baseline → analyze → optimize

Auto-Discovery & UX Enhancements

  • Dev command auto-discovery (frontend/backend/full-stack conditional discovery)
  • Config path auto-detection (walks up 5 parent dirs)
  • Serena MCP detection and onboarding prompts
  • Explicit Approve/Modify/Exit menus

Documentation

  • 3 new guides: performance-workflow-guide.md, performance-skills-reference.md, performance-metrics-guide.md
  • Updates to 6 existing docs: README, workflow, tools, project-config, jira-access-strategy, conventions template

Context Changes from Original Plan

Original PRs (#73, #74, #75) were closed due to iterative development leading to:

  1. Workflow-first architecture - Merged route discovery into setup skill
  2. Backend analysis layer - Added comprehensive backend anti-pattern detection
  3. Auto-discovery - Automated dev command and config path discovery
  4. Serena integration - MCP detection and onboarding

This PR consolidates 9 iterative commits into 2 logical commits for cleaner history.

Related Issue

Closes TC-4129

🤖 Generated with Claude Code

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @mrrajan, your pull request is larger than the review limit of 150000 diff characters

@mrrajan mrrajan force-pushed the TC-4129-performance-optimization branch from c421da9 to 6df59ac Compare April 28, 2026 08:30
@mrrajan mrrajan marked this pull request as ready for review April 28, 2026 08:32

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @mrrajan, your pull request is larger than the review limit of 150000 diff characters

@mrrajan mrrajan force-pushed the TC-4129-performance-optimization branch from e1db78b to 367fe8c Compare May 6, 2026 16:20
@mrrajan mrrajan force-pushed the TC-4129-performance-optimization branch 4 times, most recently from a22d44a to b40bc64 Compare June 12, 2026 14:23
mrrajan and others added 20 commits June 30, 2026 21:22
…late

- Create performance-setup skill with route/module discovery
- Create generic performance-config.template.md with placeholders
- Skill discovers routes from router configuration files
- Skill discovers modules from lazy-loaded routes and build config
- Template provides guidance for scenarios and module registry
- Implements idempotent setup with update/skip options

Implements TC-4130

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Assisted-by: Claude Code
…e capture script

- Create 6 performance workflow templates (baseline, module analysis, optimization task/plan, verification)
- Implement Playwright-based capture-baseline.template.mjs with comprehensive security hardening
- Security fixes: path traversal prevention, prototype pollution mitigation, token leakage prevention
- Localhost validation (127.0.0.0/8, ::1, blocks 0.0.0.0 and IPv6-mapped)
- Port validation (1-65535), iteration bounds (max 50/10), URL path validation
- Correct LCP metric using largest-contentful-paint entries
- Robust config table parsing (only actual table rows)
- Prerequisites documentation and user consent requirements

Implements TC-4131

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add performance-workflow-discovery skill that analyzes frontend
source code to identify functional workflows (user journeys),
presents discovered workflows to the user, and prompts for
selection. This skill serves as the entry point for the workflow-
based performance optimization approach.

- Discovers workflows from router configuration, feature modules,
  and navigation structure
- Estimates complexity based on components and API calls
- Saves user selection to performance-config.md
- Updated docs/workflow.md with performance optimization workflow
  section

Implements TC-4132

Assisted-by: Claude Code
…tion

Add performance-baseline skill that captures performance metrics for
user-selected workflows with test data verification before measurement.

Key features:
- Verifies Performance Analysis Configuration and selected workflow exist
- Prompts user to confirm test data availability before capture
- Handles existing baselines with replace/cancel prompt
- Copies capture script template from plugin cache
- Executes browser automation to measure LCP, FCP, TTI, Total Load Time
- Filters scenarios to include only selected workflow's key screens
- Generates baseline report with metrics, resource timing, waterfall
- Comprehensive error handling for common failures (app not running,
  Playwright not installed, invalid URLs, missing performance marks)
- Updated docs/workflow.md with baseline capture skill documentation

Implements TC-4133

Assisted-by: Claude Code
…detection

Add performance-analyze-module skill that performs deep performance analysis of
user-selected workflows by examining bundle composition and detecting nine
common performance anti-patterns: over-fetching, N+1 queries, waterfall loading,
render-blocking resources, unused code, expensive re-renders, long tasks, layout
thrashing, and missing lazy loading.

The skill generates comprehensive analysis reports with severity classification,
quantified impact estimates, and prioritized optimization recommendations scoped
to the selected workflow.

Jira-Issue-Id: TC-4134

Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
…k generation

Add performance-plan-optimization skill that generates structured optimization
plans from module-level analysis reports, creating Jira Epic and Tasks for
optimization work.

The skill reads workflow-analysis-report.md, groups optimizations into logical
tasks (bundle size, API, render, resource, long task categories), generates
optimization-plan.md with executive summary and task sequence, creates Jira
Epic with performance-optimization label, and creates linked Tasks with
performance-specific sections (Baseline Metrics, Target Metrics, Performance
Test Requirements).

Jira-Issue-Id: TC-4135

Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
…e test handling

Add performance-implement-optimization skill that executes performance
optimization tasks by implementing code changes, running functional and
performance tests, and comparing results against targets.

The skill extends implement-task workflow with performance-specific steps:
parses performance sections (Baseline Metrics, Target Metrics, Performance Test
Requirements), implements optimizations, runs functional tests with flexible
handling (tries npm test, prompts for custom test command, or recommends manual
verification), captures performance metrics, generates before/after comparison
report, and updates Jira with results.

Key feature: Step 8 tries npm test first, then prompts user whether tests exist
and requests test script path/instructions if available, or recommends manual
regression verification if no tests exist.

Jira-Issue-Id: TC-4136

Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements the performance-verify-optimization skill that verifies performance optimization PRs by:
- Reading review feedback and creating sub-tasks for change requests
- Validating acceptance criteria from Jira task
- Optionally re-running performance baseline as redundant check
- Validating target achievement (Full Success, Partial Success, Regression)
- Generating verification report with Overall result (PASS/WARN/FAIL)
- Posting report to GitHub PR and Jira task

Extends verify-pr workflow with performance-specific verification steps.
Baseline re-run is optional — used as redundant validation since regression
detection happens in performance-implement-optimization phase.

Jira-Issue-Id: TC-4137

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…workflow

Updates existing documentation files to integrate performance optimization
skills into the sdlc-workflow plugin documentation:

- README.md: Add all 6 performance skills to Available Plugins list
- docs/tools.md: Add Playwright section with installation, requirements,
  and graceful degradation notes
- docs/project-config-contract.md: Document optional Performance Analysis
  Configuration section with schema and example
- plugins/sdlc-workflow/shared/jira-access-strategy.md: Add Performance
  Optimization JIRA Workflow section documenting Epic/Task hierarchy,
  label conventions, and task description extensions
- docs/templates/conventions.md: Add Performance Optimization section
  template for per-repository conventions

All changes maintain consistency with existing documentation style and
structure.

Jira-Issue-Id: TC-4138

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add performance-workflow-guide.md (end-to-end workflow)
- Add performance-skills-reference.md (skill catalog)
- Add performance-metrics-guide.md (metrics and thresholds)
- Clarify analyze-module inspects source code
- Clarify plan-optimization reads reports (does NOT inspect code)

Quick reference style: tables, bullet points, minimal prose.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add Performance Optimization section to project CONVENTIONS.md
- Document quick reference style (tables, bullets, minimal prose)
- Document perf commit type for performance features
- Clarify skill distinctions (source code analysis vs report reading)
- Document metrics conventions (p95, Core Web Vitals, regression threshold)
- Document baseline capture and anti-pattern detection standards

- Update setup skill's conventions.template.md with Performance Optimization section
- Users running /setup will now get performance conventions in their CONVENTIONS.md

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
BREAKING CHANGE: performance-workflow-discovery merged into performance-setup

- Unified workflow selection during setup (eliminates separate discovery step)
- Three-layer optimization model: frontend/backend/integration anti-pattern detection
- Backend analysis for N+1 queries, missing pagination, inefficient queries across Rust/Java/Python/Node frameworks
- Frontend/backend/full-stack baseline capture modes with security hardening
- Critical fixes: port extraction, Jira Epic-Task parent field, auto-stash on regression, concurrent edit protection

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Dev command auto-discovery with frontend/backend/full-stack conditional discovery
- Config path auto-detection (walks up 5 parent dirs)
- Serena MCP detection and onboarding prompts with Serena-first fallback strategy
- UX improvements: explicit Approve/Modify/Exit menus, display all workflows including standalone routes

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…n detection, and missing index detection

Add three new analysis steps to performance-analyze-module: recursive call
graph tracing (Step 7.6.2), wasted computation detection (Step 7.6.3), and
missing database index detection (Step 7.6.4). Extract reusable call chain
logic into Pattern 12 in common-patterns.md. Add analysis config parameters
(chain_depth, db_latency_ms) and report template sections. Replace OHA
references with curl/bc throughout.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…etection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace performance-config.md with performance-config.json across all
skills and docs. Replace inline grep/awk config parsing with
perf-config.py get/set calls, inline benchmarking with
perf-benchmark.sh, and lockfile-based write protection with atomic
writes. Add Pattern 13 (Discovery Result Integrity), Playwright
verification step, dual-gate drift thresholds, and low-confidence
findings section. Delete performance-config.template.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ls, and broken flows

Fix backend-only mode by moving Serena probe out of frontend scope skip
path, replace phantom tool references (ToolSearch, Glob, search_for_pattern),
unify serena sentinel contract on null, fix config field name mismatches,
remove deprecated metadata.dev_command_approved dual-write, standardize
template placeholders to single-brace, merge duplicate plan templates,
add backend metric support to all templates, correct stale step references
and Jira parameter conventions, and add reconciliation notes for
overlapping detection steps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: mrrajan <86094767+mrrajan@users.noreply.github.com.>
…, and config path normalization

- Add db-migration as performance task specialization in implement-task and verify-pr
- Move config path from .claude/performance-config.json to performance-config.json
- Add frontend-to-backend API tracing for full-stack baseline scoping
- Expand analysis artifacts (findings-validation.json, query-ledger.json, analysis-progress.json)
- Add eval spec for performance optimization skills

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…d add N+1/pre-fetch detection

- Remove Step 9 skip for performance tasks — CI checks, scope containment,
  and all self-verification sub-steps now run before metric verification
- Add root cause elimination check to catch incomplete optimizations
  (e.g., batch helpers added inside a loop without eliminating the loop)
- Add N+1 loop origin identification in analyze-module findings
- Add concurrent per-item query detection (Step 7.3.1) for pre-fetch opportunities
- Add loop elimination mandate and pre-fetch mandate in plan-optimization
- Add query safety constraints from CONVENTIONS.md for parameter-limit-safe SQL
- Add strategic materialization promotion for denormalized table findings
- Add performance task evals for implement-task and verify-pr

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mrrajan and others added 3 commits June 30, 2026 21:23
Add detection steps for Cross-Table OR, Load-All-Then-Search, Unbounded
Iteration, Late Pagination, Redundant Indexes, and Recursive CTE Risk.
Add query restructuring mandate for plan-optimization. Include mock
backend fixtures for true-positive and false-positive eval coverage.
Ignore eval outputs/ in .gitignore.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Introduce Steps 7.8.1–7.8.4 for detecting anti-patterns in migration
DML (missing ANALYZE, non-materialized CTEs, uniform processing,
expensive PL/pgSQL patterns). Add Step 5.6 for optimization handling
of existing migrations, report/template sections, and eval case 9
with mock-backend-migration fixtures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mrrajan mrrajan force-pushed the TC-4129-performance-optimization branch from 9543f1c to 9ae6132 Compare June 30, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant