01-post-coding-doc-generation

A rule for creating or updating a Markdown document in the docs directory after a completed coding task. The document records database changes, configuration, API details, and the implementation flow in Chinese.

In plain words
What is it for?
Use it after backend coding work to document Flyway SQL, settings, API requests and responses, errors, and the path from controller through service to database.
Why use it?
It keeps important technical context alongside changes to modules, APIs, database tables, or configuration. This gives developers a reference for how the feature works and how to use it.

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/01-post-coding-doc-generation
Clone the repo
git clone --depth 1 https://github.com/movebrickschi/harness-engineering-mcp
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,998 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.00000 $0.01998
Opus 5 $0.00000 $0.00999
Sonnet 5 $0.00000 $0.00400
Haiku 4.5 $0.00000 $0.00200

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

Security

Grade A, and why

01-post-coding-doc-generation 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/01-post-coding-doc-generation.mdc · 191 lines

How it starts

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

Post-Coding Documentation Generation / 编码后文档生成

何时触发

当一轮编码任务完成后(包括但不限于:新增模块、新增/修改 API、新增数据库表、新增配置项),必须在 docs/ 目录下生成或更新一份对应的 .md 文档。

文档命名

  • 文件路径:docs/<module-name>.md
  • 命名规则:使用模块名的 kebab-case 形式,如 sys-user.mdwallet.mdich-craft.md
  • 如果文档已存在,在原文档上追加或更新对应章节,不要覆盖已有内容

文档必须包含的章节

1. 数据库脚本(如涉及)

  • 本项目使用 MySQL + Flyway 迁移
  • 列出本次新增或修改的 完整建表 DDLCREATE TABLE
  • 如果有数据初始化脚本(INSERT),也一并列出
  • 如果有索引变更、字段变更,列出 ALTER TABLE 语句
  • SQL 脚本放在 ```sql 代码块中,附带中文注释说明每个字段的用途
  • Flyway 迁移脚本路径:src/main/resources/db/migration/

2. 环境变量 / 配置项(如涉及)

  • 以表格形式列出新增的配置项:| 配置项 | 说明 | 默认值 | 示例 |
  • 给出 application.yaml 或 Nacos 配置示例片段
  • 如果涉及新增 @ConfigurationProperties 绑定类,说明配置读取方式

3. API 接口文档

对每个新增或修改的 API 接口,按以下结构描述:

### x.x 接口名称

**METHOD** `/api/admin/path` 或 `/api/app/path`

#### 请求体 / 请求参数

(JSON 示例 + 字段说明表格)

#### 响应体

(JSON 示例 + 字段说明表格,统一 R<T> 格式)

#### 错误响应

(状态码 + 错误场景 表格)

4. 业务逻辑与实现详解(核心章节)

这是文档中最重要的章节,目标是让任何开发者(包括不熟悉本模块的人)读完就能理解整个业务是怎么跑的。

4.1 每个 API 的完整调用链路

对每个 API 接口,必须描述从 Controller 到 Service 到数据库的完整调用链路

#### x.x 接口名称 — 实现详解

**调用链路**:
`XxxController.methodName()` → `XxxService.methodName()` → `XxxMapper.operation()`

**Controller 层**(文件:`XxxController.java`):
- 接收参数、鉴权方式(`@PreAuthorize` / `@PublicApi`)
- 参数校验逻辑(`@Valid` + Bean Validation 注解)
- 调用哪个 Service 方法

**Service 层**(文件:`XxxService.java`):
1. **步骤一**:描述做了什么(如:校验用户权限)
   - 关键判断条件:`if (xxx) { ... }`
   - 涉及的数据库查询:`xxxMapper.selectOne(new LambdaQueryWrapper<>()...)`
2. **步骤二**:描述核心业务逻辑
   - 数据转换 / 计算逻辑
   - 调用了哪些外部服务或工具方法
3. **步骤三**:描述数据库写入操作
   - 使用了事务吗?(`@Transactional`)
   - 写入了哪些表、哪些字段
   - 是否有级联操作

**异常处理**:
| 场景 | 抛出异常 | 错误码 | 错误信息 |
|------|---------|--------|---------|
| 记录不存在 | BusinessException.notFound() | 404 | 'xxx不存在' |
| 权限不足 | AccessDeniedException | 403 | '无权限访问' |
| 参数错误 | BusinessException.badRequest() | 400 | '具体校验信息' |
4.2 关键业务流程图(如涉及复杂流程)

对于涉及多步骤、多分支、多服务协作的复杂业务,用文本流程图编号步骤描述完整流程。

4.3 核心 Service 方法签名与职责

Read the full file on GitHub · 191 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 · 191 lines · 0 tokens per session scan A c21e32ef5801

Subscribe to this mod's changes

01-post-coding-doc-generation is a cursor rule published in the GitHub repository movebrickschi/harness-engineering-mcp (2 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,998 tokens. 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.