Skip to main content

Automation Priorities

AI-assisted development accelerates code production, which means your manual testing capacity becomes a bottleneck faster than before. Automation is not optional in an AI-augmented environment -- it is the only way to maintain quality at the velocity AI enables. This section defines what to automate first, how to select tools, and how to integrate AI-specific automation into your CI/CD pipeline. It supports Pillar 2: Quality Assurance and complements the testing strategy defined in Testing Strategy.

The Automation Imperative

Why Automation Is More Urgent Now

In pre-AI development, the ratio of code production to testing capacity was manageable with a mix of manual and automated testing. AI changes this equation:

FactorPre-AIPost-AIAutomation Implication
Code volume per sprintBaseline1.3-1.5x baseline30-50% more code to test
Defect densityBaseline1.7x baseline in AI codeMore defects to catch per unit of code
Vulnerability rateBaseline2.74x baseline in AI codeSecurity testing cannot be manual
PR review frequencyBaseline1.3-1.5x baselineAutomated checks must run before human review
Test creation speedLimited by human writing speedAI can generate tests rapidlyTest quality validation becomes the bottleneck

The conclusion: Without proportionally increased automation, quality will degrade as AI-assisted teams produce more code.

What to Automate First

Priority 1: Security Scanning (Implement Immediately)

Why first: The 2.74x vulnerability rate makes this the highest-risk automation gap.

What to automate:

Tool TypePurposeWhen to RunRecommended Tools
Secret detectionPrevent hardcoded credentials from reaching version controlPre-commit hook + CIgitleaks, trufflehog, detect-secrets
SASTDetect code-level vulnerability patternsEvery PRSemgrep, SonarQube, CodeQL
Dependency scanningDetect vulnerable or malicious dependenciesEvery PR + nightlySnyk, Dependabot, npm audit
Container scanningDetect vulnerable base images and configurationsEvery buildTrivy, Grype

Implementation checklist:

  • Pre-commit hooks installed on all developer machines
  • SAST runs on every PR and blocks merge for critical/high findings
  • Dependency scanning runs nightly and alerts on new vulnerabilities
  • Secret detection runs in CI even if pre-commit hooks pass
  • All tools configured with rules tuned for AI-specific vulnerability patterns

Priority 2: Code Quality Gates (Week 1-2)

Why second: Prevents the most common AI code quality issues from reaching review.

What to automate:

CheckPurposeConfiguration
LintingStyle consistency, common error detectionPer-language linter with team-specific rules
Type checkingCatch type errors in AI-generated codeTypeScript strict mode, mypy, etc.
Complexity thresholdPrevent overly complex AI-generated solutionsMax cyclomatic complexity per function (recommend 15)
Test coverage enforcementEnsure new code has minimum test coverageCoverage gate per PRD-STD-003 requirements
Dead code detectionCatch unreferenced AI-generated codeStatic analysis tool with dead code rules
Duplication detectionCatch AI-generated duplicate logicCPD, jscpd, or equivalent with 5% threshold

Priority 3: Integration Testing (Week 2-4)

Why third: AI-generated code often works in isolation but fails in integration.

What to automate:

Test TypePurposeImplementation
API contract testsVerify implementations match API contractsPact, Dredd, or custom contract validators
Database migration testsVerify AI-generated migrations are safe and reversibleAutomated migration up/down test in CI
Authentication/authorization testsVerify every endpoint has proper access controlsAutomated test suite that hits every endpoint with unauthenticated, unauthorized, and authorized requests
Cross-service integration testsVerify services interact correctlyDocker Compose or Kubernetes-based integration test environment

Priority 4: Architecture Compliance (Month 2)

Why fourth: Prevents long-term codebase degradation from AI-generated architectural violations.

What to automate:

CheckPurposeTooling
Dependency directionVerify code respects architectural layersArchUnit, NetArchTest, custom
Import restrictionsPrevent unauthorized cross-module importsESLint import rules, custom linter rules
API surface area monitoringDetect unintended API expansionCustom script that compares API surface to approved contract
Database query analysisDetect N+1 queries and unbounded queriesQuery analysis in CI or monitoring

