14-mybatis-plus-conventions

14-mybatis-plus-conventions is a cursor rule for Cursor from movebrickschi/harness-engineering-mcp. It costs 1,036 tokens per session, scanned A, original, MIT.

A set of rules for MyBatis-Plus, a Java library that maps database queries to application code. It covers query building, SQL placement, pagination, logical deletion, and multi-tenant data handling.

In plain words
What is it for?
Use it when creating MyBatis-Plus mappers and database queries. It guides type-safe query conditions, when to use annotations or XML, and how to implement paged results.
Why use it?
It makes database code safer to change and more consistent. The rules reduce errors from misspelled column names, hand-written pagination, and missing tenant filters.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when creating MyBatis-Plus mappers and database queries. It guides type-safe query conditions, when to use annotations or XML, and how to implement paged results.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/movebrickschi/harness-engineering-mcp/14-mybatis-plus-conventions
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.

Clone the repo
git clone --depth 1 https://github.com/movebrickschi/harness-engineering-mcp

Made for: Cursor.

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 14-mybatis-plus-conventions

README.md
[![agentmods](https://agentmods.dev/badge/rules/movebrickschi/harness-engineering-mcp/14-mybatis-plus-conventions.svg)](https://agentmods.dev/rules/movebrickschi/harness-engineering-mcp/14-mybatis-plus-conventions)
Your own site
<a href="https://agentmods.dev/rules/movebrickschi/harness-engineering-mcp/14-mybatis-plus-conventions"><img src="https://agentmods.dev/badge/rules/movebrickschi/harness-engineering-mcp/14-mybatis-plus-conventions.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,036 This file is loaded in full into every session.
When invoked 1,036 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.01036 $0.01036
Opus 5 $0.00518 $0.00518
Sonnet 5 $0.00207 $0.00207
Haiku 4.5 $0.00104 $0.00104

Measured 8d ago against content hash 296cb010dd0b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

14-mybatis-plus-conventions 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 8d 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/14-mybatis-plus-conventions.mdc · 126 lines

How it starts

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

MyBatis-Plus 使用规范

Mapper 定义

所有 Mapper 接口继承 BaseMapper<T>,添加 @Mapper 注解:

@Mapper
public interface XxxMapper extends BaseMapper<Xxx> { }

查询构造器

优先使用 LambdaQueryWrapper / LambdaUpdateWrapper(类型安全),禁止使用字符串列名。

// ✅ 正确:Lambda 方式,编译时检查
LambdaQueryWrapper<SysRole> wrapper = new LambdaQueryWrapper<SysRole>()
        .eq(SysRole::getRoleCode, roleCode)
        .eq(SysRole::getTenantId, tenantId)
        .orderByDesc(SysRole::getCreatedAt);

// ❌ 禁止:字符串列名,重构时易出错
QueryWrapper<SysRole> wrapper = new QueryWrapper<SysRole>()
        .eq("role_code", roleCode);

条件构造支持动态条件(第一个参数为 boolean):

wrapper.eq(StringUtils.isNotBlank(name), SysRole::getRoleName, name);

自定义 SQL

简单的关联查询使用 @Select 注解直接写在 Mapper 接口上。复杂 SQL(动态条件多、超过 5 行)才使用 XML Mapper。

@Select("SELECT DISTINCT m.* FROM sys_menu m " +
        "INNER JOIN sys_role_menu rm ON rm.menu_id = m.id " +
        "WHERE rm.role_id = #{roleId} AND m.status = 1 " +
        "ORDER BY m.sort_order")
List<SysMenu> selectMenusByRoleId(@Param("roleId") Long roleId);

分页查询

统一使用 MyBatis-Plus 的 Page<T> + IPage<T>,不要手写 LIMIT/OFFSET。

// Controller
@GetMapping("/list")
public R<IPage<UserVO>> list(
        @RequestParam(defaultValue = "1") Integer page,
        @RequestParam(defaultValue = "10") Integer size) {
    Page<User> pageParam = new Page<>(page, size);
    IPage<UserVO> result = userService.findByPage(pageParam);
    return R.ok(result);
}

// Service / Mapper
IPage<User> selectPage(Page<User> page, @Param("ew") Wrapper<User> wrapper);

Entity 继承与审计字段

所有业务实体必须继承 BaseEntity,自动获得 createdAtupdatedAtcreateBycreateByTypeupdateByupdateByType 六个审计字段,由 AuditMetaObjectHandler 自动填充。

@Data
@EqualsAndHashCode(callSuper = true)
@TableName("xxx")
public class Xxx extends BaseEntity {
    @TableId(type = IdType.AUTO)
    private Long id;
    private Long tenantId;
    // ... 业务字段 ...
}

逻辑删除

需要逻辑删除的表在 Entity 字段上标记 @TableLogic

Read the full file on GitHub · 126 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. 8d ago First seen · 126 lines · 1,036 tokens per session scan A 296cb010dd0b

Subscribe to this mod's changes

14-mybatis-plus-conventions is a cursor rule published in the GitHub repository movebrickschi/harness-engineering-mcp (2 stars, last pushed 3mo ago), licensed MIT. It adds 1,036 tokens to every session, about $0.0052 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.