Skip to main content
If you’re familiar with Kubernetes, this document will help you quickly grasp Trellis’s design philosophy.
This article was written in the Trellis 0.4.x era. Some named concepts have changed since: the Ralph Loop, dispatch / plan / debug agents, and the Multi-Agent Pipeline were all removed during the 0.5.0 prerelease. The high-level K8s analogy still applies; read specific agent / hook names here as historical references.

Table of Contents

  1. K8s Core Concepts Overview
  2. Trellis and K8s Analogy
  3. Reconciliation Mechanism Deep Dive
  4. Complete Workflow
  5. Why This Design

1. K8s Core Concepts Overview

Imperative vs Declarative

Imperative: Describe “how to do it”
Declarative: Describe “what you want”

Control Loop

The core of K8s is the Control Loop:
Power in action:

2. Trellis and K8s Analogy

Architecture Mapping

Core Component Mapping

Key Insight

K8s solves: Infrastructure complexity — Uses declarative to abstract away details, Controller handles reconciliation. Trellis solves: AI development uncertainty — Uses declarative to define expectations (prd.md + guidelines), Ralph Loop handles reconciliation. Common ground:
  • Users only declare “what they want”, don’t worry about “how to do it”
  • System continuously reconciles until actual state matches desired
  • Auto-repairs when deviations occur
Next, Chapter 3 details the reconciliation mechanism (Hook + Ralph Loop), and Chapter 4 expands on the complete workflow (Phase 1-4).

3. Reconciliation Mechanism Deep Dive

Trellis reconciliation is achieved through two mechanisms working together: Hook Injection and Ralph Loop.

Hook Injection

Timing: Automatically triggered each time a Subagent is called Function: Injects file contents referenced in jsonl into the Agent’s context
jsonl file example:
Why this design:
  • Prevents context overload (Context Rot) — Only injects what’s needed for current phase
  • Traceable — jsonl records what context each task used
  • Decoupled — Agent doesn’t need to search, focuses on execution

Ralph Loop

Essence: A programmatic quality gate that intercepts Agent stop requests and forces continuation if verification fails. Trigger timing: When Check Agent attempts to stop Flow:
verify config example (worktree.yaml):
Why use programmatic verification instead of letting AI judge:
  • Programmatic verification is reliable — lint pass means pass, doesn’t depend on AI’s judgment
  • Configurable — Different projects can configure different verification commands
  • Prevents infinite loops — Max 5 iterations, then force allow
Limitations:
  • Complex architectural issues or logic bugs may require human intervention
  • Depends on guideline quality; unclear guidelines lead to limited check effectiveness

4. Complete Workflow

Phase Overview

Exception Path

If Check Agent reports unfixable issues, Dispatch can call Debug Agent for deep analysis. This is not the default flow, but exception handling.

5. Why This Design

One-Click Complete Workflow

/trellis:start or /trellis:parallel (Claude Code only) launches with one click, AI completes the entire flow:
Users don’t need to guide step-by-step. What to do at each phase, which guidelines to reference — it’s all predefined.

Continuous Accumulation of Development Guidelines

Thinking Guides help discover “didn’t think of that” problems.

Preventing Context Rot

Too much context causes LLM to:
  • Distraction — Gets sidetracked by irrelevant information
  • Confusion — Information contradicts itself
  • Clash — Old and new information conflict
Trellis injects by phase:
  • implement phase: Requirements + related code
  • check phase: Development guidelines
  • finish phase: Pre-commit checklist
Each phase’s Agent only receives context relevant to its task.

Programmatic Quality Control

Doesn’t rely on AI’s self-judgment, uses programmatic enforcement.

Traceability

When issues arise, you can trace back to which file was missing, or which guideline was unclear.

Summary

Core philosophy aligned: Declare desired → System reconciles → Eventually consistent.