postgrebase AGENTS.md

Development instructions for PostgreBase, a no-code API platform based on PocketBase that can work with PostgreSQL, MySQL, and SQLite. They describe its Go backend, Svelte frontend, project layout, dependencies, and offline build setup.

In plain words
What is it for?
Finding backend and frontend code, understanding database and cache support, preserving vendored packages, and building or running the project.
Why use it?
They give agents the technical context needed to navigate and modify the codebase correctly. They also highlight important constraints such as vendored dependencies and builds without CGO.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/zhenruyan/postgrebase/agents-md
Clone the repo
git clone --depth 1 https://github.com/zhenruyan/postgrebase

Made for: Codex, OpenCode.

Per session 4,530 This file is loaded in full into every session.
When invoked 4,530 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.04530 $0.04530
Opus 5 $0.02265 $0.02265
Sonnet 5 $0.00906 $0.00906
Haiku 4.5 $0.00453 $0.00453

Measured 2d ago against content hash 99f39855f263, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

postgrebase AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 294 lines

How it starts

The opening of the file, as written. The whole thing — 294 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PostgreBase — Agent Development Guide

This file provides context for AI coding agents (Cursor, Claude, Windsurf, etc.) working on the PostgreBase codebase. Read this before exploring or modifying code.

Overview

PostgreBase 是 AI 原生的无代码 API 开发平台,基于 PocketBase 重构。内置 MCP (Model Context Protocol) 服务器,让 AI 工具直接操作数据。支持 PostgreSQLMySQLSQLite 三种数据库,混合缓存(Redis / 内存),100% 兼容 PocketBase API、Admin UI 和业务逻辑。

Tech Stack

  • Language: Go 1.26.2+ (builds with CGO_ENABLED=0)
  • HTTP Framework: github.com/labstack/echo/v5
  • CLI: github.com/spf13/cobra
  • Database Drivers:
    • github.com/lib/pq — PostgreSQL
    • github.com/go-sql-driver/mysql — MySQL
    • modernc.org/sqlite — SQLite (pure Go, no CGO)
  • Caching: github.com/redis/go-redis/v9 (Redis) / built-in memory store
  • Frontend: Svelte 3, svelte-spa-router, Vite 4, PocketBase JS SDK
  • Vendor: /vendor/ directory must be preserved — all dependencies are vendored for offline builds.

Project Structure

postgrebase/
├── build/              # Server entry point (main.go)
├── postgrebase.go      # Root package: CLI setup, Config struct, Bootstrap
├── core/               # Application logic
│   ├── base.go         # BaseApp: cache init, app lifecycle
│   ├── db_postgresql.go # connectDB(): DSN parsing and driver detection
│   └── app.go          # App interface definition
├── daos/               # Data access objects (CRUD for all models)
│   ├── base.go         # Dao struct, ModelQuery, RunInTransaction
│   ├── record.go       # Record CRUD
│   ├── record_table_sync.go # Table schema sync (driver-aware DDL)
│   ├── table.go        # HasTable, TableColumns, TableInfo, TableIndexes (driver-aware)
│   ├── collection.go   # Collection queries
│   ├── admin.go        # Admin auth and queries
│   └── view.go         # SQL view management
├── models/             # Data models
│   ├── base.go         # BaseModel (Id, Created, Updated, RefreshId)
│   ├── record.go       # Record model
│   ├── collection.go   # Collection model
│   ├── admin.go        # Admin model (bcrypt password, JWT token key)
│   └── schema/
│       └── schema_field.go # SchemaField.ColDefinition(driverName) — driver-aware DDL
├── apis/               # HTTP API handlers
│   ├── base.go         # InitApi(): route registration, MCP route binding
│   ├── serve.go        # HTTP server, migration runner, startup banner
│   ├── record_crud.go  # Record CRUD endpoints
│   ├── admin.go        # Admin auth endpoints
│   ├── mcp_token.go    # MCP token management API (CRUD)
│   └── middlewares.go   # Auth middleware (RequireAdminAuth, etc.)
├── mcp/                # MCP (Model Context Protocol) server
│   ├── server.go       # JSON-RPC 2.0 core, method routing, tool schemas
│   ├── tools.go        # 8 MCP tools (CRUD + search for records/collections)
│   ├── resources.go    # 2 MCP resources (collections, settings)
│   ├── auth.go         # Token validation (JWT admin tokens + mcp_ prefixed tokens)
│   ├── transport_sse.go    # SSE + Streamable HTTP transport
│   └── transport_stdio.go  # Stdin/stdout transport
├── migrations/         # Database migrations (driver-aware SQL)
│   ├── 1640988000_init.go              # Core tables (admins, collections, params, externalAuths)
│   ├── 1691747914_add_cache_columns.go # Cache columns migration
│   ├── 1704067200_mcp_tokens.go        # MCP tokens collection
│   └── 1730000000_agent_runtime.go     # Agent sessions/messages/audit/project-config tables
├── agents/             # Embedded agent platform (orchestration over controlled tools)
│   ├── service.go      # Service facade (runtime, sessions, tools, run)
│   ├── runtime.go      # RunSession: vibecoding agent loop, naming, audit
│   ├── toolkit.go      # ToolRegistry + schema.*/data.* executors + ChartHint
│   ├── sdk_tools.go    # agent.ExternalTool adapter (project scope + write authz)
│   ├── authz.go        # RunOptions, write-approval policy, audit sink
│   ├── project_config.go # per-project overrides (§9.1)
│   ├── files.go        # record file ref → image content block (§6.2)
│   └── store_db.go     # DB-backed session/message store
├── cmd/                # CLI commands
│   ├── serve.go        # `serve` command
│   ├── admin.go        # `admin create` command
│   └── mcp.go          # `mcp` command (stdio transport)
├── dbx/                # Database query builder (fork of ozzo-dbx)
│   ├── builder.go      # BaseBuilder: CreateTable, AddColumn, DropColumn, etc.
│   ├── builder_sqlite.go # SqliteBuilder: SQLite-specific overrides
│   ├── builder_pgsql.go  # PgsqlBuilder: PostgreSQL-specific overrides
│   └── builder_mysql.go  # MysqlBuilder: MySQL-specific overrides
├── tools/              # Shared utilities
│   ├── security/       # JWT, bcrypt, random string generation
│   ├── types/          # DateTime (custom time type with Scan/MarshalJSON)
│   ├── search/         # Filter/sort/search provider
│   ├── migrate/        # Migration runner
│   └── list/           # Slice/string helpers
├── ui/                 # Admin UI (Svelte SPA)
│   ├── src/
│   │   ├── components/settings/PageMCPTokens.svelte # MCP token management page
│   │   └── routes.js   # SPA routes (includes /settings/mcp-tokens)
│   └── dist/           # Built frontend (embedded in Go binary)
└── vendor/             # **DO NOT DELETE.** All Go dependencies.

Read the full file on GitHub · 294 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 294 lines · 4,530 tokens per session scan A 99f39855f263

Subscribe to this mod's changes

postgrebase AGENTS.md is an instructions file published in the GitHub repository zhenruyan/postgrebase (91 stars, last pushed 1mo ago), licensed MIT. It adds 4,530 tokens to every session, about $0.0226 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.