explaingit

humanlayer/12-factor-agents

Analysis updated 2026-06-21

19,788TypeScriptAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A practical guide proposing twelve engineering principles for building reliable AI agents that work in production, treating them as conventional software with targeted AI steps, not fully autonomous loops.

Mindmap

mindmap
  root((repo))
    What It Does
      Production AI guide
      12 engineering principles
      Avoid LLM pitfalls
    Tech Stack
      TypeScript
      Markdown docs
    Use Cases
      LLM product design
      Agent architecture
      Human oversight
    Key Principles
      Own your prompts
      Stateless agents
      Human contact tool
    Audience
      Developers
      AI founders
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Apply the 12 factors to audit your LLM agent and fix common architectural mistakes before deploying to real customers.

USE CASE 2

Use Factor 7 to add a human-approval checkpoint so your agent pauses and asks for help when it hits uncertainty instead of guessing.

USE CASE 3

Restructure a chaotic LLM pipeline by making each agent stateless and versioning your prompt templates in git.

USE CASE 4

Build a customer support bot that contacts a human via a tool call when confidence is low rather than hallucinating an answer.

What is it built with?

TypeScriptMarkdown

How does it compare?

humanlayer/12-factor-agentsinfinitered/ignitekortix-ai/suna
Stars19,78819,78319,754
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasymoderatemoderate
Complexity2/53/54/5
Audiencedeveloperdeveloperpm founder

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min
Code is Apache 2.0 (use freely for any purpose including commercially, keep the license notice), content is CC BY-SA 4.0 (share with attribution under the same license).

In plain English

12-Factor Agents is a guide, modeled after the well-known "12 Factor App" methodology for web applications, that proposes twelve concrete engineering principles for building AI-powered software that is reliable enough to deploy to real production customers. The core argument is that most successful AI agent products are not fully autonomous loops of an LLM calling tools until something works, they are mostly conventional software with AI steps embedded at precisely the right moments. The twelve factors cover the full lifecycle of building a production-grade AI agent. Several focus on controlling how information flows into the language model: own your prompts (write and version them yourself rather than relying on framework defaults), own your context window (carefully curate what the model sees rather than feeding it everything), and compact errors back into context rather than crashing. Others address architecture: keep agents small and focused on a single task, make agents stateless so they can be paused and resumed like a pure function, and treat tool calls as structured data outputs rather than magical actions. Factor 7 specifically addresses human oversight, designing the agent to contact a human through a tool call when it encounters uncertainty, rather than guessing. A developer or founder building LLM-powered features into a product, whether a coding assistant, customer support bot, or workflow automation, would use this guide to avoid common pitfalls and architectural dead ends. The content lives in Markdown files in the repository and the code examples are in TypeScript. It is published under Apache 2.0 (code) and Creative Commons BY-SA 4.0 (content).

Copy-paste prompts

Prompt 1
I'm building an LLM-powered workflow automation. Using the 12-factor-agents principles, review this agent design and tell me which factors I'm violating and how to fix them: [paste design].
Prompt 2
Help me refactor this agent code to follow Factor 5 (stateless agents) so it can be paused and resumed like a pure function: [paste code].
Prompt 3
Write a tool definition for my invoice-approval agent that implements Factor 7, it calls a human when a decision exceeds a risk threshold.
Prompt 4
Using the 12-factor-agents guide, design a prompt management system that versions my LLM prompts in git alongside application code.
Prompt 5
My agent crashes when tools return errors. Based on the compact-errors-into-context principle, rewrite this error-handling block: [paste code].

Frequently asked questions

What is 12-factor-agents?

A practical guide proposing twelve engineering principles for building reliable AI agents that work in production, treating them as conventional software with targeted AI steps, not fully autonomous loops.

What language is 12-factor-agents written in?

Mainly TypeScript. The stack also includes TypeScript, Markdown.

What license does 12-factor-agents use?

Code is Apache 2.0 (use freely for any purpose including commercially, keep the license notice), content is CC BY-SA 4.0 (share with attribution under the same license).

How hard is 12-factor-agents to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is 12-factor-agents for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub humanlayer on gitmyhub

Verify against the repo before relying on details.