polymatic.art – Daniel Pakos

blending science, technology and art

Tag: C4 mcp

  • Architecture Guardrails in Agentic SDLC

    Architecture Guardrails in Agentic SDLC

    Engineering challenges in Agentic SDLC 

    Working with AI coding agents like Claude Code, Cursor or Antigravity and integrating them into the software development lifecycle has fundamentally changed how teams build applications. While it eliminates the bottleneck of raw typing speed, it shifts the engineering challenge away from syntax and toward systems design, context management, and orchestration.

    A common developer challenge is constantly providing an accurate, sufficiently complete, and concise context to coding agents for any new development task. The core of this challenge lies in striking a delicate balance. On one hand, you must feed the agent rich, highly specific context – relevant codebase snippets, business rules written in natural language, and up-to-date documentation – so it truly understands the problem space. On the other hand, you must be deliberately concise. Overloading an AI with unnecessary information not only blurs its focus and invites hallucinations, but it also rapidly inflates token consumption and operational costs. Today’s critical engineering skill is the curation of context: providing exactly enough information to guide the AI, without wasting resources.

    Architecture as the first source of truth 

    To manage this context effectively, the role of the software architect becomes the definitive anchor point of the project. Architects serve as the vital bridge between business stakeholders and the development ecosystem; their primary responsibility is translating abstract business objectives into concrete technical constraints.

    In the development hierarchy, architects sit as the principle of defining what must be built and how the system should behave. Their architectural designs, technical definitions, and established patterns act as the absolute source of truth. By explicitly mapping out the boundaries, dependencies, and rules of the system, architects lay down the essential guardrails that keep both human engineers and AI agents aligned, focused on standards, and moving in the right direction.

    Architecture as a universal language 

    However, for these architectural guardrails to be effective, they cannot exist solely as dense technical jargon. Architects must communicate using a universal language – one that resonates seamlessly with both technical execution teams and non-technical business leaders. When everyone shares the same mental model of the system, misalignment is caught before a single line of code is generated.

    A perfect example of this in practice is the C4 model for visualizing software architecture. Its universalities lie in its accessible, top-down approach. The first two layers of C4 – the System Context and Container diagrams – manage to map out highly technical structural boundaries while remaining inherently self-explanatory. A business stakeholder can look at a System or Container Context diagram and instantly grasp how users interact with the platform, while a developer and AI agent can look from high-level System to low-level Code diagram and immediately understand responsibilities of systems, services, applications, APIs, and databases involved.

    Architecture as guardrails for coding agents 

    When deploying coding agents across complex, distributed environments – such as microservices or serverless architectures – the risk of architectural drift multiplies. AI agents are highly capable problem solvers, but without strict boundaries, they may inadvertently introduce tight coupling, bypass established APIs, or invent rogue design patterns to complete a task.

    This is where standardized, universal methods like the C4 model transition from being simple documentation to active operational guardrails. By providing a clear, structural contract, architects define the exact “blast radius” in which an AI agent is permitted to operate. The agent knows precisely which services it can interact with and which databases are off-limits. Furthermore, this standardization is crucial for engineering collaboration. When multiple human engineers and autonomous agents are contributing simultaneously across a sprawling codebase, universally understood architectural boundaries prevent conflicts. They ensure that both human and machine contributors respect the same integration points, interface definitions, and domain logic, keeping the entire project cohesive.

    C4 as architectural guardrails – a practical approach 

    While the C4 model is a phenomenal tool for human alignment, traditional visual diagrams are not inherently AI-native. Feeding high-resolution images of your architecture into an LLM for every prompt is prohibitively expensive, slow, and highly inefficient in terms of token usage. For a coding agent to consume these guardrails practically, the architecture must be represented as structured text.

    Converting C4 models into Markdown-based Mermaid diagrams is the ideal solution, offering a lightweight, highly readable format tailored for AI consumption. To integrate this efficiently into the SDLC, teams should leverage the Model Context Protocol (MCP). MCP provides a standardized way to connect AI models to additional data sources, allowing agents to dynamically query and retrieve only the architectural context they need for a specific task, exactly when they need it.
    Tools like diag2md-mcp can be utilized to bridge this gap, translating raw Draw.io (diagrams.net) files into AI-readable Markdown (Mermaid) text on the fly.

    To support this at scale, project repositories must be structured deliberately. Rather than maintaining a monolithic, enterprise-wide documentation hub that might overwhelm the agent’s context window, repositories should be strictly scoped. High-level System and Container diagrams should be placed in the root of the projects. However each microservice or application should maintain its own localized /docs directory. By storing the raw, text-based diagram files alongside the generated images within these specific folders, you guarantee that the coding agent automatically absorbs the precise, localized architectural constraints of the domain it is working on, without wasting tokens on the rest of the system.