4004 news

Agentic Coding: Ground Rules, Skills, and Refinement Loops

Principal Engineer Lada Kessler shares advanced strategies for agentic coding, including the 'centrifuge' refinement loop, skill-based activation, and deterministic verification. Learn how to manage AI complexity, enforce honest output, and build trusted software factory building blocks.

The Shift from Prompting to System Architecture

The landscape of software development is undergoing a fundamental shift from manual coding to directing agentic systems. Principal Engineer Lada Kessler argues that the primary challenge is no longer writing code, but managing the complexity and reliability of AI agents. The core insight is that AI models operate with limited attention and a tendency to please users, requiring developers to implement rigorous structural controls rather than relying on natural language prompts alone.

Strategic Ground Rules and Skill Activation

Kessler emphasizes the importance of "ground rules" defined in configuration files like Claude MD. These rules must explicitly counteract AI sycophancy by instructing the model to disagree and provide honest feedback. Furthermore, she advocates for a skill-based approach to context management. Instead of loading all instructions into the system prompt, developers should create lightweight skill files with specific activation criteria. This allows agents to invoke detailed processes only when necessary, preserving context for high-level reasoning. This method is particularly effective for enforcing Test-Driven Development (TDD) workflows, where the agent automatically triggers the TDD skill based on code-writing contexts.

The Centrifuge Loop and Iterative Refinement

A key operational framework discussed is the "centrifuge" loop. This process involves having the AI generate an initial draft, then instructing it to read the output back against the original goal to identify flaws. By repeating this cycle multiple times, developers can "spin out" the noise and produce high-quality, human-aligned output. This iterative refinement is crucial for both code generation and creative writing, challenging the misconception that AI should produce perfect results on the first try.

Verification and the Software Factory

To ensure quality, Kessler recommends using deterministic verification triggers rather than general AI code reviews. Specific checks for code smells or standard adherence provide reliable feedback. She warns against premature adoption of fully autonomous "software factories," noting that complex multi-agent systems often degrade in quality. Instead, engineers should build trusted, small-scale building blocks, such as reliable refactoring processes, before attempting to automate entire workflows. The future of engineering lies in architects who design these reliable systems, rather than workers who merely prompt them.

Key insights

  1. AI models are trained to please users, leading to sycophantic and less useful outputs. Explicit ground rules that grant permission to disagree significantly improve the critical value of AI feedback.

    AI Behavior Management →

    Impact: Reduces the risk of accepting flawed code or ideas due to AI flattery, leading to more robust engineering decisions.

  2. Loading all instructions into system prompts degrades performance due to context limits. Using lightweight skill files with specific activation triggers allows agents to access detailed processes only when relevant.

    Context Optimization →

    Impact: Improves agent reliability and reduces token costs by preventing context pollution with irrelevant instructions.

  3. AI agents struggle with multi-objective tasks. Decomposing work into single-focus steps, such as separate iterations for coding and standard enforcement, aligns with model attention mechanisms.

    Task Decomposition →

    Impact: Increases the accuracy and consistency of AI-generated code by avoiding cognitive overload in the model.

  4. The 'centrifuge' loop, where AI iteratively refines its own output against a goal, is more effective than single-shot generation for achieving high-quality results in both code and content.

    Iterative Refinement →

    Impact: Produces higher-quality deliverables that better reflect human intent and reduce the need for manual correction.

  5. General AI code reviews are often superficial. Deterministic verification triggers that check for specific standards or code smells provide more reliable and actionable feedback.

    Quality Assurance →

    Impact: Ensures consistent adherence to engineering standards and reduces the risk of missing critical issues in automated reviews.

Action items

  • Update your AI ground rules to explicitly instruct the model to be honest, disagree when necessary, and avoid pleasing the user. Test this by asking for critical feedback on a recent project.

    Impact: Improves the critical thinking capability of your AI assistant, leading to more rigorous code reviews and problem identification.

  • Refactor your current system prompts into modular skill files. Define clear activation criteria for each skill to ensure they are only loaded when relevant to the current task.

    Impact: Optimizes context usage and improves agent performance by reducing irrelevant information in the prompt window.

  • Implement a 'centrifuge' loop in your workflow by instructing the AI to read back its output and compare it against the original goal before finalizing. Repeat this process at least three times for critical tasks.

    Impact: Enhances the quality and alignment of AI-generated content, reducing the need for extensive manual editing.

  • Develop deterministic verification scripts or triggers for common code standards. Integrate these into your CI/CD pipeline to run alongside AI-generated code reviews.

    Impact: Provides a reliable safety net for AI-generated code, ensuring that critical standards are met regardless of AI interpretation.

  • Experiment with markdown-based prototyping by creating instruction files that agents can execute to simulate user experiences. Use this to explore problem spaces before writing production code.

    Impact: Accelerates the discovery phase of development and helps validate architectural decisions with lower risk and cost.

Quotes

“I call it like a centrifuge. So basically the idea is like, you spin an AI so fast and stupid comes out.”
“This thing is only good at doing one thing at a time. You have to almost give it permission to disagree and fight that in your rules.”
“Whatever AI produces should be good from the first try and never the case. So how do you get to quality? You refine.”