# How the AI-DLC Extension System Manages Opt-In Mechanisms for Testing Rules

> Learn how the AI-DLC extension system manages opt-in mechanisms. It uses markdown files and aidlc-state to conditionally import testing rules, ensuring specific tests are enabled only when you choose.

- Repository: [Amazon Web Services - Labs/aidlc-workflows](https://github.com/awslabs/aidlc-workflows)
- Tags: how-to-guide
- Published: 2026-05-09

---

**The AI-DLC extension system manages opt-in mechanisms through markdown-based `*.opt-in.md` files that inject clarifying questions during Requirements Analysis, storing user responses in the **aidlc-state** to conditionally import associated testing rule files only when explicitly enabled.**

The AI-Driven Development Life-Cycle (AI-DLC) framework, maintained in the `awslabs/aidlc-workflows` repository, treats each extension as a self-contained rule set governing specific testing paradigms like Property-Based Testing or Security Baselines. According to the source code, the system implements a declarative opt-in mechanism that ensures testing rules are only enforced when project stakeholders explicitly activate them during the Requirements Analysis phase. This design leverages standardized markdown prompt files and state-driven conditional imports to manage testing rule activation dynamically.

## The Opt-In Prompt File Structure

Every extension within the `aidlc-rules/aws-aidlc-rule-details/extensions/` directory ships with an accompanying `*.opt-in.md` file that defines the clarifying question presented to users. These files follow a consistent schema containing a short header, the markdown-formatted question, optional answer tags, and a reference to the actual rule definition file. For example, the Property-Based Testing extension includes [`property-based-testing.opt-in.md`](https://github.com/awslabs/aidlc-workflows/blob/main/property-based-testing.opt-in.md) in `extensions/testing/property-based/`, while the Security Baseline extension provides [`security-baseline.opt-in.md`](https://github.com/awslabs/aidlc-workflows/blob/main/security-baseline.opt-in.md) in `extensions/security/baseline/`.

## Automatic Injection During Requirements Analysis

When the workflow reaches the Requirements Analysis phase, specifically the "Clarifying Questions" step, the evaluator scans the extensions directory to discover all available `*.opt-in.md` files. The core logic, implemented in [`requirements_analysis.py`](https://github.com/awslabs/aidlc-workflows/blob/main/requirements_analysis.py), loads each prompt file and appends its contents to the user-facing questionnaire. This automatic discovery ensures that newly added extensions appear immediately in the workflow without requiring manual registration or custom code changes.

```python

# Core evaluator logic (requirements_analysis.py)

def load_opt_in_prompts():
    prompts = []
    for opt_file in glob("aidlc-rules/aws-aidlc-rule-details/extensions/**/*.opt-in.md"):
        prompts.append(read(opt_file))
    return "\n".join(prompts)

def inject_prompts(state):
    # Append the combined opt‑in prompts to the questionnaire

    state['clarifying_questions'] += load_opt_in_prompts()
    return state

```

## State-Driven Activation Logic

User responses to the injected prompts are recorded in the generated **aidlc-state**, which drives the conditional import of corresponding extension rule files. The system maps specific answers—such as "Yes" (A), "Partial" (B), or "No" (C/X)—to distinct rule subsets via the `apply_extension()` function. If the user selects an option indicating activation, the extension's rules are merged into the **Constraints** and **Testing** sections of the AI-DLC documentation; otherwise, the rules remain omitted from the project state.

```python
def apply_extension(state, answer):
    # Example for Property-Based Testing

    if answer.startswith("A"):
        # Load full PBT rule set

        state['rules'].extend(read("property-based-testing.md"))
    elif answer.startswith("B"):
        # Load only pure‑function subset

        state['rules'].extend(read("property-based-testing-pure.md"))
    # "C" or "X" results in no rule import

    return state

```

## Granular Control and Rule Subsets

Extensions can expose multiple granularity levels within their opt-in prompts, allowing users to enable only applicable subsets of rules rather than accepting the entire extension. For instance, selecting "Partial" might activate Property-Based Testing exclusively for pure functions while excluding stateful or IO-bound operations. This granular control is interpreted by the workflow logic to load specific rule variants, such as [`property-based-testing-pure.md`](https://github.com/awslabs/aidlc-workflows/blob/main/property-based-testing-pure.md) instead of the full [`property-based-testing.md`](https://github.com/awslabs/aidlc-workflows/blob/main/property-based-testing.md) definition.

## Standardized Schema for Extensibility

All opt-in files adhere to a uniform schema that enables the core workflow engine to treat any new extension identically, eliminating the need for custom activation code. This consistency means that contributors can add new testing capabilities—such as performance thresholds or compliance checks—by simply creating the standard `*.opt-in.md` and rule files in the appropriate subdirectory. The evaluator automatically discovers and processes these extensions according to the same lifecycle: discovery, prompt injection, response recording, and conditional rule import.

## Summary

- **Markdown-based opt-in files**: Each extension includes an `*.opt-in.md` file containing clarifying questions that appear during Requirements Analysis.
- **Automatic discovery**: The evaluator in [`requirements_analysis.py`](https://github.com/awslabs/aidlc-workflows/blob/main/requirements_analysis.py) scans `aidlc-rules/aws-aidlc-rule-details/extensions/` to load prompts without manual registration.
- **State-driven activation**: User responses stored in **aidlc-state** determine whether corresponding `*.md` rule files are imported into the project.
- **Granular control**: Extensions support multiple activation levels (Yes/Partial/No) allowing selective rule subsets like [`property-based-testing-pure.md`](https://github.com/awslabs/aidlc-workflows/blob/main/property-based-testing-pure.md) to be enabled.
- **Standardized schema**: Uniform file structure ensures new extensions integrate seamlessly with existing opt-in infrastructure.

## Frequently Asked Questions

### What is an opt-in file in the AI-DLC extension system?

An opt-in file is a markdown document with the [`.opt-in.md`](https://github.com/awslabs/aidlc-workflows/blob/main/.opt-in.md) extension that resides in the extension's directory and defines a clarifying question presented to users during the Requirements Analysis phase. It serves as the entry point for extension activation, containing the question text, acceptable answer options, and references to the actual rule definitions that become active upon user consent.

### How does the system handle partial opt-in responses?

When a user selects a "Partial" option (typically mapped to "B" in the state), the `apply_extension()` function imports only a designated subset of rules rather than the complete extension. For example, the Property-Based Testing extension might load rules exclusively for pure functions while excluding stateful components or side-effect operations from enforcement.

### Where are extension rules stored in the repository?

Extension rules are stored within `aidlc-rules/aws-aidlc-rule-details/extensions/`, organized by category subdirectories such as `testing/property-based/` or `security/baseline/`. Each extension directory contains both the opt-in prompt file (e.g., [`property-based-testing.opt-in.md`](https://github.com/awslabs/aidlc-workflows/blob/main/property-based-testing.opt-in.md)) and the rule definitions (e.g., [`property-based-testing.md`](https://github.com/awslabs/aidlc-workflows/blob/main/property-based-testing.md) or [`security-baseline.md`](https://github.com/awslabs/aidlc-workflows/blob/main/security-baseline.md)).

### Can custom extensions leverage the existing opt-in mechanism?

Yes, custom extensions can utilize the same opt-in infrastructure by following the standardized schema: creating an `*.opt-in.md` file with the required clarifying question and placing the corresponding rule files in a subdirectory under `extensions/`. The core evaluator automatically discovers and processes these files without requiring modifications to the workflow engine, ensuring immediate integration.