PTENES
TRACK 3

πŸ›  Technical Implementation

Hands-on: how to build loops with Claude Code, deterministic workflows with Archon, control dashboards, and cost optimization.

4
Modules
24
Topics
~2h30
Duration
Practical
Level
Claude Code /loop /goal /routines Archon Workflows deterministic Dashboard Control Plane Observability Optimization Provider mix External state Postgres / Neon (State Store)

Learning path map

Detailed content

3.1 ~35 min

πŸ”„ Basic Loop with Claude Code

Setup for the /loop skill, creation of plan.md, prompt for the orchestrator to configure the loop, demo with a sequential task list and automatic wake-up.

What is:

Claude Code has a built-in capability called the "loop skill" that teaches the agent to configure loops automatically.

Why learn:

It's the simplest starting point for loop engineering. A single prompt carries the entire system.

Key Concepts:

Loop skill as a capability. Initial prompt. Agent self-configuration.

What is:

A Markdown document with numbered tasks that the agent processes one by one, marking each as complete.

Why learn:

The quality of plan.md determines the quality of the output. Well-defined tasks = better results.

Key Concepts:

Ideal granularity. Acceptance criteria per task. Sequential vs. parallel order.

What is:

The prompt loads the loop skill and instructs the agent to process plan.md. The agent configures /loop on its own.

Why learn:

A good initial prompt is the difference between a functional loop and a chaotic one.

Key Concepts:

"Load the loop skill." Automatic /loop setup. A prompt as a system, not an instruction.

What is:

The agent completes a task, schedules the next wake-up via /loop, and continues until all tasks in plan.md are complete.

Why learn:

Seeing the actual workflow helps you understand how the primitives connect in practice.

Key Concepts:

Wake-up cycle. Validation between tasks. Prompt automatically generated by the agent.

What is:

A collection of copyable prompts for the most common scenarios: task runner, code review, and exploration.

Why learn:

Starting with tested prompts speeds up adoption and avoids common configuration mistakes.

Key Concepts:

Reusable templates. Adjustable parameters. Adaptation by context.

What is:

The basic loop runs in a single session, uses a single model, and has no external state. This limits scalability and reliability.

Why learn:

Understanding the limitations motivates the search for more robust solutions in the following modules.

Key Concepts:

Single session = context bloat. Single model = high cost. No state = no durability.

View Full
3.2 ~40 min

βš™ Deterministic Workflows with Archon

Cole Medin's harness builder: workflows where the human defines the process, models are mixed by step, and persistence is provided by Postgres/Neon.

What is:

Archon is Cole Medin’s tool for orchestrating coding agent sessions with human-defined workflows.

Why learn:

Represents the opposite approach to a pure loop: the human defines the process, not the agent.

Key Concepts:

Harness vs. loop. Workflow file. Deterministic steps. Mix of providers.

What is:

Deterministic pipeline: extract the issue, find context, classify the type, research, implement, validate, and create a PR.

Why learn:

It's the most practical example of how to combine determinism with an LLM, using the agent only where it's really needed.

Key Concepts:

Pipeline as a graph. Deterministic vs. LLM-driven steps. Classification as a lightweight decision.

What is:

In a deterministic workflow, the human defines which steps exist and in what order. In a pure loop, the agent decides everything on its own.

Why learn:

Understanding this trade-off is essential to choosing the right approach for each scenario.

Key Concepts:

Reliability vs. flexibility. The agent as an executor, not a decision-maker.

What is:

Each workflow node can use a different model. Lightweight steps use cheaper models; critical steps use more capable models.

Why learn:

It's the main cost optimization lever in autonomous workflows.

Key Concepts:

Model routing. Cost per step. Provider mixing. Kimi for exploration, Claude for implementation.

What is:

Logs, runs, and conversations are recorded in Postgres/Neon. If the machine goes down, the workflow resumes at the exact step.

Why learn:

Durability is what turns an experiment into a reliable system.

Key Concepts:

State store. Resume from step. Neon branching for parallel workers.

What is:

Prompts optimized for each step: classification, research, implementation, validation, and code review.

Why learn:

Ready-to-use prompts save time and serve as a starting point for adapting to your context.

Key Concepts:

Template per step. Markdown as context. Handoff between steps via documents.

View Full
3.3 ~35 min

πŸ“Š Control Dashboard (Agent Control Plane)

Real-time observability: see orchestrator decisions, cost tracking, human-in-the-loop, and remote deployment.

What is:

Open-source dashboard Cole built to manage loops with durability, observability, and human-in-the-loop.

Why learn:

Without visual control, loops are black boxes that burn tokens without feedback.

Key Concepts:

Dashboard as a nervous system. Open source on GitHub. Backend with Pi/Kimi.

What is:

All loops, events, and logs are recorded in Postgres (via Neon) for durability and analytics.

Why learn:

External state lets you resume loops after crashes and analyze execution patterns over time.

Key Concepts:

Orchestrator reads state from the database. Workers update state in the database. Database as the source of truth.

What is:

See in real time what decisions the orchestrator makes, how many workers it launches, and each round's progress.

Why learn:

Being able to see and understand the orchestrator's decisions is essential for debugging and improving the loop.

Key Concepts:

Decision log. Round history. Worker dispatch tracking. Event stream.

What is:

Metrics for tokens consumed per round, per worker, and total run cost. Visible in the dashboard.

Why learn:

Without cost tracking, optimization is impossible. The dashboard showed 1M+ tokens for a simple app.

Key Concepts:

Tokens per round. Orchestrator vs. worker costs. Breakdown by model.

What is:

The loop can pause after each round and wait for human approval before continuing.

Why learn:

HITL is the essential guardrail that prevents the problem of "run for a day, come back to crap."

Key Concepts:

Pause between rounds. Approve/reject workflow. Permission groups. Identity verification.

What is:

The dashboard can be deployed to the cloud via Retool, allowing remote access and sharing with the team.

Why learn:

Remote deploy turns a local tool into team infrastructure.

Key Concepts:

Import React into Retool. Connect to Neon. Permission groups. Audit trails.

View Full
3.4 ~30 min

πŸ’° Cost Optimization

Provider mix, model routing, external state, worktrees, and metrics to keep loops financially viable.

What is:

Use different providers for different roles: cheaper models for orchestration, stronger models for implementation.

Why learn:

It's the main lever for reducing costs without sacrificing the quality of the final output.

Key Concepts:

Pi/Kimi as a low-cost orchestrator. Claude Code for execution. Codex for review.

What is:

Route tasks to models based on complexity: simple classification uses Haiku, complex implementation uses Claude.

Why learn:

Every token counts. Using Opus to classify a bug vs. a feature is wasteful.

Key Concepts:

Complexity-based routing. Cost per token by model. Lightweight vs. heavyweight decisions.

What is:

Keep state in an external database instead of accumulating it in the LLM context window. Each session starts fresh and reads the state.

Why learn:

Context bloat is the #1 cause of degradation in long loops. External state solves it.

Key Concepts:

Context window as cache. Database as storage. Stateless session. Read-execute-write cycle.

What is:

Git worktrees create isolated copies of the repo so N agents can work in parallel without code conflicts.

Why learn:

Real parallelism requires real isolation. Worktrees are the most practical mechanism for this.

Key Concepts:

One worktree per worker. One branch per task. Merge after validation. Port conflict avoidance.

What is:

Batch: accumulate tasks and process them all at once (cheaper). Real-time: process immediately (more responsive).

Why learn:

Choosing the wrong mode wastes money or time. Context determines the choice.

Key Concepts:

Batch for overnight GitHub issues. Real-time for urgent fixes. Latency vs. cost trade-off.

What is:

The three essential metrics: tokens consumed per task, orchestrator cost per round, and worker success rate.

Why learn:

What isn't measured can't be optimized. These metrics are the minimum needed to avoid waste.

Key Concepts:

Tokens/task as a KPI. Cost per round. Success rate. Trend analysis. Budget alerts.

View Full