production-code-quality
Ensures consistent production-grade code quality with autonomous self-assessment for Python, JavaScript/TypeScript, and React Native projects. Use when writing, modifying, or reviewing ANY code to gua
SKILL.md.claude/skills/code-quality/SKILL.md
GitHubProduction Code Quality Skill
This skill ensures every piece of code produced meets production-grade standards with zero tolerance for:
- Breaking changes without explicit permission
- Loss of existing functionality
- Compatibility issues with project files
- Substandard code quality
Core Guarantees
- Best-in-Class Code: Every output follows industry best practices
- Zero Surprise Breaking Changes: All breaking changes require explicit approval
- Full Feature Preservation: Original functionality is never lost
- Project Compatibility: New code integrates seamlessly
Self-Assessment Protocol
Before delivering ANY code, execute this mandatory workflow:
Step 1: Pre-Modification Inventory
Before making changes:
- Catalog all existing functions, classes, and exports in target file
- Document current behavior and integration points
- Identify dependencies and dependents within the project
Step 2: Compatibility Analysis
Run: python scripts/compatibility_checker.py <file> <project_root>
Requirements:
- MUST achieve compatibility score ≥ 95 to proceed
- Any CRITICAL compatibility issues block delivery
- Document all compatibility concerns in assessment report
Step 3: Breaking Change Detection
Run: python scripts/breaking_change_detector.py <original> <modified>
Requirements:
- ANY breaking change requires explicit user permission
- HALT delivery and request permission before proceeding
- Never assume permission is granted
Step 4: Functionality Preservation
Run: python scripts/functionality_preserver.py <original> <modified>
Requirements:
- 100% feature preservation required by default
- Any feature loss blocks delivery
- Document preservation verification in report
Step 5: React Native Analysis (for RN projects)
Run: python scripts/rn_analyzer.py <file_or_directory> [--project-root <path>]
Requirements:
- MUST achieve RN quality score ≥ 90 to proceed
- Any CRITICAL or HIGH issues block delivery
- Covers component quality, navigation patterns, native module safety, and performance
- Uses Node.js AST parsing when available, falls back to regex pattern matching
Step 6: Quality Assessment
Run: python scripts/self_assessment.py <file> [--compare <original>] [--project-root <path>]
Requirements:
- Generate comprehensive assessment report
- All quality criteria must pass
- Include report summary with delivery
- For RN projects, the orchestrator automatically invokes
rn_analyzer.py
Permission Protocol for Breaking Changes
When breaking changes are detected, follow this exact workflow:
STOP code delivery immediately
PRESENT detailed change impact analysis:
⚠️ BREAKING CHANGE DETECTED
The following changes will break existing functionality:
- [Change 1]: [Impact description]
- [Change 2]: [Impact description]
Affected components:
- [Component 1]: [How it's affected]
- [Component 2]: [How it's affected]
Risk Level: [CRITICAL/HIGH/MEDIUM]
- REQUEST explicit confirmation:
Do you explicitly approve these breaking changes?
Please respond with "yes" to approve or "no" to cancel.
WAIT for user response - do not proceed without explicit "yes"
DOCUMENT approval in code comments if approved:
# BREAKING CHANGE APPROVED: [date]
# Change: [description]
# Approved by user for reason: [reason if provided]
- PROCEED only after documented approval
Reference Documentation
Load these references as needed:
- Code Standards:
references/code-standards.md- Language-specific best practices (Python, JS/TS) - React Native Standards:
references/react-native-standards.md- Component quality, navigation, native modules, performance, Expo, NativeWind, and TypeScript patterns - Assessment Criteria:
references/assessment-criteria.md- Quality thresholds and metrics - Breaking Change Protocols:
references/breaking-change-protocols.md- Detailed approval workflow - Preservation Checklist:
references/preservation-checklist.md- Feature verification steps
Script Reference
| Script | Purpose | When to Use |
|---|---|---|
compatibility_checker.py |
Verify project compatibility | Before any code modification |
breaking_change_detector.py |
Detect breaking changes | When modifying existing code |
functionality_preserver.py |
Verify feature preservation | After any modification |
rn_analyzer.py |
React Native quality analysis | When working with RN/Expo/NativeWind files |
self_assessment.py |
Complete quality assessment | Before delivering any code |
Quality Standards by Language
Python
- Type hints on all function signatures
- Docstrings for public functions and classes
- Error handling with specific exceptions
- Logging for significant operations
- PEP 8 compliance
JavaScript/TypeScript
- TypeScript strict mode when applicable
- JSDoc comments for public APIs
- Proper error boundaries
- Async/await over callbacks
- ESLint compliance
React Native
Component Quality
- Rules of Hooks compliance (no hooks in conditionals, loops, or callbacks)
- Explicit TypeScript interfaces for all component props
useStatefor local UI state;useReducerfor complex transitions- Derived values computed via
useMemo, never stored in state - Custom hooks with single responsibility and typed returns
Navigation Patterns
- Typed navigators and screens (React Navigation
ParamListtypes or Expo Router typed params) _layout.tsxfiles for every Expo Router route group- Deep link parameters validated before use
- Prefer declarative
<Link>over imperativerouter.push()for static navigation
Native Module Compatibility
- All native module access guarded by
Platform.OSorPlatform.select - Expo module permissions checked before hardware access
- TurboModule lookups verified non-null before invocation
- JavaScript fallbacks provided for web/unsupported platforms
Performance Patterns
React.memo()on presentational components receiving non-primitive propsuseCallback()on handlers passed to memoized children or FlatList- FlatList:
keyExtractor,getItemLayout(fixed height), stablerenderItemreference - No nested FlatList inside ScrollView (breaks virtualisation)
StyleSheet.create()over inline style objects- Explicit image dimensions to prevent layout thrash
General
- Single Responsibility Principle
- DRY (Don't Repeat Yourself)
- KISS (Keep It Simple, Stupid)
- Meaningful variable and function names
- Appropriate code comments for complex logic
Troubleshooting
Assessment Fails
- Review the detailed assessment report
- Identify specific failures by category
- Address each flagged issue
- Re-run assessment until all checks pass
- If unable to resolve, explain the blocker to user
Cannot Preserve All Functionality
- Document which features cannot be preserved
- Explain technical reason for limitation
- Present alternatives if available
- Request explicit permission to proceed with reduced functionality
- Never silently drop functionality
Compatibility Score Below Threshold
- Identify incompatible imports/dependencies
- Check for conflicting function signatures
- Verify integration points are maintained
- Resolve conflicts or request guidance
- Re-run compatibility check after fixes
React Native Analysis Issues
- If AST mode fails, the analyzer falls back to regex — results may be less precise
- Install
@babel/parserglobally (npm i -g @babel/parser) for full AST coverage - For false positives on conditional hooks, verify the flagged line and suppress if valid
- Navigation typing issues only flag in
.ts/.tsxfiles — rename.jsfiles if appropriate
Assessment Report Format
Every code delivery includes an assessment summary:
## Assessment Summary
- Compatibility Score: XX/100
- Breaking Changes: None / X (all approved)
- Features Preserved: X/X (100%)
- RN Quality Score: XX/100 (if applicable)
- Quality Checks: PASS/FAIL
[Details if any issues]