The MCAF Guide

Managed Code Coding AI Framework

Developed and sustained by Managed Code
December 2025

18 min read


1. What MCAF Is

MCAF is a framework for building software products together with AI coding agents.

It defines how to:

The goal of MCAF:

Use AI to build real products in a way that is predictable, safe, and repeatable.

MCAF has three core elements:

This Guide defines the framework.
The root AGENTS.md in each repository applies it to that codebase.

2. Context

Context is everything needed to understand, change, and run the system.
MCAF requires that humans and agents work from the same context stored in the repository.

2.1 Definition

In MCAF, repository context includes:

Anything that matters for development, testing, or operations lives in the repository.

2.2 Documentation layout

A typical docs/ layout:

This structure is a reference. A repository may adapt directory names, but keeps clear places for features, decisions, testing, development, and operations.

2.3 Feature docs

Each non-trivial feature has a document under docs/Features/ that includes:

Feature docs are written precisely enough that:

2.4 Linking and references

Documentation links to:

Links make it easy to navigate:

2.5 Hard rules for Context

3. Verification

Verification is how the team proves that behaviour and code quality meet expectations.
Under MCAF, tests and static analysis are the main decision makers.

3.1 Test levels and coverage

MCAF uses several levels of tests:

Coverage expectations:

Code coverage:

Test quality:

Tests cover:

3.2 Containerized environments

Integration/API/UI tests run against reproducible infrastructure.

If an internal dependency cannot reasonably run in a test container or local instance, this is treated and documented as an architectural smell.

3.3 Static analysis

Static analyzers and linters enforce a consistent baseline of code quality.

New code does not introduce new violations without explicit justification and review.
Recurring analyzer issues (unsafe APIs, bad patterns) lead to updates in AGENTS.md and/or ADRs.

3.4 External dependencies, mocks, and fakes

Mocks and fakes are strongly restricted in MCAF.

For internal systems (databases, queues, caches, internal services):

For external third-party systems (payment gateways, SMS providers, external APIs):

When using fakes or mocks for external systems:

Over-use of mocks is treated as a test smell and triggers refactoring or revisiting architecture and test strategy.

3.5 Hard rules for Verification

4. Instructions and AGENTS.md

Instructions define how AI coding agents behave in the repository and how they learn over time.
They live primarily in AGENTS.md.

4.1 Role of AGENTS.md

The root AGENTS.md sits next to this Guide in the repository.

It defines:

This Guide defines the framework.
The root AGENTS.md applies it to this repository.

4.2 Required content of AGENTS.md

In a repository that uses MCAF, the root AGENTS.md stays up to date with:

Local AGENTS.md files in subdirectories refine these rules for specific areas when needed.

4.3 Self-learning

AGENTS.md describes how agents:

Feedback categories:

Conversations are not memory. Stable patterns are written into AGENTS.md or docs.

4.4 Commands

AGENTS.md lists the canonical commands for this repository, for example:

Agents and automation use these commands instead of ad-hoc command sequences.

4.5 Local AGENTS.md

In large repositories, directories may have their own AGENTS.md files. They:

4.6 AGENTS.md governance

AGENTS.md is a critical document that shapes how AI agents work in the repository. Changes to it affect all future AI-assisted development.

Change approval:

Review criteria for AGENTS.md changes:

4.7 Hard rules for Instructions

5. Coding and Testability

Coding rules in MCAF exist to make integration/API/UI tests and static analysis effective and sustainable.

5.1 Purpose

Code structure and style:

5.2 Constants and configuration

Meaningful literals are not scattered through the codebase.

Examples:

Values like these:

5.3 Structure and testability

Code structure serves integration/API/UI tests:

When a test is hard or impossible to write for a piece of behaviour, this is treated as a design problem to solve, not a reason to skip tests.

5.4 Relationship to mocks and fakes

Mocks and fakes follow the rules in the Verification section:

Coding patterns that rely heavily on mocking internal services are treated as design smells and reworked.

