04-table-common-fields

A database table standard that requires every table to include identity, ownership, deletion, and change-history fields. A tenant is a customer or organization sharing the system, and an OEM is the product maker or vendor associated with the data.

In plain words
What is it for?
Use it when creating database tables or Java database models. It defines the required fields, their order, deletion behavior, timestamps, primary key, and tenant index.
Why use it?
It keeps table structure consistent across system and business data. Standard fields make it possible to identify ownership, hide logically deleted records, and track who changed records and when.

Cursor rule

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 rules/movebrickschi/harness-engineering-mcp/04-table-common-fields
Clone the repo
git clone --depth 1 https://github.com/movebrickschi/harness-engineering-mcp
Per session 962 This file is loaded in full into every session.
When invoked 962 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.00962 $0.00962
Opus 5 $0.00481 $0.00481
Sonnet 5 $0.00192 $0.00192
Haiku 4.5 $0.00096 $0.00096

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

Security

Grade A, and why

04-table-common-fields 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.

assets/rules/04-table-common-fields.mdc · 102 lines

How it starts

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

数据库表公共字段规范

所有数据库表(系统表 + 业务表)必须包含以下 7 个公共字段。

字段顺序

  1. id(主键)
  2. tenant_idoem_id(归属字段)
  3. 业务字段
  4. deletedcreated_byupdated_bycreated_atupdated_at(审计字段)
  5. PRIMARY KEY、索引

SQL DDL 模板

CREATE TABLE IF NOT EXISTS xxx (
    id           BIGINT       NOT NULL AUTO_INCREMENT COMMENT '主键',
    tenant_id    BIGINT       NOT NULL COMMENT '租户ID',
    oem_id       BIGINT       DEFAULT NULL COMMENT 'OEM厂商ID',
    -- ... 业务字段 ...
    deleted      TINYINT      NOT NULL DEFAULT 0 COMMENT '逻辑删除 0-未删除 1-已删除',
    created_by   BIGINT       DEFAULT NULL COMMENT '创建人userId',
    updated_by   BIGINT       DEFAULT NULL COMMENT '更新人userId',
    created_at   DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    updated_at   DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (id),
    INDEX idx_tenant_id (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='表注释';

Java Entity 模板

@Data
@TableName("xxx")
public class Xxx {

    @TableId(type = IdType.AUTO)
    private Long id;

    private Long tenantId;

    private Long oemId;

    // ... 业务字段 ...

    @TableLogic
    private Integer deleted;

    @TableField(fill = FieldFill.INSERT)
    private Long createBy;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateBy;

    private LocalDateTime createdAt;

    private LocalDateTime updatedAt;
}

自动填充机制

  • tenant_id:由 TenantLineInnerInterceptor 拦截器自动注入,无需手动赋值
  • created_by:通过 MetaObjectHandler 在 INSERT 时自动填充当前登录用户 userId
  • updated_by:通过 MetaObjectHandler 在 INSERT 和 UPDATE 时自动填充当前登录用户 userId
  • created_at / updated_at:由 MySQL DEFAULT CURRENT_TIMESTAMP / ON UPDATE CURRENT_TIMESTAMP 自动维护,无需代码赋值

数据库操作前置校验(MCP)

涉及数据库表结构变更时(新增表、修改表、新增字段等),如果当前环境有可用的数据库 MCP 工具(如 user-mysql),必须先查询数据库现状再给出方案

新增表

  1. 使用 list_tables 查询当前所有表,确认目标表名不存在
  2. 如果表已存在,使用 describe_table 查看现有表结构,改为给出 ALTER TABLE 方案而非 CREATE TABLE

Read the full file on GitHub · 102 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 · 102 lines · 962 tokens per session scan A 46e16624c164

Subscribe to this mod's changes

04-table-common-fields is a cursor rule published in the GitHub repository movebrickschi/harness-engineering-mcp (2 stars, last pushed 3mo ago), licensed MIT. It adds 962 tokens to every session, about $0.0048 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-31.