Most AI-coding demos start from an empty repository. Most real work does not. Production applications carry years of business rules, downstream consumers, and people who act on their output every day. The useful question is not whether an agent can write a feature. It usually can. The question is how to let an agent change a system people rely on and still prove that nothing they depend on changed until someone decided it should.

Executive summary

The AWS AI-Driven Development Lifecycle (AI-DLC) puts AI at the center of planning, design, and construction while people approve each phase. It gates the plan and the code. It does not, by itself, gate the moment new behavior first meets production traffic. A merged pull request is not a decision that users should see a change, and in a brownfield system those two events must stay separate.

AWS AppConfig feature flags close that gap. The pattern is three rules. The agent may only add behavior behind a flag that defaults to off. A code deployment with the flag off must be a no-op for users, which you can prove with tests. Turning the flag on is a human decision, rolled out gradually, watched by CloudWatch alarms, and reversible in seconds. In AI-DLC terms, flipping the flag becomes the final approval gate, owned by the Operations phase.

System view · aws architecture

AI-DLC Meets Brownfield: Shipping AI-Built Changes Without Breaking Production

Which AWS services, owners, and failure paths separate the code deploy from the release decision?

Feature-flag release gate for AI-built changes. Conceptual reference architecture; workload-specific validation is required.

1. AI-DLC in brief

AWS introduced AI-DLC as a methodology rather than a tool. The AI proposes plans, asks clarifying questions, and generates artifacts; people validate, decide, and own the outcome. Work moves through three phases. Inception turns intent into requirements and units of work, reviewed by the team in a ritual called Mob Elaboration. Construction produces the domain model, design, code, and tests, reviewed in Mob Construction. Operations covers deployment, observability, and running the change.

The workflow is open source as awslabs/aidlc-workflows under MIT-0, and version 2 runs natively in several agent harnesses, including Kiro, Claude Code, Codex CLI, Cursor, and GitHub Copilot. Two properties matter most for brownfield work. The workflow detects an existing codebase and scales its rigor to the change, so a small fix skips stages a new capability needs. And every plan, question, answer, and approval is written to files in the repository, which gives regulated teams an audit trail as valuable as the code.

2. The playbook, phase by phase

Inception: make the agent learn the system before it changes it. Start with a one- or two-sentence statement of intent and let the workflow ask the questions. Let reverse engineering run, then correct the agent's model of the existing code as a team, because every wrong assumption caught here is a defect you never ship. Write down the behavior that must not change; that list becomes the regression contract and the flag-off test suite. Name the flag in the requirements, with an owner, a default of off, and a removal date, so the agent designs for it instead of bolting it on.

Construction: build both paths, test both paths. Read the flag once, at the entry point of the unit, and route to the new or legacy implementation. Never let the new path overwrite shared state while it is unproven; write its output beside the legacy result. Test the flag-off path as hard as the flag-on path and make that suite a required CI check. In Mob Construction, ask one question of every diff: with the flag off, can this change what a user sees?

Operations: release is a separate, reversible decision. Deploy with the flag off and confirm that dashboards and the flag-off contract stay flat. Compare new and legacy outputs side by side before anyone acts on the new one. Roll out with an AppConfig deployment strategy that includes bake time, attach alarms on errors and a business-level signal, and let the alarm be the first responder. Once the new behavior is accepted, delete the flag and the legacy path.

Evidence view · decision tree

AI-DLC Meets Brownfield: Shipping AI-Built Changes Without Breaking Production

What does the Lambda seam return for every possible flag-read outcome?

Did the flag read succeed?
YES
NO
enabled: truelegacy + v2 beside it · emit PriorityDisagreement
enabled: falselegacy priority only
Timeout or HTTP errorlegacy priority only
Extension unreachablefail closed · legacy priority only
Only an explicit enabled: true reaches the new rule. Every other path returns today’s behavior.
The seam fails closed: only an explicit enabled flag reaches the new rule, and every other outcome returns today’s behavior.

