Claude Code Excels at Everything Except Following Your Program: How the ACP Protocol Fixes This

Introduction

In the rapidly evolving landscape of AI-assisted programming, Claude Code by Anthropic has emerged as a powerful tool for developers. It can generate code, debug complex issues, refactor entire projects, and even write documentation with impressive accuracy. However, as many developers have discovered, Claude Code has one critical limitation: it often fails to adhere strictly to the user's program specifications or architectural constraints. This disconnect between what developers intend and what Claude Code produces can lead to frustration, wasted time, and inconsistent codebases.

Enter the Agent Communication Protocol (ACP) — a recently proposed standard that promises to bridge this gap. Developed by a community of AI researchers and software engineers, ACP defines a structured way for AI coding assistants like Claude Code to understand and follow user-defined programs, rules, and workflows. According to a detailed analysis on Habr, ACP addresses the core issue of AI 'listening' to the programmer's intent by introducing a formal protocol for communication between the AI agent and the development environment.

In this article, we explore how Claude Code works, why it struggles with following your program, and how the ACP protocol provides a practical solution. We'll examine real-world examples, compare ACP with existing approaches, and offer actionable recommendations for developers who want to regain control over their AI coding assistant.

Why Claude Code Often Ignores Your Program

Claude Code, like other large language model (LLM)-based coding assistants, operates by predicting the most likely next tokens based on a prompt. While this makes it excellent at generating syntactically correct code, it has several inherent weaknesses:

  • Lack of persistent context: Claude Code processes each request independently, often forgetting earlier instructions or constraints from the same session.
  • Overgeneralization: It may apply patterns from its training data that don't fit your specific project architecture.
  • Ambiguity in natural language: Instructions like "use the repository pattern" can be interpreted in multiple ways, leading to inconsistent implementations.

The article from Habr highlights a concrete example: a developer asked Claude Code to implement a payment processing module that must follow a specific error-handling policy. Despite explicit instructions, the AI generated code that used generic exception handling, ignoring the project's custom error classes and logging requirements. This happened because Claude Code lacked a mechanism to 'listen' to the program's predefined rules.

What Is the ACP Protocol?

The Agent Communication Protocol (ACP) is a lightweight, extensible standard designed to enable AI agents to communicate with each other and with development tools in a structured way. Unlike ad-hoc prompt engineering, ACP provides:

  • Formal message schemas: Define how instructions, constraints, and feedback are exchanged.
  • State management: Tracks what the agent has already done and what remains to be done.
  • Rule enforcement: Allows developers to specify 'invariant' rules that the AI must not violate.
Feature Traditional Prompting ACP Protocol
Context retention Limited to conversation window Persistent state across interactions
Rule enforcement Relies on AI's interpretation Formal rule schema with validation
Error recovery User must manually correct Structured feedback loop
Scalability Works for simple tasks Designed for complex, multi-step workflows

The Habr article explains that ACP is not a replacement for Claude Code's capabilities but rather a layer that sits between the developer and the AI, ensuring the assistant 'listens' to the program's specifications before generating code.

Practical Example: Fixing Claude Code with ACP

Imagine you are building a microservice that must use a specific logging library (e.g., loguru in Python) and follow a strict naming convention for database tables. Without ACP, you might write a prompt like:

"Create a user service with CRUD operations. Use loguru for logging and name all tables with t_ prefix."

Claude Code might produce code that uses logging instead of loguru or name tables inconsistently. With ACP, you first define a program file (e.g., project.acp.json) that contains:

{
  "rules": [
    {"type": "dependency", "name": "loguru", "version": ">=0.7.0"},
    {"type": "naming", "pattern": "t_[a-z_]+$", "scope": "table"},
    {"type": "style", "rule": "all functions must have type hints"}
  ]
}

Claude Code then reads this program, and ACP ensures that any generated code violates none of the rules. If a violation occurs, the protocol triggers a correction loop before the code is presented to the developer. This dramatically reduces manual review time.

The Habr article reports that early adopters of ACP saw a reduction in code review rejections by over 40%, and developers reported feeling more confident in delegating tasks to Claude Code.

Comparison with Other Approaches

Several other methods attempt to improve AI adherence to instructions:

  • Prompt engineering: Writing detailed prompts with examples. Works for simple tasks but fails for complex rules.
  • Retrieval-Augmented Generation (RAG): Injecting project documentation into the prompt. Improves context but doesn't enforce rules.
  • Custom fine-tuning: Training a model on your codebase. Expensive and requires expertise.

ACP offers a middle ground: it's lightweight (no fine-tuning needed) but formal (not reliant on prompt quality). The table below summarizes the trade-offs:

Approach Complexity Enforcement Cost
Prompt engineering Low Weak Free
RAG Medium Medium Low
Fine-tuning High High High
ACP Protocol Low-Medium High Free (open standard)

According to the Habr source, ACP is designed to be integrated into existing CI/CD pipelines, making it practical for teams without specialized AI infrastructure.

How to Implement ACP with Claude Code

The article describes a step-by-step process for integrating ACP:

  1. Define your program: Write a .acp file that specifies rules, dependencies, and workflow steps.
  2. Configure Claude Code: Use the ACP plugin or API wrapper to inject the program into each Claude Code request.
  3. Validate outputs: ACP checks the generated code against the rules before returning it to you.
  4. Iterate: Update the program as your project evolves.

For example, a development team at a fintech startup implemented ACP to enforce PCI-DSS compliance rules in their Claude Code-generated code. They defined rules for encryption, key management, and logging, and ACP automatically rejected any code that deviated from these standards. This saved the team weeks of manual review.

ASI Biont supports integration with Claude Code and other AI tools through its flexible API — learn more at asibiont.com/courses. This platform enables developers to combine the power of AI coding assistants with structured protocols like ACP, ensuring that your program's rules are never ignored.

Challenges and Limitations

While ACP is promising, it's not a silver bullet. The Habr article notes several challenges:

  • Rule expressiveness: Complex business logic (e.g., "never use a JOIN in this specific query") is hard to define formally.
  • False positives: Strict rules may cause ACP to reject valid code, requiring manual override.
  • Adoption friction: Teams need to invest time in writing and maintaining their .acp files.

Despite these issues, the protocol is gaining traction in the developer community, with several open-source projects already adopting it.

Conclusion

Claude Code is an incredibly capable AI coding assistant, but its tendency to ignore user-defined programs remains a significant hurdle for professional development teams. The Agent Communication Protocol (ACP) offers a practical, standards-based solution to this problem by formalizing how AI agents listen to and follow program specifications.

By adopting ACP, developers can regain control over their AI assistants, reduce code review overhead, and ensure that generated code aligns with project architecture, naming conventions, and compliance requirements. While not perfect, ACP represents a major step forward in making AI coding tools truly useful for production-grade software development.

As the ecosystem matures, we can expect more tools and platforms to natively support protocols like ACP. For now, the message is clear: if you want Claude Code to listen to your program, give it a program to listen to — via ACP.

Source

← All posts

Comments