---
title: Have an agent write scheduled reports
description: Start an AI agent with the Queria skill from cron or CI and have it write reports in a fixed format
---

Start an AI agent with the [Queria skill](/en/queria-skill) in non-interactive mode, and it can do routine work such as "look at this data every week and summarize what changed" on a schedule, without anyone giving instructions. For interactive use, see [Analyze with AI agents](/en/agent-analysis).

## What you decide and what the AI does

To get reports on the same basis every time, decide how the numbers are produced yourself and leave the reading to the AI.

- Numbers: write the aggregation SQL in the prompt so every run uses the same SQL
- Reading: have the AI write the changes since last time, values that stand out, and the summary
- Format: set the Markdown headings in the prompt so the shape doesn't change between runs

## Prepare the prompt

Keep the prompt in a file such as `weekly-report.md`, so you can track changes in Git and swap it easily.

```markdown
You are a data analyst. Investigate the following with the Queria CLI
and write a Markdown report.

1. Top 10 prefectures by total population in 2024,
   from e_stat.ssds.a_pref_population
2. Compare against the latest Parquet under snapshots/ (the results
   saved last time) and call out any changes in values or rankings

Structure the output under three headings: "## Summary", "## Numbers",
"## Observations".
```

## Run in non-interactive mode

In a project directory with the Queria skill installed, start Claude Code in non-interactive mode (`-p`).

```bash
claude -p "$(cat weekly-report.md)" > reports/weekly-$(date +%F).md
```

Following the skill, the agent runs `queria search`, `schema` and `sql`, reads the results and writes the report.

## Run it on a schedule

```text
0 9 * * 1 cd /home/you/queria-reports && ./run-weekly.sh
```

Running from CI such as GitHub Actions uses the same command. Committing the report or posting it to chat are ordinary CI steps.

To do the same from an AI chat without a shell, see [MCP server](/en/mcp). The MCP server can't read your local files, so comparing with results you saved earlier needs the CLI and the skill.

## Rate limits

For scheduled runs, set an [API token](/en/authentication) (`queria auth set-token`, or the `QUERIA_TOKEN` environment variable). Reading without a token can hit the [rate limit](/en/limits), and the report may then fail.