3. A generic use case you can run: Support Ticket Priority

To make the pattern concrete, the companion project uses a deliberately generic brownfield change. A support platform sets every ticket's priority from the customer's tier alone, so an enterprise how-to question outranks a full outage for a standard customer. The new rule, built with AI-DLC, scores impact instead: tier, whether the service is down, how many users are affected, and how long the ticket has been open. Support teams, dashboards, and service-level agreements already depend on today's priority, which is exactly why the new rule must ship dark.

The infrastructure is plain Terraform with the AWS provider, so it fits existing pipelines and works with OpenTofu. This excerpt from terraform/appconfig.tf tells the environment to watch two alarms and defines one strategy for turning the flag on and another for turning it off:

resource "aws_appconfig_environment" "prod" {
  application_id = aws_appconfig_application.flags.id
  name           = var.env_name

  # If either alarm fires during a flag deployment, AppConfig rolls it back.
  monitor {
    alarm_arn      = aws_cloudwatch_metric_alarm.function_errors.arn
    alarm_role_arn = aws_iam_role.appconfig_alarms.arn
  }

  monitor {
    alarm_arn      = aws_cloudwatch_metric_alarm.priority_disagreement.arn
    alarm_role_arn = aws_iam_role.appconfig_alarms.arn
  }
}

# Turning ON: 20% more Lambda execution environments every 4 minutes,
# then 10 minutes of bake time while the alarms watch.
resource "aws_appconfig_deployment_strategy" "gradual" {
  name                           = "${var.app_name}-linear-20pct-bake-10m"
  deployment_duration_in_minutes = 20
  growth_type                    = "LINEAR"
  growth_factor                  = 20
  final_bake_time_in_minutes     = 10
  replicate_to                   = "NONE"
}

# Turning OFF (kill switch): everyone at once, no bake.
resource "aws_appconfig_deployment_strategy" "immediate" {
  name                           = "${var.app_name}-immediate-no-bake"
  deployment_duration_in_minutes = 0
  growth_type                    = "LINEAR"
  growth_factor                  = 100
  final_bake_time_in_minutes     = 0
  replicate_to                   = "NONE"
}

Terraform owns the infrastructure and creates the flag in the off state; every later flag version comes from a person running the rollout script. Do not put the flag value in a Terraform variable, or a routine apply quietly becomes a release. Two details are easy to miss: the role AppConfig assumes needs cloudwatch:DescribeAlarms, and alarm actions must be enabled on each alarm or AppConfig will not roll back.

4. One seam that fails closed

The Lambda function runs the AWS AppConfig Agent extension as a layer. Terraform reads the latest layer ARN from a public SSM parameter on every plan. The extension polls AppConfig every 15 seconds and serves cached flags on localhost, so reading a flag is a local HTTP call rather than an AWS API call. The handler in src/app.py reads the flag once:

def handler(event, context=None):
    try:
        ticket = Ticket.from_event(event)
    except InvalidTicket as exc:
        return {"error": str(exc)}

    legacy = score_legacy(ticket)

    if not flag_enabled(FLAG):
        return legacy  # flag off: byte-for-byte the behavior users have today

    v2 = score_v2(ticket)
    emit_metrics(V2Evaluated=1, PriorityDisagreement=1 if disagrees(legacy, v2) else 0)
    return {**legacy, "v2": v2}

Four habits keep this safe. The flag is read in exactly one place. Any failure, including the extension being absent, means off. The v2 result sits beside the legacy fields instead of replacing them. And every v2 evaluation emits a PriorityDisagreement metric through CloudWatch Embedded Metric Format, which is the business signal the second alarm watches. Error rate and latency catch crashes; only a comparison between new and legacy output catches a rule that is quietly wrong.

Analytical view · timeline

AI-DLC Meets Brownfield: Shipping AI-Built Changes Without Breaking Production

