ops-db

ops-db is a skill for Claude Code, Codex from bezhai/chiwei-platform. It costs 37 tokens per session (1,048 once invoked), scanned A, original, MIT.

A controlled command for reading data and database structure from three PostgreSQL databases, or submitting database changes for human approval. PostgreSQL is a database system used to store application data.

In plain words
What is it for?
Use it to inspect tables and schemas, query business or test data, check platform metadata, or submit SQL changes such as adding a column for approval.
Why use it?
It limits routine access to read-only queries and keeps changes in an approval workflow. This reduces the risk of making unreviewed database changes.

Skill for Claude CodeCodex

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 skills/bezhai/chiwei-platform/ops-db
Any agent
npx skills add bezhai/chiwei-platform --skill ops-db
Clone the repo
git clone --depth 1 https://github.com/bezhai/chiwei-platform

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ops-db

README.md
[![agentmods](https://agentmods.dev/badge/skills/bezhai/chiwei-platform/ops-db.svg)](https://agentmods.dev/skills/bezhai/chiwei-platform/ops-db)
Your own site
<a href="https://agentmods.dev/skills/bezhai/chiwei-platform/ops-db"><img src="https://agentmods.dev/badge/skills/bezhai/chiwei-platform/ops-db.svg" alt="Measured on agentmods" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,048 The whole file, excluding the scripts and references it only reads on demand.
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.00037 $0.01048
Opus 5 $0.00018 $0.00524
Sonnet 5 $0.00007 $0.00210
Haiku 4.5 $0.00004 $0.00105

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

Security

Grade A, and why

ops-db 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 4d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (query.py, test_query.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

.claude/skills/ops-db/SKILL.md · 94 lines

How it starts

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

/ops-db:受控数据库访问

查询 PostgreSQL 数据库(只读),或提交 DDL/DML 变更申请(需人工审批后执行)。

名字保留 /ops-db 是为了不打断现有调用;语义上它不是普通 ops,而是 DB access + mutation workflow。

用法

只读查询

/ops-db @chiwei <SQL>            # 查询 chiwei(业务数据)
/ops-db @chiwei-test <SQL>       # 查询 chiwei-test(COE 隔离离线库)
/ops-db @paas_engine <SQL>       # 查询 paas_engine(PaaS 元数据)
/ops-db @chiwei schema           # 查看 chiwei 的表结构
/ops-db @paas_engine schema      # 查看 paas_engine 的表结构

@数据库 必填,不传会报错。

提交变更申请

/ops-db submit @chiwei ALTER TABLE messages ADD COLUMN foo TEXT;
-- reason: 支持新字段 foo 存储 xxx
  • @数据库 必填,指定目标库
  • -- reason: 说明变更目的(强烈建议填写)
  • 提交后返回 mutation_id,状态为 pending
  • 告知用户:已提交审批,ID=,请前往 Dashboard → DB 变更 页面审批

提交变更申请(大文本 / 含特殊字符,走文件入口)

当 SQL 含 PL/pgSQL DO $$ ... $$$var、单双引号、%、换行,或要复刻 persona 这类大文本时,不要走命令行($ARGUMENTS 经 shell 会把 $$ 展开成进程 PID,SQL 损坏)。改用 --file 入口,SQL 从文件逐字节原样读取, 完全不经 shell:

python3 .claude/skills/ops-db/query.py submit @chiwei-test --file /tmp/seed.sql --reason "复刻 prod bot_persona 到 chiwei-test"
  • 先把 SQL 写入纯路径文件(如 /tmp/seed.sql,路径不含特殊字符)
  • --file <path>:从该文件按 UTF-8 逐字节读取 SQL,原样提交,不做任何处理
  • --reason <text>:变更说明用独立参数传,不再从 SQL 里正则切 -- reason:(避免 persona 文本里的同形子串被误当成 reason)
  • @数据库、返回格式、审批流程与上面的命令行 submit 完全一致
  • 命令行 submit @db <SQL> -- reason: 旧用法保持不变,仅在需要文件入口时使用 --file

查询审批状态

/ops-db status 42

返回当前状态(pending/approved/rejected/failed)、审批备注、执行时间或错误信息。

数据库选择指引

库名 用途 何时使用
paas_engine PaaS 元数据:apps、builds、releases、config_bundles 等表 操作 PaaS 管理数据
chiwei 业务数据:messages、chats、users、memory 等表 操作赤尾业务数据
chiwei-test COE 隔离的独立离线 PG 容器集(chiwei_test 库) 操作 coe-* 泳道测试数据,与线上隔离

提交前先用 @数据库 schema 确认目标库和表结构正确。

预处理数据

!`python3 .claude/skills/ops-db/query.py "$ARGUMENTS"`

指令

  1. 如果是只读查询结果(columns + rows),格式化为 markdown 表格输出
  2. 如果是 submit 结果(id + status: pending),输出:
    已提交 DDL/DML 审批申请:
    - Mutation ID: <id>
    - 数据库: <db>
    - 状态: pending(等待人工审批)
    请前往 Dashboard → DB 变更 页面完成审批。
    
  3. 如果是 status 结果,格式化状态信息(状态、审批人、备注、执行时间、错误)
  4. 如果预处理报错,直接展示错误信息

Read the full file on GitHub · 94 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 4d ago First seen · 94 lines · 37 tokens per session scan A b4fa91672190

Subscribe to this mod's changes

ops-db is a skill published in the GitHub repository bezhai/chiwei-platform (20 stars, last pushed today), licensed MIT. It adds 37 tokens to every session and 1,048 once invoked, about $0.0002 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.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

auto-perf-optimize

Run agent-driven VS Code performance or memory investigations. Use when asked to launch Code OSS, automate a VS Code scenario, run the Chat memory smoke runner, capture renderer heap snapshots, take workflow screenshots, compare run summaries, or drive a repeatable scenario before heap-snapshot analysis.

microsoft/vscode · 62 tokens

chat-perf

Run chat perf benchmarks and memory leak checks against the local dev build or any published VS Code version. Use when investigating chat rendering regressions, validating perf-sensitive changes to chat UI, or checking for memory leaks in the chat response pipeline.

microsoft/vscode · 51 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens