v3.1.0 Database Intelligence Layer Reference

Schemap CLI Reference & Safety Guide

Learn how to configure AI safety guardrails, scope context profiles, measure token cost savings, analyze schema health, and compile deterministic context maps for Claude Code, Cursor, Codex, and AI agents.

Getting Started

Installation pipx / uv / pip

Install Schemap globally on your workstation using pipx or uv:

# Recommended: Install globally via pipx
pipx install schemap-tool

# Or using uv
uv tool install schemap-tool

# Upgrade to latest version anytime
pipx upgrade schemap-tool
schemap quickstart v3.0 New

Runs the interactive onboarding pipeline: auto-detects local SQLite databases and environment connection strings, creates schemap.yaml, compiles context, installs agent rules, and prints an AI Readiness Summary Card.

schemap quickstart

# Non-interactive mode with specific database URL
schemap quickstart --non-interactive --db "sqlite:///examples/demo_ecommerce.db"
OptionDescription
--interactive / --non-interactivePrompt for settings or auto-pick detected database sources.
--db <url>Override target database connection string.
--output-path <file>Destination for database context map (default ./schemap_database_context.md).
--targets <list>Target AI agent frameworks (e.g. codex,claude,cursor or all).
schemap init Config

Initializes a new schemap.yaml configuration asset in the current working directory.

schemap init
schemap init --full   # Generate full configuration boilerplate

Context & Agent Compilation

schemap context Core

Compiles token-optimized database context files. Supports Markdown, JSON, YAML, XML, MCP, AI-prompt, and Mermaid ER diagram formats.

schemap context
schemap context --format mermaid     # Generate Mermaid ER diagram (erDiagram)
schemap context --format json        # Export machine-readable JSON context
OptionDescription
--format <fmt>Format override: markdown, json, yaml, xml, mcp, ai, mermaid.
--enrich[Beta] Apply LLM enrichment for table descriptions using OpenAI API.
--track / --no-trackTrack current schema state in .schemap/cache.json for diff intelligence.
schemap agents v3.0 Enhanced

Generates CLAUDE.md, AGENTS.md, and .cursor/rules/schemap.mdc files for AI coding agents. Uses safe marker preservation (<!-- schemap:start -->) to protect user-authored notes.

schemap agents --targets codex,claude,cursor
schemap agents --dry-run               # Preview output without modifying files
schemap agents --diff                  # Show unified git-style diff of changes
schemap agents --force                 # Force overwrite existing files
schemap sync v3.0 New

Calculates a SHA256 database schema structure fingerprint. Regenerates context maps and agent files ONLY when the schema structure actually changes.

schemap sync
schemap sync --force   # Force sync even if schema fingerprint is unchanged

Diagnosis & Automated Fixes

schemap doctor v3.0 Enhanced

Runs AI Database Health Check. Emits actionable remediation objects: inferred foreign key candidates with confidence scores (e.g. 95%), unresolved abbreviation mappings, and configuration snippets.

schemap doctor
schemap doctor --json   # Output health check report in machine-readable JSON
schemap fix v3.0 New

Interactively prompts user to accept or reject inferred foreign key relationships and abbreviation mappings, automatically persisting accepted fixes back into schemap.yaml.

schemap fix --interactive
schemap fix --accept-all   # Auto-accept all inferred FK candidates and mappings
schemap score Linter

Calculates the 0-100 AI Readiness Score for the schema based on primary keys, foreign key connectivity, documentation coverage, and naming consistency.

schemap score
schemap inspect Metadata

Extracts database metadata and displays a clean structural summary of tables, columns, foreign keys, and indexes.

schemap inspect
schemap inspect --json

Querying & Explainers

schemap explain table <name> v3.0 New

Explains table architecture, primary keys, column data types, descriptions, incoming references, and centrality scores.

schemap explain table orders
schemap explain table users --json
schemap join <table1> <table2> [table3...] v3.0 New

Uses Breadth-First Search (BFS) over foreign key relationships to find the shortest joining path between tables and outputs a valid SQL JOIN clause.

schemap join users orders payments

# Output snippet:
# SELECT *
# FROM users
# JOIN orders ON users.id = orders.user_id
# JOIN payments ON orders.id = payments.order_id;

CI / CD & Advanced Options

schemap diff v3.0 Enhanced

Compares current schema against tracked state. Supports --json diff output and --fail-on-breaking for CI pipeline gates.

schemap diff
schemap diff --json
schemap diff --fail-on-breaking   # Exit status code 2 if breaking changes exist
Global CLI Flags & Profiles v3.0 New

Global options supported across all Schemap CLI commands:

schemap --profile staging context
schemap --quiet doctor
schemap --no-color score
Global FlagDescription
--profile <name>Load named environment profile configuration from schemap.yaml.
--quiet / -qSuppress informational output messages.
--no-colorDisable ANSI color rendering in terminal output.
SCHEMAP_DATABASE_URLEnvironment variable to override database.connection_url.

AI Agent Skills Integration

schemap skills install v3.0 New

Installs agent-native schemap AI skills for Codex, Claude Code, and Cursor. Decoupled from specific database facts so project rules stay in AGENTS.md.

schemap skills install --targets codex,claude,cursor

# Installed skill paths:
#   .codex/skills/schemap/SKILL.md
#   .claude/skills/schemap/SKILL.md
#   .cursor/rules/schemap.mdc

Configuration File (`schemap.yaml`)

schemap.yaml Reference YAML

Complete configuration file options including named profiles and foreign key overrides:

# Schemap Configuration Asset
database:
  connection_url: "sqlite:///examples/demo_ecommerce.db"
  exclude_tables:
    - "spatial_ref_sys"

output:
  file_path: "./schemap_database_context.md"
  format: "markdown"

domain:
  mappings:
    cust: "Customer"
    tx: "Transaction"

# Manual/inferred foreign key overrides
foreign_key_overrides:
  - table: "orders"
    column: "user_id"
    ref_table: "users"
    ref_column: "id"

# Named environment profiles
profiles:
  staging:
    database:
      connection_url: "postgresql://user:pass@staging-db:5432/mydb"
  production:
    database:
      connection_url: "postgresql://user:pass@prod-db:5432/mydb"