When can new behavior reach users, and where can an alarm or a person reverse it?

DEPLOYROLLOUT WINDOWFLAG RETIRED
01
Code deployed darkflag off · flag-off tests green
02
Release owner enables flagrollout.py · gradual strategy
HUMAN GATE
03
20% more every 4 minutesboth alarms watch each step
04
10-minute bakeerrors · priority disagreement
AUTO ROLLBACK
05
Flag and legacy path removedafter the new rule is accepted
The release timeline separates the code deploy from the human release decision and marks where an alarm or a person can reverse it.

5. A rule that keeps the agent honest

AI-DLC accepts team rules alongside the ones it ships. This short rule, kept in the repository next to the workflow's own rules, makes every generated plan and diff follow the pattern. The last line matters most: the agent can write the flag, but it never flips it.

# Brownfield release rule (team extension)

- Any change that alters user-visible behavior, outputs or stored data MUST be
  gated by an AWS AppConfig feature flag that defaults to disabled.
- Read the flag once, at the unit's entry point. Do not scatter flag checks.
- On flag-read failure, fall back to the legacy path.
- New outputs are additive. Never overwrite legacy fields while the flag exists.
- Every unit of work lists: flag name, owner, default, rollout plan, removal date.
- Tests MUST cover both flag states. The flag-off suite is a required CI check.
- Never change a flag value or deployment from the agent session.
  Flag rollouts are human decisions.

6. Deploy it in your own AWS account

The complete project lives in CK_Docs/blog/ai-dlc-meets-brownfield, and every step is a make target. You need Terraform 1.5 or later (or OpenTofu), Python 3.13, AWS CLI v2, GNU Make, and credentials for an account you are allowed to experiment in. Everything deploys to us-east-1 unless you pass another Region. Plan on about an hour, most of it waiting for the gradual rollout.

git clone https://github.com/ckoredla/CK_Docs.git
cd CK_Docs/blog/ai-dlc-meets-brownfield
make setup          # Python venv + terraform init
make test           # 54 tests, no AWS account needed
make deploy         # terraform apply: 16 resources, flag OFF
make invoke         # legacy priority only
make enable         # you, the release owner: gradual rollout
make rollback-demo  # force the business alarm, watch AppConfig roll back
make destroy        # remove everything

With the flag off, a standard-tier ticket for a full outage affecting 250 users still lands in the P3 queue. After the rollout completes, the same request returns a v2 block that moves it to P1, beside the unchanged legacy fields. Turning the flag off uses an immediate strategy with no bake time. That is deliberate: AppConfig runs one deployment per environment at a time, and a 10-minute bake on the way down, like the predefined AllAtOnce strategy has, would block the next rollout. The project README includes a troubleshooting table and a six-step guide for adopting the same seam, tests, alarms, and agent rule in your own service.

7. Lessons and anti-patterns

The reverse-engineering review is the highest-leverage meeting on a brownfield project, because the agent's model of a legacy system is confident and partly wrong. Write the must-not-change list before the agent writes code; without it, "no regressions" is a feeling. Treat flags as a design input rather than a deployment trick: named in the requirements, they produce one clean seam, while flags bolted on afterwards scatter conditionals across files. Remember that AppConfig rolls out per configuration fetch, not per user, so 20 percent of a deployment does not mean 20 percent of people.

The common failures mirror those lessons. An agent that edits legacy code in place makes every deploy a release with no fast way back. New logic that overwrites stored fields cannot be undone by rolling back the flag. A suite with only flag-on tests cannot prove that a deploy was a no-op. An agent session that can deploy configuration removes the very human gate the pattern exists to create. And flags that never die leave two code paths forever; put the removal date in the requirement.

Editorial note

This article is independent engineering analysis. The Support Ticket Priority use case, its data, and its thresholds are generic examples written for this article and do not describe any employer's or customer's systems. AWS services are illustrative choices, not endorsements or requirements. Opinions are the author's own.

Sources