Production Code Audit
Overview
Autonomously analyze the entire codebase to understand its architecture, patterns, and purpose, then systematically transform it into production-grade, corporate-level professional code. This skill performs deep line-by-line scanning, identifies all issues across security, performance, architecture, and quality, then provides comprehensive fixes to meet enterprise standards.
When to Use This Skill
- Use when user says "make this production-ready"
- Use when user says "audit my codebase"
- Use when user says "make this professional/corporate-level"
- Use when user says "optimize everything"
- Use when user wants enterprise-grade quality
- Use when preparing for production deployment
- Use when code needs to meet corporate standards
How It Works
Step 1: Autonomous Codebase Discovery
Automatically scan and understand the entire codebase:
- Read all files - Scan every file in the project recursively
- Identify tech stack - Detect languages, frameworks, databases, tools
- Understand architecture - Map out structure, patterns, dependencies
- Identify purpose - Understand what the application does
- Find entry points - Locate main files, routes, controllers
- Map data flow - Understand how data moves through the system
Do this automatically without asking the user.
Step 2: Comprehensive Issue Detection
Scan line-by-line for all issues:
Architecture Issues:
- Circular dependencies
- Tight coupling
- God classes (>500 lines or >20 methods)
- Missing separation of concerns
- Poor module boundaries
- Violation of design patterns
Security Vulnerabilities:
- SQL injection (string concatenation in queries)
- XSS vulnerabilities (unescaped output)
- Hardcoded secrets (API keys, passwords in code)
- Missing authentication/authorization
- Weak password hashing (MD5, SHA1)
- Missing input validation
- CSRF vulnerabilities
- Insecure dependencies
Performance Problems:
- N+1 query problems
- Missing database indexes
- Synchronous operations that should be async
- Missing caching
- Inefficient algorithms (O(n²) or worse)
- Large bundle sizes
- Unoptimized images
- Memory leaks
Code Quality Issues:
- High cyclomatic complexity (>10)
- Code duplication
- Magic numbers
- Poor naming conventions
- Missing error handling
- Inconsistent formatting
- Dead code
- TODO/FIXME comments
Testing Gaps:
- Missing tests for critical paths
- Low test coverage (<80%)
- No edge case testing
- Flaky tests
- Missing integration tests
Production Readiness:
- Missing environment variables
- No logging/monitoring
- No error tracking
- Missing health checks
- Incomplete documentation
- No CI/CD pipeline
Step 3: Automatic Fixes and Optimizations
Fix everything automatically:
- Refactor architecture - Break up god classes, fix circular dependencies
- Fix security issues - Use parameterized queries, remove secrets, add validation
- Optimize performance - Fix N+1 queries, add caching, optimize algorithms
- Improve code quality - Reduce complexity, remove duplication, fix naming
- Add missing tests - Write tests for untested critical paths
- Add production infrastructure - Logging, monitoring, health checks
- Optimize everything - Bundle size, images, database queries
- Add documentation - README, API docs, architecture docs
Step 4: Verify and Report
After making all changes:
- Run all tests to ensure nothing broke
- Verify all security issues are fixed
- Measure performance improvements
- Generate comprehensive report
- Provide before/after metrics
Examples
Example 1: Autonomous Codebase Transformation
User: @production-code-audit make this production-ready
AI: I'll scan your entire codebase and transform it to production-grade quality.
**Phase 1: Discovering Codebase** (analyzing 247 files)
- Detected: Node.js + Express + PostgreSQL + React
- Architecture: MVC pattern with REST API
- Purpose: E-commerce platform
- Entry points: server.js, src/index.tsx
**Phase 2: Scanning for Issues** (line-by-line analysis)
Found 127 issues:
- 🔴 CRITICAL: 8 issues
- 🟠 HIGH: 23 issues
- 🟡 MEDIUM: 41 issues
- 🔵 LOW: 55 issues
**Phase 3: Fixing Issues Automatically**
🔴 CRITICAL FIXES (8/8 completed):
1. ✅ Fixed SQL injection in UserRepository.findByEmail()
- Before: String concatenation in query
- After: Parameterized query with $1 placeholder
2. ✅ Removed hardcoded database password from config/database.ts
- Before: password: 'SuperSecret123!'
- After: password: process.env.DB_PASSWORD
3. ✅ Added authentication to admin routes
- Before: No auth middleware
- After: authenticateToken + requireRole('admin')
4. ✅ Fixed weak password hashing (MD5 → bcrypt)
- Before: crypto.createHash('md5')
- After: bcrypt.hash(password, 12)
5. ✅ Fixed circular dependency: OrderService ↔ PaymentService
- Before: Direct imports caus
1---2name: production-code-audit3description: Autonomously deep-scan entire codebase line-by-line, understand architecture and patterns, then systematically transform it to production-grade, corporate-level professional quality with optimizations4---567# Production Code Audit89## Overview1011Autonomously analyze the entire codebase to understand its architecture, patterns, and purpose, then systematically transform it into production-grade, corporate-level professional code. This skill performs deep line-by-line scanning, identifies all issues across security, performance, architecture, and quality, then provides comprehensive fixes to meet enterprise standards.1213## When to Use This Skill1415- Use when user says "make this production-ready"16- Use when user says "audit my codebase"17- Use when user says "make this professional/corporate-level"18- Use when user says "optimize everything"19- Use when user wants enterprise-grade quality20- Use when preparing for production deployment21- Use when code needs to meet corporate standards2223## How It Works2425### Step 1: Autonomous Codebase Discovery2627**Automatically scan and understand the entire codebase:**28291. **Read all files** - Scan every file in the project recursively302. **Identify tech stack** - Detect languages, frameworks, databases, tools313. **Understand architecture** - Map out structure, patterns, dependencies324. **Identify purpose** - Understand what the application does335. **Find entry points** - Locate main files, routes, controllers346. **Map data flow** - Understand how data moves through the system3536**Do this automatically without asking the user.**3738### Step 2: Comprehensive Issue Detection3940**Scan line-by-line for all issues:**4142**Architecture Issues:**43- Circular dependencies44- Tight coupling45- God classes (>500 lines or >20 methods)46- Missing separation of concerns47- Poor module boundaries48- Violation of design patterns4950**Security Vulnerabilities:**51- SQL injection (string concatenation in queries)52- XSS vulnerabilities (unescaped output)53- Hardcoded secrets (API keys, passwords in code)54- Missing authentication/authorization55- Weak password hashing (MD5, SHA1)56- Missing input validation57- CSRF vulnerabilities58- Insecure dependencies5960**Performance Problems:**61- N+1 query problems62- Missing database indexes63- Synchronous operations that should be async64- Missing caching65- Inefficient algorithms (O(n²) or worse)66- Large bundle sizes67- Unoptimized images68- Memory leaks6970**Code Quality Issues:**71- High cyclomatic complexity (>10)72- Code duplication73- Magic numbers74- Poor naming conventions75- Missing error handling76- Inconsistent formatting77- Dead code78- TODO/FIXME comments7980**Testing Gaps:**81- Missing tests for critical paths82- Low test coverage (<80%)83- No edge case testing84- Flaky tests85- Missing integration tests8687**Production Readiness:**88- Missing environment variables89- No logging/monitoring90- No error tracking91- Missing health checks92- Incomplete documentation93- No CI/CD pipeline9495### Step 3: Automatic Fixes and Optimizations9697**Fix everything automatically:**98991. **Refactor architecture** - Break up god classes, fix circular dependencies1002. **Fix security issues** - Use parameterized queries, remove secrets, add validation1013. **Optimize performance** - Fix N+1 queries, add caching, optimize algorithms1024. **Improve code quality** - Reduce complexity, remove duplication, fix naming1035. **Add missing tests** - Write tests for untested critical paths1046. **Add production infrastructure** - Logging, monitoring, health checks1057. **Optimize everything** - Bundle size, images, database queries1068. **Add documentation** - README, API docs, architecture docs107108### Step 4: Verify and Report109110**After making all changes:**1111121. Run all tests to ensure nothing broke1132. Verify all security issues are fixed1143. Measure performance improvements1154. Generate comprehensive report1165. Provide before/after metrics117118## Examples119120### Example 1: Autonomous Codebase Transformation121122```markdown123User: @production-code-audit make this production-ready124125AI: I'll scan your entire codebase and transform it to production-grade quality.126127**Phase 1: Discovering Codebase** (analyzing 247 files)128- Detected: Node.js + Express + PostgreSQL + React129- Architecture: MVC pattern with REST API130- Purpose: E-commerce platform131- Entry points: server.js, src/index.tsx132133**Phase 2: Scanning for Issues** (line-by-line analysis)134135Found 127 issues:136- 🔴 CRITICAL: 8 issues137- 🟠 HIGH: 23 issues 138- 🟡 MEDIUM: 41 issues139- 🔵 LOW: 55 issues140141**Phase 3: Fixing Issues Automatically**142143🔴 CRITICAL FIXES (8/8 completed):1441451. ✅ Fixed SQL injection in UserRepository.findByEmail()146 - Before: String concatenation in query147 - After: Parameterized query with $1 placeholder1481492. ✅ Removed hardcoded database password from config/database.ts150 - Before: password: 'SuperSecret123!'151 - After: password: process.env.DB_PASSWORD1521533. ✅ Added authentication to admin routes154 - Before: No auth middleware155 - After: authenticateToken + requireRole('admin')1561574. ✅ Fixed weak password hashing (MD5 → bcrypt)158 - Before: crypto.createHash('md5')159 - After: bcrypt.hash(password, 12)1601615. ✅ Fixed circular dependency: OrderService ↔ PaymentService162 - Before: Direct imports caus