Priority 5: Performance Testing (Month 2-3)

Why fifth: AI-generated code may have performance issues not visible in functional testing.

What to automate:

Test TypePurposeWhen to Run
Load testingVerify performance under expected loadNightly or weekly
Stress testingFind breaking pointsWeekly
Endurance testingDetect memory leaks and resource exhaustionWeekly
API latency benchmarksCatch performance regressionsEvery PR (lightweight) + nightly (full)

Tool Selection Criteria

When selecting automation tools, evaluate against these criteria:

CriterionWeightQuestion
AI-pattern awareness25%Does the tool have rules specifically for AI-generated code patterns?
CI/CD integration20%Does it integrate smoothly with your CI/CD platform (GitHub Actions, GitLab CI, Jenkins, etc.)?
Speed20%Can it run within acceptable PR check times (< 10 minutes for security, < 15 for full suite)?
Configurability15%Can you add custom rules for your specific defect patterns?
False positive rate10%Does it produce few enough false positives that developers trust the results?
Cost10%Is the pricing sustainable at your organization's scale?
warning

A tool that is too slow or produces too many false positives will be circumvented. Developers will find ways to bypass checks that consistently waste their time. Choose tools that are fast and accurate, and tune them to minimize false positives -- even if it means accepting some false negatives initially.

CI/CD Integration Architecture

Pipeline Design

Design your CI/CD pipeline with AI-specific quality gates:

PR Created
|
v
[Stage 1: Fast Checks - < 3 minutes]
- Linting
- Type checking
- Secret detection
- Dependency vulnerability check
|
v
[Stage 2: Security Analysis - < 10 minutes]
- SAST scan
- Complexity analysis
- Dead code detection
- Duplication check
|
v
[Stage 3: Test Execution - < 15 minutes]
- Unit tests with coverage
- Coverage threshold enforcement
- Integration tests (critical path)
|
v
[Stage 4: Architecture Checks - < 5 minutes]
- Dependency direction verification
- API contract validation
- Import restriction enforcement
|
v
[Human Review]
- All automated checks pass
- Reviewer focuses on logic, design, and business correctness
|
v
[Merge]

Pipeline Stage Requirements

StageMust Pass to ProceedBlocking Severity
Fast ChecksYesAny failure blocks
Security AnalysisYesCritical/High block; Medium/Low are warnings
Test ExecutionYesAny test failure blocks; coverage below threshold blocks
Architecture ChecksConfigurableStrict mode blocks; advisory mode warns

Nightly Pipeline (Extended Checks)

Run these checks nightly because they are too slow for every PR:

  • Full mutation testing suite
  • Comprehensive integration test suite
  • Load and performance testing
  • Full dependency tree vulnerability analysis
  • Dead code analysis across the full codebase

Measuring Automation Effectiveness

Track these metrics to ensure your automation investment is delivering value:

MetricTargetHow to Measure
Defect detection by automation> 60% of all defects caught by automated checksTag defects by detection source
Time from PR to feedback< 15 minutes for full pipelineCI/CD analytics
False positive rate< 5% across all toolsTrack overridden or dismissed findings
Pipeline reliability> 99% success rate (excluding legitimate failures)CI/CD analytics
Coverage trendIncreasing or stableCoverage tracking over time
Security findings trendDecreasing (indicating prevention is working)SAST/DAST finding counts over time

Automation Roadmap

TimelineFocusOutcome
Week 1Secret detection + SAST in CICritical security automation in place
Week 2Code quality gates (linting, typing, complexity)Quality floor established
Week 3-4Integration testing automationIntegration confidence
Month 2Architecture compliance + dependency scanningStructural quality protection
Month 3Performance testing + mutation testingDeep quality validation
OngoingCustom rule development, tool tuning, false positive reductionContinuous optimization

For the testing strategy context, see Testing Strategy. For the defect patterns these automations should target, see Defect Analysis. For the management perspective on quality automation investment, see Quality & Risk Oversight.