# What Is an Agentic Control Loop? Implementing Control Theory with the design-control-loop Skill

> Explore agentic control loops, self-sustaining systems that improve code iteratively using autonomous agents and human feedback. Learn how the design-control-loop skill implements this powerful control theory concept.

- Repository: [HumanLayer/skills](https://github.com/humanlayer/skills)
- Tags: tutorial
- Published: 2026-09-12

---

**An agentic control loop is a self-sustaining, iterative system that continuously measures a codebase, decides on minimal improvements, applies changes through autonomous coding agents, and learns from human feedback to nudge a repository toward a desired state.**

The **design-control-loop** skill in the `humanlayer/skills` repository provides a structured framework for building these agentic control loops. It maps classic control theory onto software development workflows, enabling AI agents to act as persistent caretakers of code quality, test coverage, or architectural standards.

## Core Components of the Agentic Control Loop

The skill implements six fundamental control-theory components that work together to create a feedback-driven automation system:

### Set Point: The Desired Target

The **set point** defines the target state the loop aims to achieve, such as "test coverage ≥ 90%" or "zero usage of deprecated APIs." According to the skill specification in [`SKILL.md`](https://github.com/humanlayer/skills/blob/main/SKILL.md), this is defined collaboratively with the user during the design phase (lines 64-65).

### Sensor: Measuring State and Gap

The **sensor** component measures the current state of the repository and calculates the gap between reality and the set point. As implemented in lines 66-68 of the specification, sensors can take multiple forms:

- Static analysis queries or lint rules
- Test runners that measure coverage
- Custom scripts that count occurrences of patterns
- Agent-based checks that use LLMs to evaluate code quality

### Controller: Decision Logic

The **controller** decides what specific change to make next based on the sensor's measurement. Lines 68-70 describe this as either deterministic (a script that selects the next file) or fully agentic (a language model that reasons about priorities). The controller may be fused with the sensor or actuator depending on architectural needs.

### Actuator: The Coding Agent

The **actuator** is a specialized coding-agent skill that applies the chosen change, validates the result, and opens a pull request. Lines 71-74 specify that the actuator utilizes a headless CLI for `claude-code`, `codex`, `opencode`, or `codelayer` to execute changes autonomously without human intervention during the execution phase.

### Disturbances and Dampeners

**Disturbances** represent external factors that modify the repository between loop iterations, including team commits, dependency updates, or generated code. The skill accounts for these in lines 75-76 by optionally adding a *dampener* component that prevents regressions or oscillations in the control loop.

### Feedback and Memory

The **feedback** component persists human guidance between runs through a version-controlled markdown file. As detailed in Phase F (lines 27-34), this memory template enables maintainers to correct the agent's approach, refine the set point, or adjust priorities, allowing the loop to improve over time rather than repeating mistakes.

## The Seven Phases of Implementation

The `design-control-loop` skill organizes the creation of an agentic control loop into a systematic workflow:

1. **Phase A – Understand the system:** Scan CI configurations, package managers, existing validation scripts, and any prior agent loops to inform design decisions about sensor and actuator placement.

2. **Phase B – Design the loop:** Interview the user to formalize the set point, sensor mechanism, controller logic, actuator configuration, and disturbance handling. Decisions are recorded in the skill memory.

3. **Phase C – Build the actuator skill:** Generate a [`SKILL.md`](https://github.com/humanlayer/skills/blob/main/SKILL.md) file for the actuator based on the templates [`skill-template.md`](https://github.com/humanlayer/skills/blob/main/skill-template.md) and [`response-template.md`](https://github.com/humanlayer/skills/blob/main/response-template.md), defining how the coding agent should execute changes.

4. **Phase D – Verify locally:** Execute each component (sensor, controller, actuator) independently to ensure they function correctly before integration.

5. **Phase E – Wire into CI:** Assemble a recurring GitHub Actions workflow (or equivalent CI) that orchestrates the pipeline: sensor → controller → actuator.

6. **Phase F – Human-on-the-loop:** Add a memory file and optional `/iterate` PR command so human maintainers can steer the agent's behavior without stopping the automation.

7. **Phase G/H – Flow control and validation:** Enforce pull request bounds, validate YAML configurations, and perform dry-runs of the complete workflow to prevent runaway agents.

## Local Testing and Execution

Before deploying to CI, each component of the agentic control loop can be tested locally using the command-line interfaces.

Running the sensor locally to measure deprecated API usage:

```bash

# Execute the sensor script to generate state measurements

./scripts/run-sensor.sh

```

Executing the deterministic controller locally:

```bash

# Process sensor output to select the next target file

./scripts/run-controller.sh sensor-output.json

```

Testing the actuator with Claude Code:

```bash

# Launch the coding agent to fix the selected file and create a PR

claude-code --skill design-control-loop --input controller-output.json

```

Triggering the complete workflow manually in GitHub Actions:

```bash

# Start the scheduled loop via workflow_dispatch for testing

gh workflow run design-control-loop.yml --ref main

```

## Repository Structure and Key Files

The implementation of the agentic control loop relies on several reference templates and specifications located in `plugins/design-control-loop/skills/design-control-loop/`:

- **[`SKILL.md`](https://github.com/humanlayer/skills/blob/main/SKILL.md)** – Defines the interview process and build phases for constructing the loop (lines 64-76 contain the core component definitions).

- **[`references/control-loop-taxonomy.md`](https://github.com/humanlayer/skills/blob/main/references/control-loop-taxonomy.md)** – Documents the taxonomy of sensors, controllers, and actuators available for loop construction.

- **[`references/example-control-loop.md`](https://github.com/humanlayer/skills/blob/main/references/example-control-loop.md)** – Provides a fully worked example of a complete agentic control loop implementation.

- **[`references/workflow-template.yml`](https://github.com/humanlayer/skills/blob/main/references/workflow-template.yml)** – Base GitHub Actions workflow template for orchestrating sensor → controller → actuator execution.

- **[`references/skill-template.md`](https://github.com/humanlayer/skills/blob/main/references/skill-template.md)** – Skeleton template for generating actuator skills that execute the actual code changes.

- **[`references/agent-runner-templates.md`](https://github.com/humanlayer/skills/blob/main/references/agent-runner-templates.md)** – Headless CLI command references for integrating Claude Code, Codex, OpenCode, and CodeLayer as actuators.

- **[`references/memory-template.md`](https://github.com/humanlayer/skills/blob/main/references/memory-template.md)** – Defines the format for the feedback file that persists human guidance between loop iterations.

## Summary

- An **agentic control loop** applies control theory to software maintenance by continuously measuring, deciding, acting, and learning.
- The **design-control-loop** skill in `humanlayer/skills` provides a seven-phase framework for implementing these loops safely.
- Core components include the **set point** (target), **sensor** (measurement), **controller** (decision logic), **actuator** (coding agent), and **memory** (feedback persistence).
- The actuator integrates with headless AI coding agents like Claude Code and Codex via CLI interfaces to create autonomous pull requests.
- Local verification and phased deployment prevent runaway automation while enabling incremental, reviewable improvements to the codebase.

## Frequently Asked Questions

### How does the agentic control loop prevent runaway automation?

The skill implements multiple safeguards consistent with control theory's dampener concept. Phase G/H enforces pull request bounds and dry-run validation, while the human-on-the-loop architecture (Phase F) requires version-controlled feedback files that allow maintainers to pause or correct the loop's behavior. Additionally, the actuator design generates small, atomic changes that are easily reviewable rather than bulk transformations.

### What types of sensors can measure the "gap" to the set point?

According to [`SKILL.md`](https://github.com/humanlayer/skills/blob/main/SKILL.md) lines 66-68, sensors can be lint rules, static analysis queries, test coverage runners, custom shell scripts, or even LLM-based agents that evaluate code quality. The sensor must output a measurable state that the controller can interpret to determine the next action toward the defined set point.

### Can I use different AI agents as the actuator besides Claude Code?

Yes. The [`references/agent-runner-templates.md`](https://github.com/humanlayer/skills/blob/main/references/agent-runner-templates.md) file provides headless CLI integration templates for Claude Code, Codex, OpenCode, and CodeLayer. The actuator skill is designed to be agent-agnostic, requiring only that the chosen tool supports non-interactive execution via command line with JSON input/output handling.

### What is the purpose of the memory file in Phase F?

The memory file, defined in [`references/memory-template.md`](https://github.com/humanlayer/skills/blob/main/references/memory-template.md), serves as the loop's long-term persistence mechanism. It records human feedback, design decisions, and iteration history between runs, allowing the agent to learn from corrections without starting from scratch each execution. This transforms the system from a stateless script into a learning, adaptive maintenance tool.