Skip to main content

Command Line Usage

Query Command Overview

Mantis provides two powerful approaches to querying your infrastructure configurations:

  1. Natural language queries for intuitive exploration
  2. CUE query configurations for precise, repeatable queries

Basic Query Syntax

Natural Language Queries

mantis query \
-S ./prompts/cquery.txt \
-C ./config \
-q "Show me all services with more than 3 replicas" \
-i ~/.mantis/index/mantis-index.json

CUE Configuration Queries

mantis query \
-S ./prompts/cquery.txt \
-C ./config \
-c ./queries/replicas.cue

Required Parameters

ParameterFlagDescription
System Prompt-S, --system-promptPath to system prompt file
Code Directory-C, --code-dirDirectory containing CUE configurations
Query String-q, --queryNatural language query (when using NL mode)
Index Path-i, --indexPath to query index file (required with -q)
Query Config-c, --query-configPath to CUE query configuration file

Query Configuration Files

When using CUE configuration files (-c option), create structured queries:

// queries/replicas.cue
{
from: "service[string]"
select: [
"name",
"replicas"
]
where: {
"replicas": "^[4-9]|[1-9][0-9]+$" // Match 4 or more replicas
}
}

Natural Language Query Examples

# Resource Analysis
mantis query -q "What is the total number of replicas across services"

# Service Discovery
mantis query -q "Show me all frontend services"

# Resource Optimization
mantis query -q "Find services with high CPU limits"

Index Management

Building the Index

# Basic indexing
mantis index --code-dir ./configs

# Custom index location
mantis index --code-dir ./configs --index-dir /path/to/index

# With custom system prompt
mantis index --code-dir ./configs --system-prompt ./prompts/index.txt

Index Parameters

ParameterFlagDescriptionDefault
Code Directory-C, --code-dirSource directory for CUE filesRequired
System Prompt-S, --system-promptAI prompt file pathOptional
Index Directory-i, --index-dirIndex storage location~/.mantis/index

Index Features

The generated index provides:

  • Query Templates: Pre-built queries for common scenarios
  • Path Optimization: Pre-computed paths for faster queries
  • AI Suggestions: Context-aware query recommendations

Best Practices

  1. Index Management

    • Regularly update your index as configurations change
    • Use custom system prompts for specialized queries
    • Store indexes in version control for team sharing
  2. Query Organization

    • Create reusable query configurations for common tasks
    • Document complex queries with comments
    • Use natural language for exploratory queries