12-Factor Agent Design and Review
Use the 12-Factor Agents principles as an engineering lens, not a certification
checklist. The goal is to expose reliability decisions, evidence, and tradeoffs
for LLM-powered software while keeping deterministic code in charge wherever it
can decide safely and repeatably.
Select the mode
- Design — the user is planning a new LLM workflow or agentic feature.
- Review — code or a design/spec already exists and the user wants findings.
- Mixed — review the current system first, then design a target architecture.
If the request is ambiguous, infer the mode from available artifacts. Existing
code or a concrete spec implies Review; a desired outcome with no implementation
implies Design. State the selected mode in the output.
Scope boundaries
This skill covers application architecture: prompts, context construction,
structured model outputs, deterministic execution, state, control flow,
pause/resume, humans, retries, triggers, and replayability.
It does not replace security threat modeling, model evaluation, observability
instrumentation, performance profiling, or a framework-specific implementation
guide. Surface those as follow-up work when relevant instead of pretending the
factor review completed them.
Load references deliberately
Read references/factors.md before doing a detailed
Design, Review, or Mixed analysis. It defines the factor intent, useful evidence,
and common misreadings. Factor 13 is an appendix/bonus idea, not one of the
canonical twelve.
Read references/extensions.md only when one of these
conditions applies:
- deeper code-search or evidence-gate guidance is needed;
- the system has enterprise audit, idempotency, or high-risk side effects;
- the user asks about scaffolding, observability, evals, or failure-mode catalogs;
- comparing this workflow with existing 12-factor-agent skills would help.
Shared workflow
1. Establish the system boundary
Identify:
- the user-visible outcome and explicit non-goals;
- every trigger and the canonical event it becomes;
- decisions that genuinely require language-model judgment;
- deterministic validation, policy, routing, and side effects;
- irreversible or high-impact operations;
- persistence, human response, timeout, retry, and recovery boundaries.
Sketch this path before scoring or designing details:
trigger -> canonical event -> state/context builder -> model decision
-> schema/policy validation -> deterministic handler
-> persisted event/state -> response, pause, or next turn
2. Classify factor relevance
Inspect all twelve factors and the Factor 13 appendix, but do not force every
factor into every system.
- Required — omission creates a concrete reliability or safety failure for
the stated workflow.
- Recommended — useful at the expected scale or risk, but not a current
blocker.
- N/A — outside the system boundary; include a one-line reason.
3. Separate observation from proposal
For Review and Mixed mode, observed facts need evidence from the supplied
artifacts. Recommendations are proposals and must be labeled as such.
Acceptable evidence includes:
- a repo-relative
file:line citation;
- an exact config, schema, endpoint, table, or event definition;
- a short excerpt from a supplied design document;
- a captured runtime trace when behavior cannot be proven statically.
If targeted search finds nothing but the inspected scope is incomplete, mark the
factor Unverified, not Gap. Absence supports Gap only after the relevant
entrypoints, state definitions, model boundary, and handlers were inspected.
4. Prioritize by consequence
Use severity independently from factor status:
- Critical — unvalidated model output can directly cause destructive,
financial, security-sensitive, or externally visible effects.
- High — failures cannot be bounded, resumed, reproduced, or audited.
- Medium — reliability degrades under realistic scale, long context, or
partial failure.
- Low — maintainability or clarity improvement with limited current impact.
Do not prioritize by factor number or count of gaps.
Design mode
- Resolve the LLM/code decision boundary before selecting a framework.
- Define typed model outputs and the deterministic handlers they may request.
- Define one durable event/state model that can reconstruct a run.
- Define the owned prompt and context builder inputs; do not prescribe a
template engine unless the system needs one.
- Define launch, pause, resume, timeout, cancellation, and human-response paths.
- Define bounded retry/error compaction and escalation behavior.
- Define how each important transition will be replayed or evaluated.
- Write the result using
assets/design-template.md.
The design must name concrete interfaces and acceptance checks, but should not
invent provider- or framework-specific code unless the user chose that stack.
Review mode
- Locate entrypoints, model calls, prompts/context builders, tool schemas,
handlers, state persistence, retries, human gates, and tests. Prefer
rg and
inspect the cited files rather than relying on keyword counts.
- Pass the scan gate: every in-scope factor has either a path to inspect or a
note describing the targeted search that found no candidate.
- Pass the evidence gate before assigning a status:
- Strong — the principle is implemented coherently for the stated risk.
- Partial — useful implementation exists with a material limitation.
- Gap — sufficient evidence shows a missing or unsafe capability.
- N/A — not relevant, with a reason.
- Unverified — artifacts are insufficient for a defensible judgment.
- Connect each material finding to a user-visible failure mode.
- Recommend the smallest architectural change that closes the risk; do not
default to framework removal or a rewrite.
- Write the result using
assets/review-template.md.
Mixed mode
Complete Review mode first. Preserve confirmed strengths and constraints, then
use Design mode to describe the target state. Every target-state change should
trace back to a review finding, requirement, or explicit future capability.
Validation loop
Before delivering the artifact:
- Check that every verdict has evidence or is marked Unverified.
- Check that every N/A has a reason.
- Check that recommendations are not written as observed facts.
- Check that high-risk side effects have validation, policy/idempotency, and a
human gate when required.
- Check that retries and loops have termination/escalation behavior.
- Check that the proposed state can support resume and replay where required.
- Check that acceptance steps exercise the real model boundary or reducer, not
only syntax and type checks.
Gotchas
- The factors are principles, not a compliance standard. Do not calculate a
percentage score or call a system "12-factor compliant."
- Factor 13 is an appendix. Label pre-fetching as an extension, never as a
canonical thirteenth factor.
- Framework use is not automatically a failure. The relevant question is
whether the team can inspect and control prompts, context, state, and flow.
- Inline prompts are not automatically weak. Ownership, reviewability,
versioning, and testability matter more than file placement or Jinja usage.
- Raw chat messages are not automatically wrong. Flag them when they are
unbounded, stale, unfiltered, or impossible to reproduce.
- "Trigger from anywhere" does not require every channel. It means execution
is decoupled from the current UI and can accept the channels the product needs.
- The 3-10-step guidance is a heuristic. Domain coherence and context growth
matter more than a hard method count.
- Static code cannot prove runtime behavior. Ask for traces or mark the item
Unverified when retries, compaction, resume, or model inputs are dynamic.
Provenance
The canonical methodology is Dexter Horthy / HumanLayer's
12-Factor Agents. This skill's
documentation is an adaptation under CC BY-SA 4.0; see LICENSE.txt.
1---2name: 12-factor-agent-design-review3description: Design and evidence-review LLM systems with HumanLayer's 12-Factor Agents. Use whenever planning or auditing an LLM workflow, agent loop, tool-calling app, framework migration, human approval, or unreliable agent—even without naming the method. Covers LLM/code boundaries, prompts/context, typed tools, durable state, control flow, pause/resume, retries, and replay. Not for Twelve-Factor App deployment, prompt-only edits, model comparisons, generic code review, security-only work, or scaffolding.4---56# 12-Factor Agent Design and Review78Use the 12-Factor Agents principles as an engineering lens, not a certification9checklist. The goal is to expose reliability decisions, evidence, and tradeoffs10for LLM-powered software while keeping deterministic code in charge wherever it11can decide safely and repeatably.1213## Select the mode1415- **Design** — the user is planning a new LLM workflow or agentic feature.16- **Review** — code or a design/spec already exists and the user wants findings.17- **Mixed** — review the current system first, then design a target architecture.1819If the request is ambiguous, infer the mode from available artifacts. Existing20code or a concrete spec implies Review; a desired outcome with no implementation21implies Design. State the selected mode in the output.2223## Scope boundaries2425This skill covers application architecture: prompts, context construction,26structured model outputs, deterministic execution, state, control flow,27pause/resume, humans, retries, triggers, and replayability.2829It does not replace security threat modeling, model evaluation, observability30instrumentation, performance profiling, or a framework-specific implementation31guide. Surface those as follow-up work when relevant instead of pretending the32factor review completed them.3334## Load references deliberately3536Read [references/factors.md](references/factors.md) before doing a detailed37Design, Review, or Mixed analysis. It defines the factor intent, useful evidence,38and common misreadings. Factor 13 is an appendix/bonus idea, not one of the39canonical twelve.4041Read [references/extensions.md](references/extensions.md) only when one of these42conditions applies:4344- deeper code-search or evidence-gate guidance is needed;45- the system has enterprise audit, idempotency, or high-risk side effects;46- the user asks about scaffolding, observability, evals, or failure-mode catalogs;47- comparing this workflow with existing 12-factor-agent skills would help.4849## Shared workflow5051### 1. Establish the system boundary5253Identify:5455- the user-visible outcome and explicit non-goals;56- every trigger and the canonical event it becomes;57- decisions that genuinely require language-model judgment;58- deterministic validation, policy, routing, and side effects;59- irreversible or high-impact operations;60- persistence, human response, timeout, retry, and recovery boundaries.6162Sketch this path before scoring or designing details:6364```text65trigger -> canonical event -> state/context builder -> model decision66 -> schema/policy validation -> deterministic handler67 -> persisted event/state -> response, pause, or next turn68```6970### 2. Classify factor relevance7172Inspect all twelve factors and the Factor 13 appendix, but do not force every73factor into every system.7475- **Required** — omission creates a concrete reliability or safety failure for76 the stated workflow.77- **Recommended** — useful at the expected scale or risk, but not a current78 blocker.79- **N/A** — outside the system boundary; include a one-line reason.8081### 3. Separate observation from proposal8283For Review and Mixed mode, observed facts need evidence from the supplied84artifacts. Recommendations are proposals and must be labeled as such.8586Acceptable evidence includes:8788- a repo-relative `file:line` citation;89- an exact config, schema, endpoint, table, or event definition;90- a short excerpt from a supplied design document;91- a captured runtime trace when behavior cannot be proven statically.9293If targeted search finds nothing but the inspected scope is incomplete, mark the94factor **Unverified**, not Gap. Absence supports **Gap** only after the relevant95entrypoints, state definitions, model boundary, and handlers were inspected.9697### 4. Prioritize by consequence9899Use severity independently from factor status:100101- **Critical** — unvalidated model output can directly cause destructive,102 financial, security-sensitive, or externally visible effects.103- **High** — failures cannot be bounded, resumed, reproduced, or audited.104- **Medium** — reliability degrades under realistic scale, long context, or105 partial failure.106- **Low** — maintainability or clarity improvement with limited current impact.107108Do not prioritize by factor number or count of gaps.109110## Design mode1111121. Resolve the LLM/code decision boundary before selecting a framework.1132. Define typed model outputs and the deterministic handlers they may request.1143. Define one durable event/state model that can reconstruct a run.1154. Define the owned prompt and context builder inputs; do not prescribe a116 template engine unless the system needs one.1175. Define launch, pause, resume, timeout, cancellation, and human-response paths.1186. Define bounded retry/error compaction and escalation behavior.1197. Define how each important transition will be replayed or evaluated.1208. Write the result using121 [assets/design-template.md](assets/design-template.md).122123The design must name concrete interfaces and acceptance checks, but should not124invent provider- or framework-specific code unless the user chose that stack.125126## Review mode1271281. Locate entrypoints, model calls, prompts/context builders, tool schemas,129 handlers, state persistence, retries, human gates, and tests. Prefer `rg` and130 inspect the cited files rather than relying on keyword counts.1312. Pass the scan gate: every in-scope factor has either a path to inspect or a132 note describing the targeted search that found no candidate.1333. Pass the evidence gate before assigning a status:134 - **Strong** — the principle is implemented coherently for the stated risk.135 - **Partial** — useful implementation exists with a material limitation.136 - **Gap** — sufficient evidence shows a missing or unsafe capability.137 - **N/A** — not relevant, with a reason.138 - **Unverified** — artifacts are insufficient for a defensible judgment.1394. Connect each material finding to a user-visible failure mode.1405. Recommend the smallest architectural change that closes the risk; do not141 default to framework removal or a rewrite.1426. Write the result using143 [assets/review-template.md](assets/review-template.md).144145## Mixed mode146147Complete Review mode first. Preserve confirmed strengths and constraints, then148use Design mode to describe the target state. Every target-state change should149trace back to a review finding, requirement, or explicit future capability.150151## Validation loop152153Before delivering the artifact:1541551. Check that every verdict has evidence or is marked Unverified.1562. Check that every N/A has a reason.1573. Check that recommendations are not written as observed facts.1584. Check that high-risk side effects have validation, policy/idempotency, and a159 human gate when required.1605. Check that retries and loops have termination/escalation behavior.1616. Check that the proposed state can support resume and replay where required.1627. Check that acceptance steps exercise the real model boundary or reducer, not163 only syntax and type checks.164165## Gotchas166167- **The factors are principles, not a compliance standard.** Do not calculate a168 percentage score or call a system "12-factor compliant."169- **Factor 13 is an appendix.** Label pre-fetching as an extension, never as a170 canonical thirteenth factor.171- **Framework use is not automatically a failure.** The relevant question is172 whether the team can inspect and control prompts, context, state, and flow.173- **Inline prompts are not automatically weak.** Ownership, reviewability,174 versioning, and testability matter more than file placement or Jinja usage.175- **Raw chat messages are not automatically wrong.** Flag them when they are176 unbounded, stale, unfiltered, or impossible to reproduce.177- **"Trigger from anywhere" does not require every channel.** It means execution178 is decoupled from the current UI and can accept the channels the product needs.179- **The 3-10-step guidance is a heuristic.** Domain coherence and context growth180 matter more than a hard method count.181- **Static code cannot prove runtime behavior.** Ask for traces or mark the item182 Unverified when retries, compaction, resume, or model inputs are dynamic.183184## Provenance185186The canonical methodology is Dexter Horthy / HumanLayer's187[12-Factor Agents](https://github.com/humanlayer/12-factor-agents). This skill's188documentation is an adaptation under CC BY-SA 4.0; see `LICENSE.txt`.