Welcome to The Foundry.
The Foundry is a User Friendly - Enterprise Ready Multi-Agent System (MAS) bootstrapping framework.
This repository is not just a codebase; it is a living, autonomous governance environment designed to orchestrate multiple specialized AI agents (Architect, Backend, Frontend, DevOps, QA, etc.) to build complex software projects entirely from scratch.
We built The Foundry to solve the most critical failure points of modern AI coding (token amnesia, infinite loops, architectural drift, and agent collisions). It implements a rigorous "Policy-as-Code" and "Pull-Based" governance model, while remaining completely frictionless for the end-user.
- The Problem: Centralized orchestrator agents pushing tasks to developers often lose context, hallucinate file paths, or spam the chat.
- The Decision: We implemented a Pull Model. Agents read their own queues in
.agent/tasks/. If they run out of work, they must file a formal TOML request asking the@architectfor the next ticket. - Why: This decouples execution from planning, turning the
.agentdirectory into a highly resilient, asynchronous Event Bus.
- The Problem: Agents work in isolation ("black boxes"). They overwrite each other's code and don't know who is waiting for whom.
- The Decision: All agents are constitutionally required to update
.agent/team_status.mdwhen they start, pause, or finish a task. - Why: This provides Shared Team Awareness. If an agent is blocked, human users or peer agents can instantly see the bottleneck on the board.
- The Problem: Passing a massive
spec.mdto an agent to fix a tiny CSS bug causes "Context Rot", wastes tokens, and confuses the LLM. - The Decision: Zero Global Spec Reading. Agents only read a localized
.agent-context.mdfile located exactly in the sub-folder they are editing. - Why: This enforces maximum efficiency, keeping the LLM laser-focused on the immediate code boundaries.
- The Problem: Agents get trapped in loops trying to fix a failing test, burning thousands of tokens and never succeeding.
- The Decision: A strict budget of 5 iterations per loop. On the 5th failure, the agent MUST halt and update its status to
🔴 BLOCKED. - Why: Prevents runaway compute costs and forces the system to escalate complex, unresolvable issues to humans or senior agents.
- The Problem: Agents talking to each other using JSON often hallucinate trailing commas or invalid syntax, breaking the pipeline.
- The Decision: All Agent-to-Agent (A2A) requests use a strict template at
.agent/requests/_change_request_template.toml. - Why: TOML is highly fault-tolerant and easily readable by both machines and humans, ensuring zero-error communication.
- The Problem: Having the Product Manager (
@pm) modify system configuration files breaks the Principle of Least Privilege. - The Decision: We introduced
@bootstrapper, an agent that configures the project in a single command and then permanently deletes its own source code. - Why: Provides a magical 1-click onboarding experience while leaving the repository 100% secure and surgically clean for the permanent team.
Every file in this repository has a specific purpose. There is no bloat.
The Constitution. Immutable rules for all agents. Contains the project domain, tech stack, and explicitly forbidden actions. All agents read this file.
Contains the Agent Cards (*.agent-card.json). These define the personality, constraints, and physical write permissions (ownership) of each agent (e.g. @frontend, @backend).
The autonomous nervous system of the repository.
rules/: Global behavioral logic (e.g. context-scoping, concurrency).skills/: The procedural workflows for agents (e.g.agent-work-loop.mdfor the main loop,project-inception.mdfor the bootstrapper).tasks/: Physical Markdown tickets created by the@architectfor the developers to pull.requests/: Cross-domain TOML change requests (Agent-to-Agent communication). Includes_change_request_template.toml.team_status.md: The real-time Kanban board where agents report their current status.
Strategic documentation.
roadmap.md: The Master Epic/Sprint plan managed by@architect.brief.md: The executive summary of the business vision managed by@pm.adrs/: Architecture Decision Records.
Automated quality rubrics used by @qa to verify code against business requirements before deployment.
The Foundry comes pre-configured with a specialized team. Each agent has its own agent-card.json dictating its exact permissions and boundaries.
- 🏗️
@bootstrapper: Ephemeral SysAdmin. Clones, configures, and self-destructs. - 📊
@pm: Product Manager. Interviews you to define the MVP, user stories, and writesbrief.md. Forbidden from touching code. - 🏛️
@architect: Enterprise Architect. Designs data models, scopes technical context, and generates physical task tickets for the developers. - 💻
@frontend&@backend: Software Engineers. They pull their tasks from the Kanban board and write code in their specific folders. - 🛡️
@qa: Quality Assurance. Evaluates code against Acceptance Criteria inevals/. - ⚙️
@devops: Infrastructure Manager. Manages Docker, CI/CD, and deployments. - 👮
@api-steward: API Guardian. Ensures OpenAPI contracts are not broken between frontend and backend.
Agents are equipped with physical Markdown "skills" (Standard Operating Procedures):
agent-work-loop.md: The core autonomous execution loop every agent follows.plan-epic.md: The Architect's process to decompose business requirements into physical tickets.manage-context-budget.md: Forces agents to strictly manage their token windows.
Running multi-agent systems can get incredibly expensive if agents are allowed to "think globally" on every prompt. The Foundry is engineered for strict FinOps:
- Just-In-Time (JIT) Context: Developers are constitutionally forbidden from reading the massive global
docs/spec.md. The Architect extracts only the tiny pieces they need and creates localized.agent-context.mdfiles. This saves millions of input tokens per project. - 5-Step Execution Budgets: To prevent agents from getting stuck in infinite debugging loops (which burn tokens exponentially), The Foundry enforces a strict 5-attempt limit. On the 5th failure, the agent must halt and request human intervention.
- Chat is for Handoffs, not Code: Instead of pasting thousands of lines of code into the chat UI (which wastes context window), agents write physical tickets and code directly to the file system.
Anyone can download this framework and use it to build their own software project in a single, frictionless step:
Copy and paste this exact prompt into your AI Agent (Antigravity, Cursor, Claude, etc.):
Clone https://github.com/aavilagallego/TheFoundry and execute start.md
The magic of The Foundry is that you don't orchestrate agents manually; they pass the baton to each other autonomously. When you run the Magic Prompt, you trigger a chain reaction:
-
🏗️ Phase 1: Physical Setup (
@bootstrapper) The AI adopts the SysAdmin persona. It asks for your Tech Stack, configures the repository's rules (AGENTS.md), assigns folder permissions, and then permanently deletes its own source code for security. Finally, it gives you a prompt to wake up the PM. -
📊 Phase 2: Product Definition (
@pm) The AI switches to the Product Manager persona. It interviews you purely about the business logic to define your MVP scope, creating yourdocs/brief.mdanddocs/roadmap.md. It then gives you a prompt to wake up the Architect. -
🏛️ Phase 3: Tech Scaffolding (
@architect) The Architect takes over. It reads the PM's roadmap, establishes the technical directories, and extracts tiny pieces of context for the developers (to prevent token exhaustion). It generates physical Markdown task tickets. -
💻 Phase 4: Isolated Execution (
@frontend/@backend) Your developer agents wake up, read their isolated task tickets from the Kanban board, and start writing code. If they fail a test 5 times, they hit their "Step Budget" and halt to prevent infinite loops.
Once the @bootstrapper vanishes in Phase 1, your Enterprise MAS is perfectly governed, alive, and ready for production.
Building and managing autonomous AI ecosystems can be challenging. If you need help with your Agent Development, custom workflows, or enterprise implementations, drop me a line.
📧 Contact: aavilagallego@gmail.com
Built for the future of autonomous, scalable, and human-aligned AI software engineering.