Stage 7 · Master
Advanced Topics & Future of Platform Engineering
AI-Augmented Developer Platform
Copilot for platform: scaffold from natural language, auto-fix policy violations, predict capacity, anomaly detection in DX metrics.
Why AI for Platform?
Platform engineering is ripe for AI: repetitive tasks (scaffolding, policy fixes), pattern recognition (capacity, anomalies), natural language interfaces (developers ask, platform acts). AI doesn't replace platform engineers — it amplifies them.
| Traditional Platform | AI-Augmented Platform |
|---|---|
Scaffold: platform service create --name x --team y | Scaffold: "Create a payment service with PostgreSQL and Kafka for the payments team" |
| Fix policy: Manual PR review, CI fails, developer fixes | Fix policy: LLM analyzes violation, suggests fix, creates PR |
| Capacity: Manual scaling, reactive | Capacity: Predictive scaling based on ML forecast |
| Incidents: Manual investigation | Incidents: LLM correlates logs, metrics, traces, suggests root cause |
| Docs: Manual, often outdated | Docs: Auto-generated from code, kept in sync |
| Support: Human answers in Slack | Support: LLM first-line, escalates to human |
Natural Language Scaffolding
Developer describes intent in natural language. LLM translates to template parameters, selects appropriate golden path, generates scaffold. Human reviews and approves.
interface ScaffoldRequest {
naturalLanguage: string;
userId: string;
team: string;
}
interface ScaffoldPlan {
template: string;
parameters: Record<string, any>;
capabilities: string[];
estimatedTime: string;
warnings: string[];
}
class NLScaffoldService {
private llm: LLMClient;
private templateRegistry: TemplateRegistry;
private policyEngine: PolicyEngine;
async generatePlan(request: ScaffoldRequest): Promise<ScaffoldPlan> {
// 1. Build context for LLM
const context = await this.buildContext(request);
// 2. Prompt LLM to extract intent
const prompt = `
You are a platform engineering assistant. Convert the user's natural language request into a scaffold plan.
Available templates:
${this.templateRegistry.list().map(t => `- ${t.name}: ${t.description}`).join('
')}
Available capabilities: postgresql, redis, kafka, service-mesh, pubsub, blob-storage, ml-feature-store
User request: "${request.naturalLanguage}"
User team: ${request.team}
Output JSON with:
- template: template name
- parameters: key-value pairs for template
- capabilities: list of required capabilities
- estimatedTime: human-readable estimate
- warnings: any concerns
`;
const response = await this.llm.complete({
prompt,
temperature: 0.1,
maxTokens: 1000,
responseFormat: "json",
});
const plan = JSON.parse(response.text) as ScaffoldPlan;
// 2. Validate against policies
const validation = await this.policyEngine.validatePlan(plan, request.team);
if (!validation.valid) {
plan.warnings.push(...validation.violations.map(v => `Policy: ${v.message}`));
}
// 3. Enrich with defaults
plan.parameters = this.enrichWithDefaults(plan.parameters, request.team);
return plan;
}
async executePlan(plan: ScaffoldPlan, userId: string): Promise<ScaffoldResult> {
// Human-in-the-loop: present plan for approval
const approval = await this.requestApproval(plan);
if (!approval.approved) {
throw new Error("Scaffold cancelled by user");
}
// Execute via platform API
return this.platformClient.scaffold({
template: plan.template,
parameters: plan.parameters,
requestedBy: userId,
});
}
}
LLM converts natural language to structured scaffold plan. Policy engine validates. Human approves before execution.
$ platform scaffold "Create a payment processing service with PostgreSQL and Kafka for the payments team"
🤖 Analyzing request...
📋 Generated Plan:
Template: golden-path-go-service
Parameters:
service_name: payment-processor
team: payments
language: go
framework: gin
Capabilities: [postgresql, kafka]
Estimated Time: 3 minutes
Warnings: None
❓ Proceed? [Y/n] y
🚀 Scaffolding...
✓ Validated parameters
✓ Rendered template
✓ Created GitHub repo: github.com/myorg/payment-processor
✓ Configured CI/CD (GitHub Actions)
✓ Created ArgoCD Application
✓ Provisioned PostgreSQL (db-payments-prod)
✓ Provisioned Kafka topic (payments.events)
✓ Registered in software catalog
✓ Created preview environment
✅ Service created successfully!
Repository: https://github.com/myorg/payment-processor
ArgoCD: https://argocd.platform.example.com/applications/payments-payment-processor
Grafana: https://grafana.platform.example.com/d/service-payment-processor
Runbook: https://github.com/myorg/payment-processor/blob/main/RUNBOOK.md
Next steps:
1. git clone https://github.com/myorg/payment-processor
2. Open in VS Code (DevContainer recommended)
3. Start coding! Push to main to deploy.
CLI integrates NL scaffold: user describes intent, LLM generates plan, human approves, platform executes.
Auto-Fix Policy Violations
Policy violations block CI/CD. LLM analyzes violation, understands context, generates fix, creates PR. Developer reviews and merges.
interface PolicyViolation {
policy: string;
rule: string;
message: string;
file: string;
line: number;
severity: "error" | "warning";
context: string; // Surrounding code
}
interface FixProposal {
violation: PolicyViolation;
fix: string; // Unified diff
explanation: string;
confidence: number; // 0-1
requiresHumanReview: boolean;
}
class AutoFixService {
private llm: LLMClient;
private gitClient: GitClient;
async analyzeViolation(violation: PolicyViolation): Promise<FixProposal> {
const prompt = `
You are a platform policy expert. Fix this policy violation.
Policy: ${violation.policy}
Rule: ${violation.rule}
Message: ${violation.message}
File: ${violation.file}
Line: ${violation.line}
Context:
```
${violation.context}
```
Common patterns for this policy:
${this.getPolicyPatterns(violation.policy, violation.rule)}
Output JSON:
{
"fix": "unified diff",
"explanation": "what and why",
"confidence": 0.0-1.0,
"requiresHumanReview": true/false
}
`;
const response = await this.llm.complete({
prompt,
temperature: 0.1,
responseFormat: "json",
});
return JSON.parse(response.text);
}
async createFixPR(violation: PolicyViolation, proposal: FixProposal): Promise<string> {
const branchName = `policy-fix/${violation.policy}/${violation.rule}/${Date.now()}`;
// Create branch, apply fix, commit
await this.gitClient.createBranch(branchName);
await this.gitClient.applyDiff(violation.file, proposal.fix);
await this.gitClient.commit(
`fix: resolve ${violation.policy} ${violation.rule} violation
${proposal.explanation}
Auto-generated by platform AI. Requires review.`,
branchName
);
// Create PR
const pr = await this.gitClient.createPullRequest({
title: `fix: ${violation.policy} ${violation.rule} violation in ${violation.file}`,
body: `## Auto-Fix for Policy Violation
**Policy:** ${violation.policy}
**Rule:** ${violation.rule}
**File:** ${violation.file}:${violation.line}
**Explanation:** ${proposal.explanation}
**Confidence:** ${(proposal.confidence * 100).toFixed(0)}%
**Requires Human Review:** ${proposal.requiresHumanReview ? 'Yes' : 'No'}
```diff
${proposal.fix}
```
*Generated by Platform AI. Please review carefully before merging.*
`,
head: branchName,
base: "main",
labels: ["auto-fix", "policy-violation", `policy:${violation.policy}`],
reviewers: ["platform-team"],
});
return pr.url;
}
}
LLM analyzes violation context, generates fix diff, creates PR with explanation. Human reviews and merges.
Predictive Capacity & Cost
ML models forecast: capacity needs (CPU, memory, storage), cost trends, anomaly detection. Platform proactively scales, alerts on budget risk, recommends right-sizing.
import pandas as pd
import numpy as np
from prophet import Prophet
from sklearn.ensemble import IsolationForest
import mlflow
class CapacityForecaster:
def __init__(self):
self.models = {}
self.anomaly_detector = IsolationForest(contamination=0.01)
def train_capacity_model(self, metric_name: str, df: pd.DataFrame):
"""Train Prophet model for capacity metric (CPU, memory, storage)."""
# Prepare data for Prophet
df_prophet = df.rename(columns={'timestamp': 'ds', 'value': 'y'})
# Add regressors: day of week, hour, deployment events
df_prophet['day_of_week'] = df_prophet['ds'].dt.dayofweek
df_prophet['hour'] = df_prophet['ds'].dt.hour
model = Prophet(
yearly_seasonality=False,
weekly_seasonality=True,
daily_seasonality=True,
changepoint_prior_scale=0.05,
seasonality_prior_scale=10,
)
model.add_regressor('day_of_week')
model.add_regressor('hour')
model.fit(df_prophet)
self.models[metric_name] = model
# Log to MLflow
mlflow.log_model(model, f"capacity-{metric_name}")
def forecast(self, metric_name: str, horizon_hours: int = 168) -> pd.DataFrame:
"""Forecast metric for next horizon_hours (default 1 week)."""
model = self.models[metric_name]
future = model.make_future_dataframe(periods=horizon_hours, freq='H')
future['day_of_week'] = future['ds'].dt.dayofweek
future['hour'] = future['ds'].dt.hour
forecast = model.predict(future)
return forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']]
def detect_anomalies(self, metric_name: str, recent_data: pd.DataFrame) -> pd.DataFrame:
"""Detect anomalies in recent metric data."""
values = recent_data['value'].values.reshape(-1, 1)
anomaly_scores = self.anomaly_detector.fit_predict(values)
recent_data['anomaly_score'] = anomaly_scores
recent_data['is_anomaly'] = anomaly_scores == -1
return recent_data
def generate_recommendations(self, forecasts: Dict[str, pd.DataFrame]) -> List[Recommendation]:
"""Generate right-sizing recommendations from forecasts."""
recommendations = []
for metric, forecast in forecasts.items():
# Get peak forecast
peak = forecast['yhat_upper'].max()
current_limit = self.get_current_limit(metric)
if peak > current_limit * 0.8:
recommendations.append(Recommendation(
type="scale_up",
metric=metric,
current=current_limit,
recommended=peak * 1.2,
reason=f"Forecasted peak ({peak:.1f}) exceeds 80% of current limit ({current_limit})",
confidence=0.85,
))
# Check for over-provisioning
avg_usage = forecast['yhat'].mean()
if avg_usage < current_limit * 0.3:
recommendations.append(Recommendation(
type="scale_down",
metric=metric,
current=current_limit,
recommended=max(avg_usage * 2, current_limit * 0.5),
reason=f"Average forecasted usage ({avg_usage:.1f}) well below current limit ({current_limit})",
confidence=0.75,
))
return recommendations
Prophet for time-series forecasting, IsolationForest for anomaly detection. Generates right-sizing recommendations with confidence scores.
Anomaly Detection in DX Metrics
Detect anomalies in developer experience metrics: scaffold success rate drops, CI queue time spikes, preview env failures increase. Alert platform team before developers complain.
# PrometheusRule for DX metric anomalies
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: dx-metrics-anomalies
namespace: monitoring
spec:
groups:
- name: dx-metrics-anomalies
interval: 5m
rules:
# Scaffold success rate anomaly
- alert: ScaffoldSuccessRateAnomaly
expr: |
(
rate(platform_scaffold_total{status="success"}[5m])
/
rate(platform_scaffold_total[5m])
) < 0.95
and
rate(platform_scaffold_total[5m]) > 0.1
for: 5m
labels:
severity: warning
team: platform
annotations:
summary: "Scaffold success rate dropped below 95%"
description: "Success rate: {{ $value | humanizePercentage }}. Check scaffolder logs and GitHub API status."
runbook_url: "https://runbooks.platform.example.com/scaffold-failures"
# CI queue time anomaly
- alert: CIQueueTimeAnomaly
expr: |
histogram_quantile(0.95, rate(github_actions_queue_duration_seconds_bucket[5m])) > 600
for: 10m
labels:
severity: warning
team: platform
annotations:
summary: "CI queue time p95 > 10 minutes"
description: "Queue time p95: {{ $value | humanizeDuration }}. Check runner capacity and queue depth."
runbook_url: "https://runbooks.platform.example.com/ci-queue"
# Preview environment failure rate
- alert: PreviewEnvFailureRateAnomaly
expr: |
(
rate(platform_preview_env_total{status="failed"}[15m])
/
rate(platform_preview_env_total[15m])
) > 0.1
for: 5m
labels:
severity: warning
team: platform
annotations:
summary: "Preview environment failure rate > 10%"
description: "Failure rate: {{ $value | humanizePercentage }}. Check ArgoCD sync status and Crossplane claims."
runbook_url: "https://runbooks.platform.example.com/preview-env-failures"
# Scaffold-to-deploy time regression
- alert: ScaffoldToDeployTimeRegression
expr: |
histogram_quantile(0.50, rate(platform_scaffold_to_deploy_seconds_bucket[1h]))
>
1.5 * histogram_quantile(0.50, rate(platform_scaffold_to_deploy_seconds_bucket[1h] offset 7d))
for: 30m
labels:
severity: info
team: platform
annotations:
summary: "Scaffold-to-deploy time increased 50% vs last week"
description: "Current p50: {{ $value | humanizeDuration }}. Investigate CI/CD pipeline changes."
runbook_url: "https://runbooks.platform.example.com/scaffold-deploy-regression"
# Platform API latency anomaly (ML-based)
- alert: PlatformAPILatencyAnomaly
expr: |
histogram_quantile(0.99, rate(platform_api_request_duration_seconds_bucket[5m]))
>
3 * histogram_quantile(0.99, rate(platform_api_request_duration_seconds_bucket[5m] offset 1h))
for: 5m
labels:
severity: critical
team: platform
annotations:
summary: "Platform API p99 latency 3x higher than 1 hour ago"
description: "Possible platform API degradation. Check API pods, dependencies, recent deployments."
runbook_url: "https://runbooks.platform.example.com/api-latency"
PrometheusRules with anomaly detection: rate-based thresholds, historical comparison (offset), ML-ready for future integration.
ChatOps + LLM
Slack/Teams bot powered by LLM: developers ask questions, bot answers from docs, runbooks, metrics. Escalates to human when needed.
import { App, ExpressReceiver } from '@slack/bolt';
import { LLMClient } from './llm';
class PlatformBot {
private app: App;
private llm: LLMClient;
private platformClient: PlatformClient;
constructor() {
this.app = new App({
signingSecret: process.env.SLACK_SIGNING_SECRET,
token: process.env.SLACK_BOT_TOKEN,
receiver: new ExpressReceiver({ signingSecret: process.env.SLACK_SIGNING_SECRET }),
});
this.llm = new LLMClient();
this.platformClient = new PlatformClient();
this.registerHandlers();
}
private registerHandlers() {
// Mention handler
this.app.event('app_mention', async ({ event, say }) => {
const text = event.text.replace(/<@[A-Z0-9]+>/, '').trim();
const response = await this.processQuery(event.user, text);
await say({ text: response, thread_ts: event.ts });
});
// Slash commands
this.app.command('/platform', async ({ command, ack, respond }) => {
await ack();
const response = await this.processQuery(command.user_id, command.text);
await respond(response);
});
// Interactive components (buttons, selects)
this.app.action('platform_action', async ({ action, ack, respond }) => {
await ack();
const response = await this.handleAction(action);
await respond(response);
});
}
private async processQuery(userId: string, query: string): Promise<string> {
// Get context: user's team, recent activity, open PRs
const context = await this.getUserContext(userId);
const prompt = `
You are the Platform Assistant. Help developers with platform questions.
User: ${context.userName} (Team: ${context.team})
Recent activity: ${context.recentActivity}
Open PRs: ${context.openPRs}
Available tools:
- get_service_info(service_name)
- get_deployment_status(service_name)
- get_logs(service_name, since)
- get_metrics(service_name, metric, duration)
- search_docs(query)
- search_runbooks(query)
- create_scaffold_plan(description)
- check_policy_compliance(service_name)
User question: "${query}"
If you need to use a tool, respond with:
TOOL: tool_name(arguments)
If you can answer directly, provide a helpful response.
`;
let response = await this.llm.complete({ prompt, temperature: 0.1 });
// Handle tool calls
while (response.includes('TOOL:')) {
const toolMatch = response.match(/TOOL: (w+)((.*))/);
if (!toolMatch) break;
const [, toolName, argsStr] = toolMatch;
const args = JSON.parse(argsStr);
let toolResult;
switch (toolName) {
case 'get_service_info':
toolResult = await this.platformClient.getService(args.service_name);
break;
case 'get_deployment_status':
toolResult = await this.platformClient.getDeploymentStatus(args.service_name);
break;
case 'search_docs':
toolResult = await this.platformClient.searchDocs(args.query);
break;
// ... other tools
}
response = await this.llm.complete({
prompt: `${prompt}
Tool result: ${JSON.stringify(toolResult)}
Continue answering.`,
temperature: 0.1,
});
}
return response;
}
}
Slack bot with LLM: understands natural language, calls platform APIs, searches docs/runbooks, creates scaffold plans. Human-in-the-loop for actions.
AI Guardrails & Safety
- Human-in-the-loop: All destructive actions require human approval
- Confidence thresholds: Only auto-execute if confidence > 0.9
- Audit trail: Every AI action logged with prompt, response, decision
- Rate limiting: Max N AI actions per hour per user/team
- Rollback: One-click rollback for AI-initiated changes
- Explainability: AI must provide reasoning for every suggestion
- Bias testing: Regular evaluation of AI suggestions across teams/languages
- Data privacy: No PII in prompts, no training on customer data
- Fallback: Graceful degradation to human-only when AI unavailable
- Red teaming: Regular adversarial testing of AI guardrails
Platform engineers become AI supervisors: they define policies, review AI suggestions, handle edge cases, improve models. The platform becomes a teaching tool — developers learn best practices from AI suggestions.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.