Recipes · Data

A read-only analyst with safe SQL.

Connect to Postgres, introspect the schema, and answer business questions without writes.

Chihab · · Intermediate · 8 min read

The analyst uses the Postgres voice in its default read-only mode. It must call list_tables and describe_table before writing queries, and every query is parameterised. Configure the voice with a read-only role on your Postgres for hard isolation.

Score file
import { defineScore, AnthropicProvider } from '@tuttiai/core'
import { PostgresVoice } from '@tuttiai/postgres'

export default defineScore({
  provider: new AnthropicProvider(),
  agents: {
    analyst: {
      name: 'analyst',
      model: 'claude-sonnet-4-6',
      system_prompt:
        'You are a data analyst. Use list_tables and describe_table before writing queries. Always parameterise values with $1, $2, ... Never run writes.',
      voices: [new PostgresVoice()],
      permissions: ['network'],
    },
  },
})
How to run it
  1. 01 Scaffold a project: npx tutti-ai init my-data-analyst
  2. 02 Install voices: npm i @tuttiai/postgres
  3. 03 Drop the score above into tutti.score.ts, set the env vars in .env, and run tutti-ai run.
Why this is safe
  • read-only Postgres role
  • parameterised queries enforced by prompt

Start conducting.

One install. Your first agent running in 60 seconds. No signup. No telemetry.