Skip to main content

Understanding Trellis Through Kubernetes

If you’re familiar with Kubernetes, this document will help you quickly grasp Trellis’s design philosophy.

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

1.1 Imperative vs Declarative

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

1.2 Control Loop

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

2. Trellis and K8s Analogy

2.1 Architecture Mapping

2.2 Core Component Mapping

2.3 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.

3.1 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

3.2 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

4.1 Phase Overview

4.2 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

5.1 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.

5.2 Continuous Accumulation of Development Guidelines

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

5.3 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.

5.4 Programmatic Quality Control

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

5.5 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.