# Factory-as-code

> The software factory’s entire configuration lives in versioned files: agents, models, secrets, tools, automations, metrics. You review it, test it and roll it back like infrastructure code.

The idea is infrastructure as code, Terraform-style. A factory file defines the agents: instructions, skills, MCP servers, model choice. It also describes the machines they run on, the product repositories, the triggers, the integrations and the measurement tools. The format matters little as long as every change is versioned.

The first gain is centralization. People stop tuning their own machines in isolation: the team shares one model selection, one definition of secrets and tools, one dashboard. An engineer who finds an improvement offers it to everyone as a reviewed change.

The second gain is measurement, which needs a code definition. With a versioned configuration, you can compare two versions, test a variant and restore an earlier one. Agents can propose changes themselves, based on feedback or benchmarks.

The same logic applies inside the repository. The instructions file, skills, subagents, hooks and settings are committed. Code owners review them, and an evaluation suite tests them on every change.

**When**: As soon as several people use agents, each with their own local settings.

**Trade-offs**: People give up some personal tuning, and the configuration needs named owners. In return, one improvement benefits the whole team.

## Where to start

- Inventory each developer’s local settings
- Gather them in a shared repository
- Run every change through the evaluations, then through review matched to its risk
- Rerun evaluations on every configuration change

## Common mistakes

- Storing secrets in plain text in versioned files
- Changing the configuration without measuring the effect
- Letting local settings bypass the shared configuration

## Metrics

- Evaluation pass rate before and after each change
- Number of configuration rollbacks

## Sources

- [Warp, The Factory Stack](https://www.warp.dev/blog/the-factory-stack)
- [Warp, 7 core components for building a software factory](https://www.warp.dev/blog/7-ways-to-build-a-software-factory)
- [Anthropic, The AI-native SDLC playbook](https://claude.com/fr/resources/articles/the-ai-native-sdlc-playbook)
