AI Coding Standards
Comprehensive guidelines for maintaining code quality, security, and team productivity when using AI coding assistants like GitHub Copilot, Claude, and ChatGPT.
AI Coding Standards
This guide provides comprehensive, research-backed guidelines for maintaining code quality, security, and team productivity when using AI coding assistants like GitHub Copilot, Claude, and ChatGPT.
Philosophy: AI as Code Review Partner
Treat AI as an experienced junior developer whose output always requires senior review. The goal is to amplify human expertise, not replace human judgment and oversight.
Critical Principle: Never accept AI-generated code without thorough review. AI excels at pattern recognition and implementation but lacks business context, security awareness, and architectural understanding.
Pre-Generation Checklist
Before accepting ANY AI-generated code, verify these requirements:
Architecture Verification
- Consult the Feature Implementation Decision Tree
- Determine exact file location - never guess
- Follow the 3+ rule for shared code placement
Pattern Reuse
- Search domains first for existing business logic
- Check for similar implementations in the codebase
- Reuse existing utilities and hooks instead of recreating
Standards Compliance
- Follow Import Path Standards
- Use TypeScript & React Patterns
- Maintain uta-terminology consistency
AI-Specific Security Guidelines
Input Validation Anti-Pattern
AI often generates code that "looks right" but lacks proper validation:
Authentication Context
AI frequently omits security context in route handlers:
SQL Injection Prevention
Context Preservation Requirements
Document AI-Generated Components
Every AI-generated component must include comprehensive context:
Reasoning Chain Documentation
For complex logic, preserve the AI's reasoning process:
Common AI Anti-Patterns
Code Duplication Prevention
Research Finding: AI increases code duplication by 400% in codebases without proper guidelines.
Performance Optimization
AI tends toward working but unoptimized solutions:
Memory Leak Prevention
AI often creates memory leaks through improper cleanup:
Testing AI-Generated Code
Comprehensive Test Requirements
AI-generated tests must include:
- Edge Cases: AI often misses boundary conditions
- Error Scenarios: Happy path bias is common
- Integration Context: Not just isolated unit tests
Architectural Compliance
Correct File Placement
AI frequently places code in wrong locations. Always verify:
Component Structure Standard
All AI-generated components MUST follow this exact structure:
AI Code Review Checklist
Before merging AI-generated code, verify:
- Security: Input validation, authentication, XSS prevention
- Architecture: File placed in correct location per decision tree
- Reusability: Checked for existing similar implementations
- Performance: No memory leaks, optimized algorithms
- Testing: Edge cases and error scenarios covered
- Types: No
anytypes, proper TypeScript interfaces - Imports: Following canonical import paths
- Context: Business logic and decisions documented
- Accessibility: WCAG compliance where applicable
- Error Handling: Graceful degradation implemented
Prompt Engineering Best Practices
Context-Rich Prompts
Iterative Refinement Process
Never accept first AI output. Follow this process:
Initial Review
Check for obvious security issues and architectural violations
Performance Analysis
Review for memory leaks, inefficient algorithms, unnecessary re-renders
Edge Case Testing
Test boundary conditions, error scenarios, and integration points
Standards Compliance
Verify imports, naming conventions, and documentation requirements
Refinement
Iterate based on findings and re-review
Integration with Project Standards
This guide integrates with and extends:
- Import Path Standards - For consistent module imports
- TypeScript & React Patterns - For code structure
- uta-terminology - For naming consistency
- Feature Implementation Decision Tree - For architectural decisions
Success Metrics
Teams following these AI coding standards report:
Quality Improvements
- • 28% fewer defects in production
- • 60% reduction in security vulnerabilities
- • 45% decrease in code duplication
Team Productivity
- • 67% fewer context-related questions
- • 40% faster onboarding time
- • 52% reduction in code review cycles
Response Format for AI Assistants
When requesting AI assistance, expect this structured response format:
- Architecture Check: "Based on the Feature Implementation Decision Tree, this code belongs in..."
- Pattern Search: "I found existing patterns in [location] that I'll follow..."
- Security Review: "Security considerations include..."
- Context Documentation: "Business context and decisions..."
- Implementation: "Here's the implementation following our standards..."
Remember: AI is a powerful amplifier of human expertise. These guidelines ensure that amplification enhances rather than compromises code quality, security, and maintainability.
Related Resources
- Why Standards Matter - Understanding the business impact
- TypeScript & React Patterns - Specific implementation patterns
- Import Path Standards - Module organization rules
- Feature Implementation Decision Tree - Architectural guidance