yida-db-seq-fix

yida-db-seq-fix is a skill for Claude Code, Codex from openyida/openyida. It costs 73 tokens per session (915 once invoked), scanned A, original, MIT.

A tool for checking and correcting PostgreSQL sequences, which generate automatic numeric IDs for new rows. It is designed for Yida databases after automatic table creation or data migration.

In plain words
What is it for?
Use it to preview sequence problems with a dry run, fix affected sequences by setting them to the maximum ID plus one, and verify the result afterward.
Why use it?
A sequence can lag behind the largest existing ID and cause duplicate-primary-key errors when new records are inserted. The tool compares sequence values with actual table IDs before proposing a correction.

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/openyida/openyida/yida-db-seq-fix
Any agent
npx skills add openyida/openyida --skill yida-db-seq-fix
Clone the repo
git clone --depth 1 https://github.com/openyida/openyida

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 yida-db-seq-fix

README.md
[![agentmods](https://agentmods.dev/badge/skills/openyida/openyida/yida-db-seq-fix.svg)](https://agentmods.dev/skills/openyida/openyida/yida-db-seq-fix)
Your own site
<a href="https://agentmods.dev/skills/openyida/openyida/yida-db-seq-fix"><img src="https://agentmods.dev/badge/skills/openyida/openyida/yida-db-seq-fix.svg" alt="Measured on agentmods" height="20"></a>
Per session 73 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 915 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.1 $0.00073 $0.00915
Opus 5 $0.00036 $0.00458
Sonnet 5 $0.00015 $0.00183
Haiku 4.5 $0.00007 $0.00092

Measured 6d ago against content hash 0b9f4c93d839, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

yida-db-seq-fix 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 6d 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.

yida-skills/skills/yida-db-seq-fix/SKILL.md · 110 lines

What it actually says

PostgreSQL Sequence 自动修复

严格禁止 (NEVER DO)

  • 不要在生产环境直接执行 --fix,必须先用 --dry-run 预览
  • 不要在未确认数据库连接的情况下执行修复操作
  • 不要跳过 Sequence 检测直接修改数据库

严格要求 (MUST DO)

  • 执行修复前必须先用 --dry-run 确认影响范围
  • 修复完成后必须验证 Sequence 值是否正确更新
  • 记录修复操作日志,便于问题追溯

适用场景

用户意图 触发条件
Sequence 起始值检测 环境检测自动建表后,需要验证 Sequence 配置
主键冲突修复 插入数据时报 duplicate key value violates unique constraint 错误
预防性检查 数据迁移后,确保 Sequence 值正确

背景

宜搭环境检测自动建表时,PostgreSQL 的 Sequence 默认使用 START 1。如果数据迁移时已有数据,Sequence 起始值可能小于已有数据的最大 ID,导致插入时报主键冲突错误。

此工具用于:

  1. 检测 8 个核心表的 Sequence 当前值
  2. 对比表中实际最大 ID
  3. 自动将 Sequence 起始值设置为 max(id) + 1

命令

预览模式(推荐先执行)

openyida db-seq-fix --dry-run

输出示例:

📋 Sequence 检测报告

表名                    当前值    最大ID    状态
─────────────────────────────────────────────
form_component          1         1000      ⚠️ 需要修复
form_definition         1         500       ⚠️ 需要修复
...

💡 使用 openyida db-seq-fix --fix 执行自动修复

执行修复

openyida db-seq-fix --fix

输出示例:

✅ Sequence 修复完成

表名                    修复前    修复后
────────────────────────────────────────
form_component          1         1001
form_definition         1         501
...

监控的表

表名 Sequence 名称
form_component form_component_id_seq
form_definition form_definition_id_seq
form_instance form_instance_id_seq
form_permission form_permission_id_seq
process_definition process_definition_id_seq
process_instance process_instance_id_seq
process_task process_task_id_seq
system_log system_log_id_seq

参数说明

参数 说明
--dry-run 仅检测,不执行修复,输出检测报告
--fix 执行自动修复,将 Sequence 起始值设置为 max(id) + 1

错误处理

错误信息 原因 处理方式
数据库连接失败 数据库配置错误或服务不可用 检查数据库连接配置
表不存在 表尚未创建 先执行环境检测建表
Sequence 不存在 Sequence 未正确创建 手动创建 Sequence

注意事项

  1. 生产环境谨慎操作:建议在低峰期执行,避免影响业务
  2. 备份数据:修复前建议备份数据库
  3. 验证结果:修复后执行测试插入,确认问题已解决
  4. 日志记录:修复操作会记录到系统日志,便于追溯
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. 6d ago First seen · 110 lines · 73 tokens per session scan A 0b9f4c93d839

Subscribe to this mod's changes

yida-db-seq-fix is a skill published in the GitHub repository openyida/openyida (210 stars, last pushed today), licensed MIT. It adds 73 tokens to every session and 915 once invoked, about $0.0004 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

rds-postgres

Single-node managed Postgres. Default choice for relational data — and often replaces other nodes (see "Built-ins"). Config knobs: instanceClass, storageGB, encrypted, multiAz, publiclyAccessible, dbName.

AlexK020908/infra-designer · 0 tokens

database

A managed Postgres with a public, pooled, TLS endpoint — plus auth, storage, and realtime if you want them. The serverless-friendly database that pairs with a Vercel frontend or any external/edge compute. Provisioned in the Supabase dashboard, not IaC.

AlexK020908/infra-designer · 0 tokens

alloydb-basics

Manages clusters, instances, and backups for AlloyDB for PostgreSQL, and integrates with AlloyDB Model Context Protocol (MCP) tools for automated database operations. Use when creating, configuring, or administering AlloyDB databases. Do NOT use for general PostgreSQL instances (e.g. Cloud SQL) or other GCP databases.

google/skills · 72 tokens

cloud-sql-basics

This file generates or explains Cloud SQL resources. Use this file when the user asks to create a Cloud SQL instance or database for MySQL, PostgreSQL, or SQL Server. Cloud SQL manages third-party MySQL, PostgreSQL, and SQL Server instances as resources in Cloud SQL. For example, when Cloud SQL creates an open-source…

google/skills · 108 tokens

supabase

Use when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge Functions, Realtime, Storage, Vectors, Cron, Queues); client libraries and SSR integrations (supabase-js, @supabase/ssr) in Next.js, React, SvelteKit, Astro, Remix; auth issues (login, logout, sessions, JWT, cookies…

supabase/agent-skills · 185 tokens

supabase-postgres-best-practices

Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the…

supabase/agent-skills · 182 tokens