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

Written for no agent in particular: nothing here depends on one.

Good fit 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.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/openyida/openyida/yida-db-seq-fix
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.

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/github.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/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for yida-db-seq-fix

Your own site · 80×15
<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="Reviewed on agentmods" width="80" 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. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.5 $0.00029 $0.00366
Sonnet 5.5 $0.00015 $0.00183
Haiku 4.5 $0.00007 $0.00092

Measured 1mo ago against content hash 0b9f4c93d839, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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. 1mo 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 (228 stars, last pushed today), licensed MIT. It adds 73 tokens to every session and 915 once invoked, about $0.0003 per session on Opus 5.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

azure-database-postgresql

Expert knowledge for Azure Database for PostgreSQL development including troubleshooting, best practices, decision making, architecture & design patterns, limits & quotas, security, configuration, integrations & coding patterns, and deployment. Use when using Flexible Server, pgvector/AI search, Private Link/TLS…

MicrosoftDocs/Agent-Skills · 137 tokens

azure-horizondb

Expert knowledge for Azure Horizondb development including troubleshooting, best practices, decision making, architecture & design patterns, limits & quotas, security, configuration, integrations & coding patterns, and deployment. Use when tuning pgvector, azureai SQL functions, LangChain vector stores, Apache AGE…

MicrosoftDocs/Agent-Skills · 110 tokens

postgresql-cli

PostgreSQL interactive terminal (psql) reference and usage guide. Use this skill whenever the user mentions psql, PostgreSQL command-line client, backslash commands, meta-commands, \d commands, database inspection, SQL scripting in PostgreSQL, importing/exporting data with psql, \copy, psql formatting, psql variables…

chaunsin/agent-skills · 148 tokens

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