The Golden Rule: CLI Produces Facts, Model Acts on Facts

Don't make the model memorize all rules—let rules be executed at the right places. cli-schema validate turns Schema from knowledge into a quality gate.

Oliver Kingsley

Oliver Kingsley

6 July 2026

The Golden Rule: CLI Produces Facts, Model Acts on Facts

Apidog for Enterprise

On-Premises Deploy

SSO & RBAC

SOC 2 Compliant

Explore Apidog Enterprise

This is a 10-part series sharing how Apidog developed Apidog CLI, a command-line tool for API testing and API lifecycle management. Read in order or jump to any post that interests you:

Title Focus
1 We Built 126 MCP Tools. But It Is Not the Best Solution for Agent Problem discovery
2 Why We Developed Brand-new Apidog CLI Architecture development
3 The Golden Rule: CLI Produces Facts, Model Acts on Facts Core philosophy
4 agentHints: Teaching CLIs to Talk to Agents Structured output
5 SKILL: Shipping Operational Experience as Code Operational experience
6 The Numbers Don't Lie: 30% Fewer Tool Calls, 25% Fewer Tokens Quantitative results
7 From PRD to Testing Loop: A Complete Agent Workflow with Apidog CLI Practical tutorial
8 Why CI/CD Compatibility Is Non-Negotiable for Agent Tools DevOps perspective
9 AI Branch: Safer Project Changes with AI Agents Security layer
10 Spec-First Was Yesterday. Welcome to Skill-First. Vision & future

Don't make the model memorize all rules—let rules be executed at the right places. cli-schema validate turns Schema from knowledge into a quality gate.


The Core Principle: Let Rules be Executed at the Right Places.

We distilled one core principle from our experience:

Don't make the model memorize all rules. Let rules be executed at the right places.

This is similar to a lesson from Agent evaluation:

Indicator Type Where It Belongs
Deterministic indicators Scripts, code, automated checks
Semantic judgments LLMs, model reasoning

In Apidog CLI + SKILL:

What Where
Deterministic structure validation CLI (cli-schema)
Task judgment and generation Agents

Let CLI validate structure. Let Agents generate content.


The Problem with Model Memory

When an AI Agent helps create or update Apidog resources, the risky part isn't just generating content.

The risky part is writing generated content into a real project without enough structure or verification.

Apidog resources are structured. Consider what a test case or test scenario includes:

Component Complexity
Request data Method, URL, headers, body, auth
Assertions Comparator, subject, target value, conditions
Variable extraction Variable name, type, extraction path
Pre-processors Scripts before request
Post-processors Scripts after response
Step order Sequence, dependencies
Environment references Environment ID, variable overrides

If an Agent guesses the structure:


cli-schema validate: The Quality Gate

The most direct embodiment of our principle is cli-schema validate.

apidog cli-schema validate test-scenario-update --file ./scenario-update.json

When an Agent wants to write or update a test scenario, having AI generate complex step structures is very error-prone.

The validate command:

All before initiating the write request.


Common Errors cli-schema Catches

Here are real examples of errors Agents commonly make—and that cli-schema validate catches:

Wrong Value Correct Value Context
global globals Variable scope type
contains include Assertion comparator
responseBody responseJson Response body subject
"500" (string) 500 (number) Delay in milliseconds
equals equal Assertion comparator
header headers Request headers field

These aren't theoretical. We discovered them through real Agent interactions.

Each error would cause:

With cli-schema validate, these errors are caught locally, before the network call.


The Design Philosophy

Let's consider the alternatives:

Alternative 1: Write Rules into Prompt

If we wrote all field rules into the Agent's prompt:

Result: Massive context burden.

A comprehensive test scenario schema could easily require 5,000+ tokens of description. That's context the model must carry for every task, even when most rules aren't relevant.

Alternative 2: Rely on Model Memory

If we rely on the model to "know" the correct structure:

Result: High error rates.

The model doesn't have perfect memory of Apidog-specific conventions. It will guess—and guesses will be wrong.

Better Approach: Validate Locally

Let the Agent generate drafts. Let CLI execute validation before writing.

# Agent generates JSON
# (Agent doesn't need to memorize all rules)

# CLI validates
apidog cli-schema validate test-case-create --file ./test-case-create.json

# CLI outputs specific errors if any
# Agent adjusts based on errors

# Only valid writes proceed
apidog test-case create --project <projectId> --file ./test-case-create.json

Schema Transformation

cli-schema validate transforms what Schema means:

Before After
Schema = knowledge model must memorize Schema = quality gate that must be passed
Errors discovered through failed writes Errors discovered through local validation
Retry through network calls Fix through local adjustment
Context burden Execution gate

Problems are not consumed in meaningless back-and-forth network requests.

Quality checks are completed through local commands.


Practical Example

Let's walk through a real workflow:

# Agent reads endpoint
apidog endpoint get <endpointId> --project <projectId>

# Agent generates test case JSON
# (Creates ./test-case-create.json)

# Validate before writing
apidog cli-schema validate test-case-create --file ./test-case-create.json

If validation passes:

apidog test-case create --project <projectId> --file ./test-case-create.json

If validation fails:

Error: Field "assertions[0].comparator" has invalid value "contains"
Valid values: equal, not_equal, greater, less, include, not_include, exists, not_exists

Error: Field "extractors[0].type" has invalid value "global"
Valid values: globals, environment, collection, local

Suggestion: Fix these fields and re-validate before writing.

The Agent:

  1. Reads the specific errors
  2. Understands exactly what's wrong
  3. Adjusts the JSON file
  4. Re-runs validation
  5. Proceeds only when valid

No failed writes. No confused retries. No wasted tokens.


The Broader Lesson

This principle extends beyond validation.

Rule Type Where It Belongs
Field name rules cli-schema
Enum value rules cli-schema
Type constraints cli-schema
Workflow sequence SKILL
Next-step guidance agentHints
Task decomposition Agent

Deterministic rules → Engineering system

Semantic judgment → Agent


What's Next

Now that we've established the validation principle, the next question is:

After validation, how does CLI guide the Agent to the next step?

In Part 4, agentHints: Teaching CLIs to Talk to Agents, we'll explore how structured output with next-step suggestions transforms CLI from a command executor into a workflow navigator.


Key Takeaways


Download Apidog to design, mock, test, and document APIs in one workspace. Learn more about Apidog CLI for command-line API testing, CI automation, and AI Agent workflows.

button

Explore more

API Observability: What It Is and How to Achieve It

API Observability: What It Is and How to Achieve It

API observability explained: how it differs from monitoring, the three pillars (metrics, logs, traces), RED, SLOs, and how to implement it.

6 July 2026

Vegeta Load Testing: A Constant-Rate HTTP Tutorial

Vegeta Load Testing: A Constant-Rate HTTP Tutorial

Learn Vegeta load testing: constant-rate HTTP attacks, install, the attack/report/plot pipeline, targets file format, and how functional testing fits in.

6 July 2026

Claude Fable 5 Without Restrictions

Claude Fable 5 Without Restrictions

The Fable 5 export suspension lifted, so you can use it again. What that means, why the safety filter stays, and how to run it with the fewest real limits.

6 July 2026

Practice API Design-first in Apidog

Discover an easier way to build and use APIs

The Golden Rule: CLI Produces Facts, Model Acts on Facts