Skip to main content
The ClickHouse Assistant chat agent can be customized to understand your specific business logic, data structures, and domain knowledge through AGENTS.md—a special saved query that acts as a semantic layer over the agent’s system prompt. By creating an AGENTS.md file, you can provide custom instructions that are injected at the start of every conversation to guide SQL query generation and data analysis based on your organization’s unique requirements, calculations, and conventions.

How it works

When you save a query named “AGENTS.md” (case-sensitive) in the Cloud Console:
  1. The ClickHouse Assistant chat agent automatically loads this file when a message is sent
  2. The content is placed within a structured content tag and injected into the agent’s system prompt
  3. The instructions are applied to all ClickHouse Assistant chat conversations in that service

Creating AGENTS.md

1

Create the saved query

  1. In the Cloud Console, create a new query
  2. Name it exactly: “AGENTS.md” (case-sensitive)
  3. Write your custom instructions in the query text editor (not actual SQL)
  4. Save the query
2

Add your instructions

Structure your instructions using clear, actionable language. Include:
  • Business rules and calculations
  • Data structure guidance
  • Domain-specific terminology
  • Common query patterns
  • Performance optimization rules

Best practices

Treat context as a finite resource

Context is precious—every token depletes the agent’s “attention budget.” Like humans with limited working memory, language models experience performance degradation as context grows. This means finding the smallest possible set of high-signal tokens that maximize the likelihood of your desired outcome.

Find the right altitude

Strike a balance between two extremes:
  • Too specific: Hard coding brittle if-else logic that creates fragility and maintenance complexity
  • Too vague: High-level guidance that fails to give concrete signals or falsely assumes shared context
The optimal altitude is specific enough to guide behavior effectively, yet flexible enough for the model to apply strong heuristics. Start with a minimal prompt on the best model available, then add clear instructions based on observed failure modes.

Organize with structured sections

Use XML tags or Markdown headers to create distinct, scannable sections:

Provide diverse, canonical examples

Examples are the “pictures worth a thousand words.” Rather than stuffing every edge case into your prompt, curate a focused set of diverse examples that effectively portray expected behavior.

Keep it minimal yet complete

  • Include only frequently-needed instructions
  • Be concise—larger context degrades performance due to “context rot”
  • Remove outdated or rarely-used rules
  • Ensure sufficient information to guide desired behavior
Minimal doesn’t necessarily mean short. You need enough detail to ensure the agent adheres to expected behavior, just avoid unnecessary verbosity.

Example: Calculated Metrics from raw data

Guide the agent when metrics require specific calculations rather than direct column access:

Example: Business logic rules

Define domain-specific calculations and categorizations:

Example: Data structure quirks

Document unconventional data formats or legacy schema decisions:

Example: domain terminology

Map business terms to technical implementation:
Last modified on June 12, 2026