optimization-phase
Standard Operating Procedure for /optimize phase. Covers performance benchmarking, accessibility audit, security review, and code quality checks.
When & Why to Use This Skill
The Optimization Phase skill is a comprehensive Standard Operating Procedure (SOP) designed to ensure production readiness through rigorous performance benchmarking, accessibility audits, security reviews, and code quality checks. It streamlines the transition from implementation to deployment by enforcing strict quality gates, including API latency targets, WCAG compliance, and high test coverage, ensuring software is stable, secure, and performant.
Use Cases
- Performance Benchmarking: Validating that API response times (p50 <200ms) and page load speeds meet strict production targets.
- Accessibility Auditing: Ensuring UI features comply with WCAG 2.1 AA standards using automated tools like Lighthouse or axe-core.
- Security Vulnerability Scanning: Conducting dependency audits and security reviews to identify and mitigate risks before code reaches production.
- Code Quality Enforcement: Systematically checking for DRY (Don't Repeat Yourself) violations and ensuring unit/integration test coverage meets the 80% threshold.
- Production Readiness Validation: Serving as a final quality gate to generate comprehensive optimization and code review reports before the preview phase.
| name | optimization-phase |
|---|---|
| description | "Standard Operating Procedure for /optimize phase. Covers performance benchmarking, accessibility audit, security review, and code quality checks." |
| allowed-tools | Read, Bash, Grep, Glob |
Optimization Phase: Quick Reference
Purpose: Production readiness validation - performance, security, accessibility, and code quality before deployment.
Phase Overview
Inputs:
- Implemented code (from
/implementphase) specs/NNN-slug/spec.md- Success criteria and performance targets
Outputs:
optimization-report.md- Performance, security, accessibility resultscode-review-report.md- Code quality issues and recommendations
Expected duration: 1-2 hours
Quick Start Checklist
Before you begin:
- Implementation phase completed
- All tests passing
- Code committed to feature branch
Core workflow:
- ✅ Performance Benchmarking - API <200ms, page load <2s
- ✅ Accessibility Audit - WCAG 2.1 AA compliance (if UI feature)
- ✅ Security Review - npm audit, dependency scanning
- ✅ Code Quality Review - DRY violations, test coverage
- ✅ Generate Reports - optimization-report.md + code-review-report.md
Detailed Resources
🎯 Quality Gates (Blocking)
- Performance Benchmarking - API p50/p95, page load targets
- Accessibility Audit - Lighthouse CI, axe-core validation
- Security Review - Dependency vulnerabilities, OWASP top 10
📊 Code Quality (Blocking if Critical)
- Code Quality Review - DRY, KISS, test coverage (80%+)
- Code Review Checklist - Pre-commit validation
📝 Documentation
- Report Generation - optimization-report.md format
- Common Mistakes - Anti-patterns to avoid
Completion Criteria
Required (Blocking):
- Performance targets met (API p50 <200ms, p95 <500ms, page load <2s)
- Test coverage ≥80% (unit + integration)
- Security scan clean (no critical vulnerabilities)
- Accessibility WCAG 2.1 AA (if UI feature)
- No DRY violations (code duplication <3 instances)
Optional:
- Performance optimizations applied (caching, lazy loading)
- Minor accessibility improvements
- Code refactoring suggestions documented
Quality Gates
Gate 1: Pre-Flight Validation (Blocking)
- Environment variables configured
- Production build succeeds
- No TypeScript/lint errors
Gate 2: Code Review (Blocking if critical issues)
- Test coverage ≥80%
- Performance benchmarks met
- Security scan passed
- Accessibility standards met
Next Phase
After optimization complete:
→ /preview - Manual UI/UX testing on local dev server
See also:
- reference.md - Comprehensive optimization guide (full text)
- examples.md - Good vs bad optimization examples