5.5 Hard rules for Coding and Testability

6. Perspectives

MCAF describes responsibilities using four perspectives. One person may play several perspectives at once.
Titles do not matter; responsibilities do.

6.1 Product

Accountable for what the system does and why.

Responsibilities:

6.2 Dev

Accountable for how the system is built.

Responsibilities:

6.3 QA

Accountable for how behaviour is verified.

Responsibilities:

6.4 AI Agent

Accountable for generation and adaptation within the rules.

Responsibilities:

The AI Agent does not approve or merge changes.
Human maintainers make the final decision.

7. Development Cycle

The development cycle describes how a change moves from idea to merged code under MCAF.
It is built around tests and static analysis, not just “write code”.

7.1 Describe

Before coding:

  1. Product updates or creates feature documentation.
  2. Dev updates or creates ADRs if architecture changes.
  3. QA updates or creates test documentation for the new behaviour.
  4. AI Agent may draft content; humans validate and finalize.

Output:

7.2 Plan

For non-trivial tasks:

  1. Agent proposes a plan that includes:
    • files to change
    • tests to add or update (positive, negative, edge flows, integration/API/UI)
    • docs to modify
  2. Engineer adjusts and accepts the plan.
  3. The plan is recorded (issue, document, or merge request description).

7.3 Implement tests and code

  1. Add or update tests that match the documented test flows, focusing on integration/API/UI where possible.
  2. Implement code until these tests pass.
  3. Keep changes small and reviewable.
  4. Follow coding and testability rules from this Guide and the repository’s AGENTS.md.

In MCAF, tests and code move together; a task is not “almost done” while tests are missing.

7.4 Run tests in layers

Tests run in this order:

  1. New and modified tests for this change.
  2. Related suites for the affected feature/module/service.
  3. Full required test sets for this repository (unit, integration, API, UI/E2E as defined).

Failures at any layer are understood and fixed, not skipped or muted.

7.5 Run static analysis

  1. Run the standard analyze command for this repository.
  2. Review warnings and errors.
  3. Fix violations or explicitly document justified exceptions.
  4. Re-run targeted tests if fixes touched behaviour.

A task is not ready until tests and analyzers both pass.

7.6 Update docs and AGENTS.md

After implementation and verification:

  1. Feature docs are updated so they reflect actual behaviour and edge cases.
  2. Test docs are updated so they match real test coverage and flows.
  3. If the work revealed new stable patterns or errors:
    • AGENTS.md is updated with new rules or clarifications
    • ADRs are updated if architecture or standards changed

Docs and AGENTS.md describe the system that actually exists.

7.7 Review and merge

Humans review:

A change is merged when:

The AI Agent prepares and updates code, tests, and docs.
Maintainers own the final merge decision.

8. AI Participation Modes

For each task, the team chooses how the AI Agent participates.

8.1 Delegated

The agent performs most of the development cycle:

Humans review and decide on merge.

Used for:

8.2 Collaborative

The agent and humans work closely throughout the task:

Used for:

8.3 Consultative

The agent focuses on analysis and explanation:

Humans implement code and tests.

Used for:

9. Adopting MCAF in a Repository

To adopt MCAF in a repository:

  1. A docs/ directory exists with at least Features/, ADR/, Testing, and Development.
  2. This Guide and a root AGENTS.md live at the repository root and are kept current.
  3. Commands for build, test, format, and analyze are defined and documented.
  4. Containerized or scripted environments exist for integration/API/UI tests.
  5. Static analyzers are configured and treated as part of the Definition of Done.
  6. Meaningful changes follow the MCAF development cycle:
    • docs first
    • explicit plan
    • tests and code together
    • layered test runs
    • static analysis
    • updated docs and AGENTS.md
    • human review and merge

MCAF is considered active only when these practices are followed in day-to-day work, not just written down.

10. Ownership and Process

10.1 Ownership

Every significant feature, document, and decision has an accountable owner:

10.2 Process