Skip to content

AI Code Generation Practices

AI Code Generation Practices for Development Team

Section titled “AI Code Generation Practices for Development Team”

rev. 7-26-25

With the introduction of Claude Code and AI-assisted development, we need to adapt our practices to maintain code quality and understanding while leveraging AI’s speed.

AI as a Fast but Inconsistent Developer: AI tools are incredibly fast and capable at pattern matching and code generation, but can be inconsistent in their approaches and lack understanding of business context, architectural implications, and edge cases. Our role shifts from primarily writing code to architecting, reviewing strategically, and maintaining system understanding.

Velocity with Purpose: We use AI to accelerate delivery of climate impact solutions. Speed matters, but not at the expense of reliability or maintainability.

Human Judgment at the Center: AI amplifies our capabilities but doesn’t replace our responsibility. We maintain ownership of architectural decisions, business logic, and system understanding.

Continuous Learning: Both humans and AI improve through feedback loops. We document patterns, review outcomes, and refine our approaches based on real-world results.

Transparency and Trust: We’re open about using AI tools with our stakeholders. Our risk-based review process ensures appropriate oversight while building confidence in AI-assisted development.

  • Developers spend more time on architecture and problem-solving, less on boilerplate
  • AI suggestions improve over time through better context (momentum-docs MCP)
  • Code quality remains high or improves through consistent automated checks
  • Team maintains deep understanding of the codebase despite increased velocity
  • Customers benefit from faster feature delivery without stability compromises

The review strategy has evolved into a risk-based approach rather than time-based tiers. See the Risk-Based PR Review Policy for current guidelines.

Risk Assessment

  • Developer judgment determines risk level, not review duration
  • Context matters more than file types (e.g., test data migration vs production data migration)
  • Feature flags and parallel refactors reduce risk levels

AI Review Capabilities

  • Zero-risk changes: AI-only review sufficient
  • Low-risk changes: AI review with 20% post-merge sampling
  • Medium-risk changes: Either human review OR AI + mandatory post-merge
  • High-risk changes: Human review required

What We’ve Learned So Far July 2025

  • AI reviewers excel at syntax, patterns, and security vulnerabilities
  • Human reviewers needed for business logic, architectural decisions, and context

Code Generation: Claude Code - Our primary AI pair programming tool AI Code Review:

  • CodeRabbit - Automated PR review for best practices and patterns
  • Korbit - Security vulnerabilities and code quality analysis

Context Provider: Momentum-Docs MCP (Model Context Protocol)

  • Provides Claude Code with up-to-date documentation on domains, APIs, and patterns
  • Reduces repetitive codebase searches and improves AI accuracy
  • Must be kept current with released features and established patterns

All AI review comments must be addressed - This means:

  1. Respond to each comment explaining your decision
  2. Implement suggested fixes when appropriate
  3. Resolve the comment thread with justification if not implementing

This policy ensures we don’t miss valuable automated insights while maintaining developer judgment on implementation decisions.

Momentum-Docs MCP Maintenance: When discovering architectural patterns, API usage, or domain knowledge through code exploration:

  1. Consider if this knowledge would benefit future AI-assisted development
  2. Document stable patterns in momentum-docs to minimize future search overhead
  3. Keep documentation current as patterns evolve
  4. Skip documenting work-in-progress or experimental features

This creates a virtuous cycle where AI assistance becomes more accurate and efficient over time.

  • Run at maximum level (9) for all AI-generated code
  • Enable strict rules: strictRules: true
  • Add bleeding edge rules
  • Create custom rules for domain-specific patterns
  • Set up CI to fail builds on PHPStan violations

To make generated code more reviewable, remind AI to follow MCP and rules document.

  • PHPStan level 9 compliance
  • Specific test coverage targets (minimum 80% for new features)
  • Adherence to existing architectural patterns
  • Inline documentation for complex business logic
  • Error handling for expected failure modes
  • Code Quality: PHPStan violations, test coverage percentages
  • Production Stability: Error rates, performance metrics
  • Team Velocity: Feature delivery speed while maintaining quality
  • Knowledge Retention: Team confidence in explaining system behavior
  • ✅ Risk-based review policy documented
  • ✅ AI code generation practices defined
  • ✅ Claude Code, CodeRabbit, and Korbit integrated into workflow
  • ✅ AI review comment policy established (all comments must be addressed)
  • ✅ Momentum-docs MCP deployed for context management
  • ✅ PHPStan level 9 enforcement for new code
  • 🚧 Risk assessment automation tools (Python script created, GitHub Actions pending)
  • 🚧 Post-merge review tracking implementation
  • 🚧 Team training on risk categorization

Future Expansion: Toward a Complete Model Specification

Section titled “Future Expansion: Toward a Complete Model Specification”

This document could evolve into a comprehensive Model Specification (Model Card) for our AI-assisted development system. Additional sections to consider:

  • Model versions and capabilities for each AI tool
  • Training data characteristics and limitations
  • Update cycles and version control
  • Integration points and dependencies
  • Baseline metrics: pre-AI vs post-AI development velocity
  • Defect rates by risk category and review type
  • False positive/negative rates in automated reviews
  • Time-to-resolution for AI-flagged issues
  • Documented failure modes and recovery procedures
  • Incident response protocols for AI-related issues
  • Human escalation paths and override mechanisms
  • Business continuity without AI tools
  • Data sharing agreements with AI providers
  • Code privacy and intellectual property protections
  • Audit trails for AI-assisted decisions
  • Regulatory compliance considerations
  • Developer experience and job satisfaction metrics
  • Training requirements and skill development
  • Client communication about AI usage
  • Long-term maintainability considerations

Creating a full Model Specification would provide transparency for SOC2 audits, support responsible AI practices, and establish Cadence OneFive as a leader in climate tech AI adoption.